Commit graph

108 commits

Author SHA1 Message Date
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
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
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
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 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
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
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
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
hulb
2b1ddd093d
replace assets generation with embed (#423) 2022-05-26 19:36:23 +02:00
Felipe Martin Garcia
ce8a172682
fix: bookmark content download (#413)
Fixed a bug where the content of the article would archive but the
reader version would not be saved due to variable passing. Also made the
code easier to follow by following return principles.

Fixes #406
2022-03-27 21:01:49 +02:00
Emmanuel Frecon
e1e2c7bfd8
Web Server and CI Improvements (#374)
* Fix for infinite redirect loop

path.Join trims the trailing slash if the path isn't /, use configured
root instead.

* Add repo root independence

This makes the workflows agnostic of the repository root, making it
possible to build in forked repos.

* Add HTTP request logging

* Fix proper RootPath handler

* Add logging for all resources

This adds proper logging for all resources, including errors. Logging
is on by default, but can be turned off.

* Report effective length of written data
2022-02-19 08:22:50 +01:00
Felipe Martin Garcia
fb0bf38b7e
feat: async content download when creating via api (#368)
* feat: async content download when creating via api

Invoking the content download code in a goroutine after saving the
bookmark, this way we can return a response to the user quickly while
the webpage is donwloaded and archived.

Cache api endpont (/api/cache) remains untouched until I understand
the logic behind it.

Also updated the API endpoint for the extension, though I'm unsure why
there's a difference between the "regular" API and the webext API,
they should be using the same APIs.
2022-02-13 21:09:42 +01:00
Felipe Martin Garcia
a76b121098
fix: golangci-lint errors (#366) 2022-02-13 16:38:27 +01:00
Felipe M
2ca628b7fe
hotfix: fixes session duration from #346 2022-02-11 16:00:38 +01:00
Felipe Martin Garcia
d56993292b
fix: remember me session duration (#346)
- Default session duration is 1h
- Increased session duration (when remember me is checked) is
  increased to 30d.
2022-02-11 14:05:34 +01:00
Dean Jackson
a5cb2c6e40 Fix login autofill
Add <form> element, as some browsers won't autofill fields
not contained in form.

Remove username and password bindings, and explicitly read
inputs instead. Some browsers do not fire onChange events
when a field is autofilled for security reasons, so Vue
bindings don't register the change.

https://github.com/facebook/react/issues/1159#issuecomment-506584346
2019-12-13 08:36:16 +01:00
Khoa Nguyen
d1d48ad788 wrap mime.TypeByExtension with preset mimetypes 2019-10-21 20:16:50 -07:00
Ninh Pham
98353369f7
Fix: grid layout on dialog 2019-10-14 10:51:11 +07:00
Radhi Fadlillah
7a2bcacf51 Fix: hasArchive icon gone after update bookmark 2019-10-13 08:37:10 +07:00
Radhi Fadlillah
7d938f3893 Fix: checkbox in dialog doesn't work 2019-10-13 08:22:17 +07:00
Ninh Pham
ef248c8fc4
Fix: Bookmark content displays Invalid Date if database is PostgreSQL #201 2019-10-12 20:15:11 +07:00
Radhi Fadlillah
d2906b126a Fix wrong cookie path 2019-10-11 14:14:17 +07:00
Radhi Fadlillah
0bc1b4a4cc Make sure archive use UTF-8 encoding 2019-10-09 20:49:26 +07:00
Radhi Fadlillah
a3e1563dff Move warc to another package 2019-10-09 20:10:12 +07:00
Radhi Fadlillah
9e962f0b2d Fix: now cookie set per subpath #39 2019-10-07 15:33:32 +07:00
Radhi Fadlillah
99d27930ea Initial support for subpath #39 2019-10-07 13:38:40 +07:00
Radhi Fadlillah
bf974facdc Add border around table in content view 2019-10-04 16:36:41 +07:00
Radhi Fadlillah
52bb4d9d8a Prevent browser doing MIME sniffing #182 2019-10-04 07:22:37 +07:00
Radhi Fadlillah
28ee496a68 Fix title is empty when adding bookmark 2019-10-03 20:23:28 +07:00
Radhi Fadlillah
b315c48acf Fix content with double braces not rendered #171 2019-09-25 07:32:03 +07:00
Radhi Fadlillah
752d1ba4f6 In no-thumbnail mode, make margin more consistent 2019-09-24 21:59:17 +07:00
Radhi Fadlillah
a82b8820bd Add options to hide excerpt #166 2019-09-24 21:16:03 +07:00
Radhi Fadlillah
c77b17caf8 Use formatter in LESS files 2019-09-24 11:56:35 +07:00
Radhi Fadlillah
bccc70b3f8 Add option to hide thumbnail image #166 2019-09-24 09:47:50 +07:00
Radhi Fadlillah
fbd4e37643 Fix custom title and excerpt doesn't saved 2019-09-22 16:17:51 +07:00
Radhi Fadlillah
1d83468455 Fix when using extension bookmark doesn't archived 2019-09-22 15:58:26 +07:00
Radhi Fadlillah
0bf5772022 Remove unneeded local variables 2019-09-21 16:19:45 +07:00
Radhi Fadlillah
64c62d6b12 Remove repeated code for archiving bookmarks 2019-09-20 16:48:57 +07:00
Radhi Fadlillah
2da0c7e297 Update readme to include web extension 2019-09-05 17:31:44 +07:00
Radhi Fadlillah
531c66c955 When session expired and user login, return him to previous page 2019-08-29 16:14:19 +07:00