Commit graph

46 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
hulb
8732fd7b6d
implement migration for mysql & postgres (#422) 2022-05-03 23:30:28 +02:00
Felipe Martin Garcia
81d52a2e24
feat: sqlite migrations (#398)
- Moved migrations from code to SQL files
- Using golang-migrate/v4
- Added a new CLI command: migrate
2022-03-26 08:33:57 +01:00
Tung Le
ca3cc11b2d
sqlite: remove unneeded LEFT JOIN to improve performance (#387)
* sqlite: remove unneeded LEFT JOIN to improve performance

* Fix handling join clause in GetBookmarks

* Revert changes in GetBookmarks
2022-03-10 23:32:58 +01:00
n8225
2b4fd9f0cb
Remove unneeded alter table transactions from sqlite (#372) 2022-02-14 19:49:46 +01:00
Felipe Martin Garcia
0bd297d63c
fix: update bookmark on sqlite database (#367)
It used an update and insert at the same time, since the virtual table
cannot have constrants nor upserts we need to try an update the
bookmark content to check for it's existence, inserting it only if the
update fails (don't affect any rows).

This will need to be improved in the future, since not all bookmark
updates require modification of the content table (in my case, I was
testing only updating tags).
2022-02-13 21:28:40 +01:00
Felipe Martin Garcia
a76b121098
fix: golangci-lint errors (#366) 2022-02-13 16:38:27 +01:00
n8225
f1c98a8e98
Update Dependencies and Replace mattn/go-sqlite with modernc.org/sqlite (#345)
* No more CGO

* Update all dependencies to current

* Only test against go 1.17.
2022-02-11 13:59:49 +01:00
Dean Jackson
32f9d2695f Explicit charset for MySQL connection 2019-12-13 08:52:26 +01:00
Radhi Fadlillah
9ba9d1eced Fix: wrong query in PostgreSQL 2019-10-03 21:47:03 +07:00
Radhi Fadlillah
a4dd1c8687 Specify character set when creating MySQL table #188 2019-10-03 21:02:25 +07:00
bvp
4eb86d60d7
Initial PostgreSQL support 2019-09-24 19:59:25 +03:00
Dean Jackson
988f2d6502 Use single quotes for better compatibility 2019-09-22 19:15:04 +02:00
Dean Jackson
ddf7c37208 Fix MySQL column definitions
- Add AUTO_INCREMENT to `id` fields
- Fix DEFAULT definitions on TEXT/BLOB fields

TEXT/BLOB field default values must be expressions:
https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
2019-09-22 18:58:26 +02:00
Dean Jackson
76a7856f80 Add specific size to bookmark_url key
MySQL can't index an entire TEXT field; the key must be truncated
https://stackoverflow.com/a/1827099
2019-09-22 18:49:11 +02:00
Radhi Fadlillah
df98c281d3 Make MySQL address changeable #156 2019-09-22 08:25:34 +07:00
Radhi Fadlillah
89aad30a17 Fix: missing column while updating database 2019-08-29 09:45:45 +07:00
Radhi Fadlillah
c22f904bdd If there are no owner yet, allow to use default account 2019-08-22 14:34:36 +07:00
Radhi Fadlillah
6b39742a35 Make SQLite database compatible with old version 2019-08-22 14:27:38 +07:00
Radhi Fadlillah
0c4d75f773 Add basic account level management 2019-08-12 19:57:18 +07:00
Radhi Fadlillah
4e76288e09 Add method to exclude or include some tags 2019-08-11 15:55:31 +07:00
Radhi Fadlillah
667e5b2e74 Initial MySQL support 2019-08-10 08:13:13 +07:00
Radhi Fadlillah
20e89216f0 Add option to mark if bookmark archive is public 2019-08-08 20:16:25 +07:00
Radhi Fadlillah
ea73eaff64 Add method for renaming tag 2019-08-07 23:30:17 +07:00
Radhi Fadlillah
bc9aa7f634 Now search look at excerpt as well 2019-08-07 10:56:12 +07:00
Radhi Fadlillah
3503484c2b Add account management in web interface 2019-05-31 22:41:29 +07:00
Radhi Fadlillah
3b8dead04d Implement edit bookmark in web interface 2019-05-30 10:07:20 +07:00
Radhi Fadlillah
093b398b2f Implement add bookmark in web interface 2019-05-28 17:05:11 +07:00
Radhi Fadlillah
61bd8244a6 Initial new web interfaces 2019-05-27 17:01:53 +07:00
Radhi Fadlillah
4ab1253f8c Implement logic for import cmd 2019-05-23 09:22:47 +07:00
Radhi Fadlillah
9a9baf9f91 Implement logic for update cmd 2019-05-22 16:13:52 +07:00
Radhi Fadlillah
3b4f9bf248 Add logic for delete cmd 2019-05-22 08:13:52 +07:00
Radhi Fadlillah
659a3291d8 Implement logic for add and print cmd 2019-05-21 23:24:11 +07:00
Radhi Fadlillah
1e099fbd27 Restructure project directories 2019-05-21 10:31:40 +07:00