Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate ebook routes #742

Merged
merged 24 commits into from Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1af16bc
add new api
Monirzadeh Sep 29, 2023
a922bb7
UI use new API
Monirzadeh Sep 29, 2023
4b78818
remove legacy route
Monirzadeh Sep 29, 2023
a9c541c
Merge branch 'master' into epub-v1
Monirzadeh Sep 30, 2023
2cedf3c
Merge branch 'master' into epub-v1
Monirzadeh Oct 3, 2023
ace7de2
fix request to new api destination and read that response
Monirzadeh Oct 3, 2023
b6c0bb4
feat: allow authentication using cookies
fmartingr Oct 10, 2023
6dc3d80
fix: return proper error on validatesession
fmartingr Oct 10, 2023
df8da02
typo: secret key envionment variable in makefile
fmartingr Oct 10, 2023
97a9232
Merge branch 'feat/cookie-auth' into epub-v1
Monirzadeh Oct 13, 2023
22daafb
serve ebook file with new api
Monirzadeh Oct 13, 2023
c05bfba
cache update use new api path
Monirzadeh Oct 14, 2023
44b2c8f
add skipexist and batch download use same route as cache
Monirzadeh Oct 14, 2023
6c387c5
fix bug - update hasebook status
Monirzadeh Oct 14, 2023
8e608b9
remove unneeded part of code
Monirzadeh Oct 14, 2023
24b4ff5
add swagger documentation
Monirzadeh Oct 14, 2023
fe4dc2a
fix swagger documentation
Monirzadeh Oct 14, 2023
d175078
fix swagger response
Monirzadeh Oct 14, 2023
4893e5e
better statuscode
Monirzadeh Oct 23, 2023
7bbecdc
Merge branch 'master' into epub-v1
Monirzadeh Oct 23, 2023
75938fb
fix swagger documentation
Monirzadeh Oct 23, 2023
3aae47d
covert to snake_case
Monirzadeh Oct 28, 2023
e617c33
recover coverage.txt that remove
Monirzadeh Oct 28, 2023
11e6433
Merge branch 'master' into epub-v1
fmartingr Oct 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -44,7 +44,7 @@ serve:
## Runs server for local development
.PHONY: run-server
run-server:
GIN_MODE=$(GIN_MODE) SHIORI_DEVELOPMENT=$(SHIORI_DEVELOPMENT) SHIORI_DIR=$(SHIORI_DIR) SHIORI_SECRET_KEY=shiori go run main.go server
GIN_MODE=$(GIN_MODE) SHIORI_DEVELOPMENT=$(SHIORI_DEVELOPMENT) SHIORI_DIR=$(SHIORI_DIR) SHIORI_HTTP_SECRET_KEY=shiori go run main.go server

