Commit graph

208 commits

Author SHA1 Message Date
Felipe Martin
4df7e1dd8e
feat: build css from less files locally (#735)
* build less using lessc and bun

* build

* make styles-check

* Added workflow to check updates

* avoid embed less files

* docs

* updated tests to reflect changes

* typo

* fixed archive page css

* call styles check on pull requests

* comments in style.less

* fix archive styles affecting other pages

* minify using clean-css

* Split archive.css and style.css

* Updated docs
2023-09-16 19:58:55 +02:00
Monirzadeh
3fb3f6075b
just use one dependency for uuid (#736) 2023-09-16 18:34:51 +02:00
András Rutkai
e722cb6961
fix: properly parse mysql connection string, docs update (#730)
Mysql connection string update, docs update
2023-09-13 18:31:41 +02:00
Felipe Martin
ef1d18d81f
fix(db): handle usage of special characters in searches (#721)
* handle full text search for failing cases

* added test

* test getbookmarkcount too

* replaceall, fix getbookmarkcount
2023-09-11 18:20:09 +02:00
Monirzadeh
f4817cb9c3
fix: Ensure bookmark files are correctly downloaded before deleting current ones (#683)
* 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>
2023-08-20 18:20:13 +02:00
Felipe Martin
8b015a3850
Swagger improvements (#666)
* 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
2023-08-12 08:38:52 +02:00
arakimo
2e1016e5f1
preserve fragment in URLs (#315) (#687)
* preserve fragment in URLs (#315)

* fix: correctly handle URLs without a fragment

* simplify solution to (#315)
2023-08-05 09:04:25 +02:00
Felipe Martin
307f293430
chore: remove verbose logger (#685) 2023-07-30 07:59:36 +02:00
Felipe Martin
e0d4537b37
default to sqlite, warn dbms users (#667) 2023-07-30 07:41:32 +02:00
Felipe Martin
a60f65f24e
fix: title overwritten if user has defiend it (#684) 2023-07-29 09:24:12 +02:00
Felipe Martin
2cbc592ece
Show Shiori version on server command (#669)
Fixes #668
2023-07-22 18:44:03 +02:00
Felipe Martin
622d556fde
fix: title is never retrieved when adding bookmark (#664)
* fix: title is never retrieved when adding bookmark

Fixes #654
2023-07-21 16:14:34 +02:00
Felipe Martin
c5c7a5f600
Show version in login page (#652) 2023-07-21 09:25:19 +02:00
Felipe Martin
888d053b2d
Allow JWT authentication into legacy APIs (#651)
* typo: letter in login page

* httpconfig set defaults for secret key with warn

* allow new authentication in old api

* Updated warn log
2023-07-21 07:57:42 +02:00
Felipe Martin
a60dbf3dc5
Run legacy API and new API at the same time. (#648)
* 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
2023-07-19 18:25:41 +02:00
Felipe Martin
6f19c12c95
Start working on new REST API. Refactor logic in domains. (#497)
* added 404 template

* added auth domain

* added embed file for frontend

* added base config and dependencies

* added basic new http server

* added separated server command

* updated go modules

* removed modd file

* Added shortcut to send internal server error response

* Added JWT support to Auth Domain

* Added JWT support to API

* docs: added comments to response struct

* naming

* inline returns

* updated dependencies

* production logger

* bookmarks endpoint

* reverted old views api path

* frontend for api v1

* proper 404 error (not working atm)

* use response

* removed 404 html

* server error handler

* login and basic auth

* adjusted session duration

* properly retrieve tags

* properly delete bookmark

* cleanup

* archiver domain

* debug routes

* bookmark routes

* expiration by parameter

* move to logrus

* logout

* frontend cache

* updated dependencies

* http: migrated to gin

* linted

* Added version command

* unit tests, docs

* response test utils and tests

* remove logout handler

* auth

* createtag

* improved http test utilities

* assert message equals

* Remove 1.19 from test matrix

* moved api to v1 folder

* docs: contribute docs

* updated makefile

* updated usage docs

* warn in server command

* updaed docs with shiori version command

* Updated documentation

* deps: update
2023-07-17 14:30:18 +01:00
Monirzadeh
78a7578f5c
fix download data image fix #645 (#646) 2023-07-15 19:04:14 +01:00
Ryan Gonzalez
e02d3e7739
feat: add SHIORI_PG_SSLMODE (#536)
* 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>
2023-07-09 08:43:26 +02:00
Felipe Martin
6ab661520e
fix: prevent bookmark overwrite on download (#636) 2023-07-09 08:33:56 +02:00
Monirzadeh
249f4b89c8
Initial Ebook Support (#623)
* 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>
2023-07-09 08:29:32 +02:00
Monirzadeh
98c2d77257
thumb image will be not accesable anymore if it is private fix #578 (#627)
* 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>
2023-07-02 10:58:57 +02:00
Tomi lla
dde1b44e77
fix(log): record user real ip from headers (#603)
* 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>
2023-06-11 21:25:23 +02:00
Monirzadeh
a4b92504b0
fix direction in RTL language (#615)
Co-authored-by: Felipe Martin <812088+fmartingr@users.noreply.github.com>
2023-06-11 21:18:12 +02:00
chain710
888e59dabf
Add log args for root command (#565)
- log-level: specify log level, default info
- log-caller: whether log `file:lineno` or not, default false
- log FullTimestamp
2023-03-17 13:37:23 +01:00
sdvcrx
3c1229d6ce
fix(frontend): prevent archive header covering up the archive content (#562) 2023-02-22 13:05:55 +01:00
Ivan Li
47f288fb1d
fix: browser ext cannot archive and update bookmark. (#560) 2023-02-05 10:58:00 +01:00
mox46
52d9a6322f
use UTC for cookie expiry date in backend (#566) 2023-02-05 10:56:34 +01:00
Katarn
257506ae19
feat: improve bookmark image detection (#554) 2023-01-21 09:53:19 +01:00
Ryan Welch
1b03cc48d6
Reset page when searching for new tag (#550) 2023-01-10 12:46:13 +01:00
Felipe Martin
3fcb295d72
Make migrations transparent to the user (#530)
* refactor: remove migrate command

* reafactor: avoid migration errors on no changes
2022-11-27 15:39:27 +01:00
Felipe Martin
77269b7a64
feat(frontend): username autofocus on login (#519) 2022-10-16 12:17:02 +02:00
Felipe Martin
c86cf12638
fix: remove createnewid usages (#520)
* remove CreateNewID usages

* remove CreateNewID implementations and definition

* added missing sqlite envvar to compose file
2022-10-15 23:01:52 +02:00
Felipe Martin
d1f0ce8dbb
fix(api-ext): use same save logic as the api (#518)
* switched session priority to header then cookie

* fix(db): GetBookmarks handle no rows error

* fix(api-ext): using same save logic as the api
2022-10-15 14:16:12 +02:00
Felipe Martin
5f1adc6c34
fix(db): avoid using dash in fts5 queries (#514)
* 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
2022-10-15 11:33:29 +02:00
Felipe Martin Garcia
4de21eaf40
fix: avoid panic usage when downloading bookmark (#513)
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
2022-10-14 13:37:24 +02:00
Acelya
ed5a3bcbb9
fix: failed to save bookmark: constraint failed: UNIQUE constraint failed: bookmark.url (#515)
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
2022-10-13 19:18:40 +02:00
Felipe Martin Garcia
05fee53bd0
fix: saving bookmarks inconsistencies (#500)
* 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
2022-10-11 23:47:38 +02:00
Acelya
040dc5c5d1
fix: failed to save bookmark: context canceled (#499)
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
2022-10-11 18:08:21 +02:00
Felipe Martin Garcia
222fc14fe2
fix: remove CreateNewID usage from api handlers (#486) 2022-10-09 18:56:12 +02:00
Felipe Martin Garcia
158c52a325
fix: data dir permissions having execute for all (#493) 2022-10-09 18:50:42 +02:00
Felipe Martin Garcia
d0210447d2
fix: import should respect add_date or last_modified fields (#490)
* fix: handle last_modified and add_date in imports

* refactor: moved date format to a constant

* fix: use provided modified date when set
2022-10-09 17:05:52 +02:00
Felipe Martin Garcia
dc73cd825b
fix(psql): save bookmarks not using passed bookmark id for the insert (#484)
* 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
2022-10-09 17:05:30 +02:00
hulb
821b69d76c
fix err in keyword searching (#494) 2022-10-09 17:05:01 +02:00
Felipe Martin Garcia
460014581c
fix(import): check for no rows error (#487) 2022-10-04 13:54:33 +02:00
hulb
09f2465065
refactor:pass ctx to db layer, return err instead of recover panic (#450) 2022-09-30 12:19:36 +02:00
Felipe Martin Garcia
3deeda7151
feat: upgrade to go 1.19 (#469)
* feat: upgrade to go 1.19

* fix: ioutil deprecation notice
2022-08-11 14:22:10 +02:00
Felipe Martin Garcia
c8fec2a265
fix: remove manual transaction on sqlite migration 2 (#468) 2022-08-11 13:40:17 +02:00
Andriy Kushnir
0246e10dff
feat: improve performance for sqlite queries (#425)
* [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
2022-08-08 20:52:33 +02:00
Felipe Martin Garcia
cba5046231
feat: session expire time from backend (#437)
* 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
2022-07-23 11:32:53 +02:00
hulb
7e1824a8b5
fix invalid assets path when use webroot (#448)
Co-authored-by: hulb <hulb@RD-NeoHu.netis.com.cn>
2022-07-08 11:26:37 +02:00