* generate ebook get dstPath
* Archive and ebook can recover if download faild
* recover thumb if download faild
* thumb image create just if image processing is sucssesful
* create epub in tmp if it sucssesful copy to destination
* archive file create in tmp if it successful move to destination
* move to destination as function
* update ebook download api and remove .epub from file name
* report faild item to user
* not show dialog if error not happen
* update thumbnail based on last status of bookmark fix#524
* better warning massage
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* tmpFile without .epub
* MoveToDestination change to MoveFileToDestination
* return .epub
* log if downloadBookImage return error
* fix bug remove imgPath just if download last image be unsuccessful
* update old unit test
* add processing.go unit test
* small massage for report failded item to the user
* add some more unit test and samplefile
* use sample image in unit test
* use local sample file and unit test not need internet connection anymore
* update error to user and log that too
* add more comment
* update comment
* change variable name parentDir to dstDir
* more simpler error handling
* remove unneeded defer
* remvoe unneeded epubWriter.Close()
* more readable unit test in processing
* more readable unit test for ebooks
* delete all defer os.RemoveAll from unit tests
* Better comment
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* Better Error output
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* fix err.String() method
---------
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* refactor: swagger docs into a folder
* added scripts for the swaggger tasks
* check version and fmt
* CI
* formatted swag comments
* using custom delims
* revert custom delims
* swag 1.16.1
* update swagger docs
* avoid make swagger output
* swagger check
* test
* swag-fmt
* swagger run
* gofmt
* avoid swag-fmt check for now due to inconsistencies with gofmt
* re-enabled by using go fmt afterwards
* use newer swag in CI
* add gopath to path
* using go binary instead of unset env
* alternative
* correct swag version
* formatted
* formatted
* correct go fmt command
* make swagger
* swagger-check -> swag-check
* run swag-check on lint
* config: backwards comptabile dir
* remove duplicated frontend
* frontend: move assets to assets folder
* legacy routes handler in gin
* templates and asset in different embed
* new routes
* frontend routes serve old views
* added DTO for account object
* api auth calls legacy handler
* frontend: handle new error messages
* frontend: update urls
* frontend: login using new api
* updated frontend tests
* chore: remove debug route
* create shiori/gopher user if no owner is present
* server as default command
* serve -> server
* refactored database logic, allow database url
* removed unused configuration
* storage docs
* refactor cli to use cfg and deps
* check errors only in server
* log fatal instead of os exit
* dont default data directory to current dir
* fixed sqlite path
* trigger build on prs
* avoid releasing if lint/test fails
* pull request condition
* event -> event_name
* Get correct pull request number
* added workflow to delete dangling tags
* fix: nil error checking
* set gin mode first
* set gin mode before initialization
* fix logger
* allow version bump from custom ref
* Updated matrix link to workspace
* feat: add SHIORI_PG_SSLMODE
Some managed hosting providers don't support sslmode=disabled.
* handle empty value
---------
Co-authored-by: Felipe M <me@fmartingr.com>
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* generate ebook
* serve ebook file
* Update ebook.go not download same image twice anymore
* download ebook request api/ui part
* fix typo
* add stylesheet
* update hasEbook status
* download link update after ebook generate
update bookmark command in ui
* download ebook with bookmark title
* Apply suggestions from code review for better error handling
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* Update internal/view/js/page/home.js fix typo
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* import error lib and retuen missing error
* move ebook download action to update cache
* replace io/ioutil with io
* add missing error handling
* update Archive now always update ebook
* replace panic error with 404
* remove ebook with delete action
* add download ebook link to content page
* remove tags that not work correctly right now
* if file is pdf not generate ebook
* update style.css
* Revert "update style.css"
This reverts commit 519e10d6ce.
* remove download limit for api
* fix missing fmt.Errorf and change to errors.Wrap
* fix double panic
* return 404 if bookmark not exist
* change function name to GenerateEbook
* not isFatalErr anymore
* add unit test
* remove uneeded field for unit test
---------
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* thumb image will be not accesable anymore if it is private fix#578
* Update internal/webserver/handler-ui.go better error handling
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
---------
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* fix(real_ip): get user real ip from headers of request
* fix(real_ip): compatible with those header with multiple IP values separated by commas
* test(real_ip): add benchmark for IPv4 and IPv6 private address check
* fix(real_ip): check empty, then remove leading and tailing comma char, finally locate first IP field
* test(real_ip): move checker logic into utils and add more unit test cases
* test(real_ip): write unit tests covering all code branches of the `util-ip` module
* refactor(real_ip): use one-line `testify.assert.Panics` to capture intended panic in test case
* chore(real_ip): add module private variable `UserRealIpHeaderCandidates`
put those headers together, make it easy to manage in one place
* doc(real_ip): write docstring for each function in the `utils-ip` module
* chore(real_ip): choose more concrete and unambiguous name for test helper function
It is to avoid polluting the module name-space with too general names.
* chore(naming): change function names according to code style
* refactor(real_ip): simplify the code indicated by 'gosimple' and `golangci`
* chore(naming): rename the `utils-ip` file to `utils_ip` to match with the rest of the file structure
---------
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
* fix(sqlite): avoid using dash in fts5 queries
* test(db): get bookmarks and count with dash in keyword
* test(db): common and ad-hoc sqlite test case
Removed the usage of `panic()` when downloading a bookmark and simply
return an error that has to be checked by implementations.
Right now the API will continue if the bookmark download fails (either
sync or async) but will leave a log with the error cause, so the users
have the bookmark stored even if the archival didn't actually happen
(but can be done manually later on).
Fixes#459
After a first bookmark save, all subsequent ones fail because the update
query does not include an identifier and the update is done on all rows.
Introduced by 05fee53bd0
* chore: updated go-migrate dependencies
* fix: specify if we're saving bookmarks expecting a creation
up until now the SaveBookmarks method was doing some "magic" to do
"upserts" on the databases, but consistency between engines was scarce
and not knowing if we were expecting saving a new bookmark or updating
an existing one was leading to errors and inconsistencies in logic all
around the place. Now we need to specify a creation boolean when
saving and a differnt query will be make (INSERT vs UPDATE).
* fix(api): using incorrect bookmark for content downlaod
* test(db): added test pipeline for databases
Added functions that will share logic among the engines and will be
called on fresh databases on each test run
* dev: added basic docker-compose for development
* chore: uncommented tests
* ci(test): added mysql service
* typo
* test(mysql): select database after reset
* fix(mysql): ignore empty row errors when parsing tags
* fix(mysql): handle insert errors
* chore: added mysql variables to compose
* ci: explicit mysql service port exposed
When the HTTP request completes, the asynchronous bookmarks save may be incomplete.
In this case, the shared context is canceled and saving bookmarks fails.
Introduced by 09f2465065
* fix(psql): get last inserted id from insert query
book.ID was not being used, so inserts were failing.
the check for book.ID was removed and it is filled with the returning
id from the insert query
* test(psql): added save bookmarks simple test
* ci: added postgresql service
* fix(typo): QueryRow -> QueryRowContext
* ci: explicit postgresql port
* ci(test): 1.19 only
* ci: bind psql to localhost
* test(pg): migrate before test
* test(pg): migrate database before test
* fix(pg): check no rows error on get query
* [sqlite] Added has_content column and relevant migration
* Fix typo in docstring
* [sqlite] Fetch content for bookmarks separately
* [sqlite] Store has_content alongside with bookmark
* [sqlite] Rename variable to distinguish it from main query
* [sqlite] Use by-reference instead of no-op copy
* [sqlite] Reduce queries count from ≈30 to 1 to fetch tags
* Lint fixes
* Make minor logging improvements
* Wrap entire migration in transaction block
* Added «down» migration
* Drop workaround for old SQLite versions
* feat: session expire time from backend
Deduplicated logic from backend and frontend where we needed to take the
login checkbox into account for both back and front codebases. Now the
backend will send the frontend the expire time calculated only in one
place.
This is part of a multi-step process that will store sessions in
database, but this will ease the maintenance of this section for now.
* chore: remove test logger