## Generate swagger docs
.PHONY: swagger
Expand Down
112 changes: 112 additions & 0 deletions docs/swagger/docs.go
Expand Up @@ -126,6 +126,39 @@ const docTemplate = `{
}
}
},
"/api/v1/bookmaeks/cache": {
"put": {
"produces": [
"application/json"
],
"tags": [
"Auth"
],
"summary": "Update Cache and Ebook on server.",
"parameters": [
{
"description": "Update Cache Payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api_v1.updateCachePayload"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Bookmark"
}
},
"403": {
"description": "Token not provided/invalid"
}
}
}
},
"/api/v1/tags": {
"get": {
"produces": [
Expand Down Expand Up @@ -215,6 +248,32 @@ const docTemplate = `{
}
}
},
"api_v1.updateCachePayload": {
"type": "object",
"required": [
"ids"
],
"properties": {
"create_archive": {
"type": "boolean"
},
"create_ebook": {
"type": "boolean"
},
"ids": {
"type": "array",
"items": {
"type": "integer"
}
},
"keep_metadata": {
"type": "boolean"
},
"skip_exist": {
"type": "boolean"
}
}
},
"model.Account": {
"type": "object",
"properties": {
Expand All @@ -235,6 +294,59 @@ const docTemplate = `{
}
}
},
"model.Bookmark": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"create_archive": {
"type": "boolean"
},
"create_ebook": {
"type": "boolean"
},
"excerpt": {
"type": "string"
},
"hasArchive": {
"type": "boolean"
},
"hasContent": {
"type": "boolean"
},
"hasEbook": {
"type": "boolean"
},
"html": {
"type": "string"
},
"id": {
"type": "integer"
},
"imageURL": {
"type": "string"
},
"modified": {
"type": "string"
},
"public": {
"type": "integer"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/model.Tag"
}
},
"title": {
"type": "string"
},
"url": {
"type": "string"
}
}
},
"model.Tag": {
"type": "object",
"properties": {
Expand Down
112 changes: 112 additions & 0 deletions docs/swagger/swagger.json
Expand Up @@ -115,6 +115,39 @@
}
}
},
"/api/v1/bookmaeks/cache": {
"put": {
"produces": [
"application/json"
],
"tags": [
"Auth"
],
"summary": "Update Cache and Ebook on server.",
"parameters": [
{
"description": "Update Cache Payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api_v1.updateCachePayload"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Bookmark"
}
},
"403": {
"description": "Token not provided/invalid"
}
}
}
},
"/api/v1/tags": {
"get": {
"produces": [
Expand Down Expand Up @@ -204,6 +237,32 @@
}
}
},
"api_v1.updateCachePayload": {
"type": "object",
"required": [
"ids"
],
"properties": {
"create_archive": {
"type": "boolean"
},
"create_ebook": {
"type": "boolean"
},
"ids": {
"type": "array",
"items": {
"type": "integer"
}
},
"keep_metadata": {
"type": "boolean"
},
"skip_exist": {
"type": "boolean"
}
}
},
"model.Account": {
"type": "object",
"properties": {
Expand All @@ -224,6 +283,59 @@
}
}
},
"model.Bookmark": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"create_archive": {
"type": "boolean"
},
"create_ebook": {
"type": "boolean"
},
"excerpt": {
"type": "string"
},
"hasArchive": {
"type": "boolean"
},
"hasContent": {
"type": "boolean"
},
"hasEbook": {
"type": "boolean"
},
"html": {
"type": "string"
},
"id": {
"type": "integer"
},
"imageURL": {
"type": "string"
},
"modified": {
"type": "string"
},
"public": {
"type": "integer"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/model.Tag"
}
},
"title": {
"type": "string"
},
"url": {
"type": "string"
}
}
},
"model.Tag": {
"type": "object",
"properties": {
Expand Down
73 changes: 73 additions & 0 deletions docs/swagger/swagger.yaml
Expand Up @@ -27,6 +27,23 @@ definitions:
config:
$ref: '#/definitions/model.UserConfig'
type: object
api_v1.updateCachePayload:
properties:
create_archive:
type: boolean
create_ebook:
type: boolean
ids:
items:
type: integer
type: array
keep_metadata:
type: boolean
skip_exist:
type: boolean
required:
- ids
type: object
model.Account:
properties:
config:
Expand All @@ -40,6 +57,41 @@ definitions:
username:
type: string
type: object
model.Bookmark:
properties:
author:
type: string
create_archive:
type: boolean
create_ebook:
type: boolean
excerpt:
type: string
hasArchive:
type: boolean
hasContent:
type: boolean
hasEbook:
type: boolean
html:
type: string
id:
type: integer
imageURL:
type: string
modified:
type: string
public:
type: integer
tags:
items:
$ref: '#/definitions/model.Tag'
type: array
title:
type: string
url:
type: string
type: object
model.Tag:
properties:
id:
Expand Down Expand Up @@ -143,6 +195,27 @@ paths:
summary: Refresh a token for an account
tags:
- Auth
/api/v1/bookmaeks/cache:
put:
parameters:
- description: Update Cache Payload
in: body
name: payload
required: true
schema:
$ref: '#/definitions/api_v1.updateCachePayload'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/model.Bookmark'
"403":
description: Token not provided/invalid
summary: Update Cache and Ebook on server.
tags:
- Auth
/api/v1/tags:
get:
produces:
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/update.go
Expand Up @@ -52,7 +52,7 @@ func updateHandler(cmd *cobra.Command, args []string) {
skipConfirm, _ := cmd.Flags().GetBool("yes")
noArchival, _ := cmd.Flags().GetBool("no-archival")
logArchival, _ := cmd.Flags().GetBool("log-archival")
keepMetadata := cmd.Flags().Changed("keep-metadata")
keep_metadata := cmd.Flags().Changed("keep-metadata")

// If no arguments (i.e all bookmarks going to be updated), confirm to user
if len(args) == 0 && !skipConfirm {
Expand Down Expand Up @@ -170,8 +170,8 @@ func updateHandler(cmd *cobra.Command, args []string) {
Bookmark: book,
Content: content,
ContentType: contentType,
KeepTitle: keepMetadata,
KeepExcerpt: keepMetadata,
KeepTitle: keep_metadata,
KeepExcerpt: keep_metadata,
LogArchival: logArchival,
}

Expand Down