diff --git a/api/api.go b/api/api.go index 2983479..8836149 100644 --- a/api/api.go +++ b/api/api.go @@ -97,7 +97,11 @@ func (api *API) registerWebAppRoutes() { // Local / Offline Static Pages (No Template, No Auth) api.Router.GET("/local", api.localDocuments) + + // Reader (Reader Page, Document Progress, Devices) api.Router.GET("/reader", api.documentReader) + api.Router.GET("/reader/devices", api.authWebAppMiddleware, api.getDevices) + api.Router.GET("/reader/progress/:document", api.authWebAppMiddleware, api.getDocumentProgress) // Web App api.Router.GET("/", api.authWebAppMiddleware, api.createAppResourcesRoute("home")) @@ -106,7 +110,6 @@ func (api *API) registerWebAppRoutes() { api.Router.GET("/documents/:document", api.authWebAppMiddleware, api.createAppResourcesRoute("document")) api.Router.GET("/documents/:document/cover", api.authWebAppMiddleware, api.getDocumentCover) api.Router.GET("/documents/:document/file", api.authWebAppMiddleware, api.downloadDocument) - api.Router.GET("/documents/:document/progress", api.authWebAppMiddleware, api.getDocumentProgress) api.Router.GET("/login", api.createAppResourcesRoute("login")) api.Router.GET("/logout", api.authWebAppMiddleware, api.authLogout) api.Router.GET("/register", api.createAppResourcesRoute("login", gin.H{"Register": true})) diff --git a/api/app-routes.go b/api/app-routes.go index 4d9c772..beba89c 100644 --- a/api/app-routes.go +++ b/api/app-routes.go @@ -113,10 +113,9 @@ func (api *API) createAppResourcesRoute(routeName string, args ...map[string]any } templateVars["User"] = userID - // Potential URL Parameters - qParams := bindQueryParams(c) - if routeName == "documents" { + qParams := bindQueryParams(c, 9) + var query *string if qParams.Search != nil && *qParams.Search != "" { search := "%" + *qParams.Search + "%" @@ -181,6 +180,8 @@ func (api *API) createAppResourcesRoute(routeName string, args ...map[string]any templateVars["Data"] = document templateVars["TotalTimeLeftSeconds"] = int64((100.0 - document.Percentage) * float64(document.SecondsPerPercent)) } else if routeName == "activity" { + qParams := bindQueryParams(c, 15) + activityFilter := database.GetActivityParams{ UserID: userID, Offset: (*qParams.Page - 1) * *qParams.Limit, @@ -397,6 +398,20 @@ func (api *API) getDocumentProgress(c *gin.Context) { }) } +func (api *API) getDevices(c *gin.Context) { + rUser, _ := c.Get("AuthorizedUser") + + devices, err := api.DB.Queries.GetDevices(api.DB.Ctx, rUser.(string)) + + if err != nil && err != sql.ErrNoRows { + log.Error("[getDevices] GetDevices DB Error:", err) + errorPage(c, http.StatusInternalServerError, fmt.Sprintf("GetDevices DB Error: %v", err)) + return + } + + c.JSON(http.StatusOK, devices) +} + func (api *API) uploadNewDocument(c *gin.Context) { var rDocUpload requestDocumentUpload if err := c.ShouldBind(&rDocUpload); err != nil { @@ -981,13 +996,12 @@ func (api *API) getDocumentsWordCount(documents []database.GetDocumentsWithStats return nil } -func bindQueryParams(c *gin.Context) queryParams { +func bindQueryParams(c *gin.Context, defaultLimit int64) queryParams { var qParams queryParams c.BindQuery(&qParams) if qParams.Limit == nil { - var defaultValue int64 = 9 - qParams.Limit = &defaultValue + qParams.Limit = &defaultLimit } else if *qParams.Limit < 0 { var zeroValue int64 = 0 qParams.Limit = &zeroValue diff --git a/api/opds-routes.go b/api/opds-routes.go index 655bacd..dd2935f 100644 --- a/api/opds-routes.go +++ b/api/opds-routes.go @@ -49,7 +49,7 @@ func (api *API) opdsEntry(c *gin.Context) { }, Links: []opds.Link{ { - Href: "/api/opds/documents?limit=100", + Href: "/api/opds/documents", TypeLink: "application/atom+xml;type=feed;profile=opds-catalog", }, }, @@ -66,8 +66,8 @@ func (api *API) opdsDocuments(c *gin.Context) { userID = rUser.(string) } - // Potential URL Parameters - qParams := bindQueryParams(c) + // Potential URL Parameters (Default Pagination - 100) + qParams := bindQueryParams(c, 100) // Possible Query var query *string @@ -160,7 +160,7 @@ func (api *API) opdsSearchDescription(c *gin.Context) { rawXML := ` Search AnthoLume Search AnthoLume - + ` c.Data(http.StatusOK, "application/xml", []byte(rawXML)) } diff --git a/assets/lib/platform.min.js b/assets/lib/platform.min.js deleted file mode 100644 index a74305a..0000000 --- a/assets/lib/platform.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(){"use strict";var e={function:!0,object:!0},G=e[typeof window]&&window||this,i=e[typeof exports]&&exports,t=e[typeof module]&&module&&!module.nodeType&&module,r=i&&t&&"object"==typeof global&&global;!r||r.global!==r&&r.window!==r&&r.self!==r||(G=r);var a=Math.pow(2,53)-1,$=/\bOpera/,n=Object.prototype,o=n.hasOwnProperty,X=n.toString;function l(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function K(e){return e=H(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:l(e)}function j(e,t){for(var i in e)o.call(e,i)&&t(e[i],i,e)}function N(e){return null==e?l(e):X.call(e).slice(8,-1)}function V(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function z(i,r){var n=null;return function(e,t){var i=-1,r=e?e.length:0;if("number"==typeof r&&-1 - diff --git a/assets/reader/index.html b/assets/reader/index.html index 8ec5567..c593eae 100644 --- a/assets/reader/index.html +++ b/assets/reader/index.html @@ -20,7 +20,6 @@ - @@ -71,6 +70,10 @@ #top-bar:not(.top-0) { top: calc((8em + env(safe-area-inset-top)) * -1); } + + select:invalid { + color: gray; + } @@ -260,5 +263,120 @@ + + + + + + + + Select Device + + + + This device appears to be new! Please either assume an existing + device, or create a new one. + + + + + + + + + + + + + + + + Select Existing Device + + + + + + Assume Device + + + + + + + + + + + + + + + + + + + + + Create Device + + + + +
+ This device appears to be new! Please either assume an existing + device, or create a new one. +