diff --git a/.github/workflows/_buildx.yml b/.github/workflows/_buildx.yml index 467aeb72a..addbcb0c3 100644 --- a/.github/workflows/_buildx.yml +++ b/.github/workflows/_buildx.yml @@ -26,10 +26,9 @@ jobs: - name: Prepare master push tags if: github.event_name == 'push' && github.ref == 'refs/heads/master' run: | - echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV REPO=ghcr.io/${{ github.repository }} TAG=$(git describe --tags) - if [ -z "$(git tag --points-at HEAD)" ] + if [ -z "$(git tag --points-at HEAD)" ] || [ "$TAG" == *"rc"* ] then TAG2="dev" else diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 2ace23ed3..1d79eadd8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -21,4 +21,6 @@ jobs: uses: ./.github/workflows/_gorelease.yml call-buildx: needs: call-gorelease + # only build on pull requests from the same repo for now + if: github.event.pull_request.head.repo.full_name == github.repository uses: ./.github/workflows/_buildx.yml diff --git a/README.md b/README.md index 231e6579c..284b2aa47 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![IC](https://github.com/go-shiori/shiori/actions/workflows/push.yml/badge.svg?branch=master)](https://github.com/go-shiori/shiori/actions/workflows/push.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/go-shiori/shiori)](https://goreportcard.com/report/github.com/go-shiori/shiori) -[![#shiori@libera.chat](https://img.shields.io/badge/irc-%23shiori-orange)](https://web.libera.chat/#shiori) [![#shiori-general:matrix.org](https://img.shields.io/badge/matrix-%23shiori-orange)](https://matrix.to/#/#shiori:matrix.org) [![Containers](https://img.shields.io/static/v1?label=Container&message=Images&color=1488C6&logo=docker)](https://github.com/go-shiori/shiori/pkgs/container/shiori) diff --git a/internal/cmd/root.go b/internal/cmd/root.go index a360450fc..1af24fb9b 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -82,7 +82,7 @@ func initShiori(ctx context.Context, cmd *cobra.Command) (*config.Config, *confi logger.WithError(err).Fatal("error creating data directory") } - db, err := openDatabase(ctx, cfg.Database.DBMS, cfg.Database.URL) + db, err := openDatabase(logger, ctx, cfg) if err != nil { logger.WithError(err).Fatal("error opening database") } @@ -124,23 +124,24 @@ func initShiori(ctx context.Context, cmd *cobra.Command) (*config.Config, *confi return cfg, dependencies } -func openDatabase(ctx context.Context, dbms, dbURL string) (database.DB, error) { - if dbURL != "" { - return database.Connect(ctx, dbURL) +func openDatabase(logger *logrus.Logger, ctx context.Context, cfg *config.Config) (database.DB, error) { + if cfg.Database.URL != "" { + return database.Connect(ctx, cfg.Database.URL) } - if dbms == "mysql" { + + if cfg.Database.DBMS != "" { + logger.Warnf("The use of SHIORI_DBMS is deprecated and will be removed in the future. Please migrate to SHIORI_DATABASE_URL instead.") + } + + // TODO remove this the moment DBMS is deprecated + if cfg.Database.DBMS == "mysql" { return openMySQLDatabase(ctx) } - if dbms == "postgresql" { + if cfg.Database.DBMS == "postgresql" { return openPostgreSQLDatabase(ctx) } - return openSQLiteDatabase(ctx) -} -func openSQLiteDatabase(ctx context.Context) (database.DB, error) { - dataDir := os.Getenv("SHIORI_DIR") - dbPath := fp.Join(dataDir, "shiori.db") - return database.OpenSQLiteDatabase(ctx, dbPath) + return database.OpenSQLiteDatabase(ctx, fp.Join(cfg.Storage.DataDir, "shiori.db")) } func openMySQLDatabase(ctx context.Context) (database.DB, error) { diff --git a/internal/cmd/server.go b/internal/cmd/server.go index d32eccb98..68c1809a1 100644 --- a/internal/cmd/server.go +++ b/internal/cmd/server.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/go-shiori/shiori/internal/http" + "github.com/go-shiori/shiori/internal/model" "github.com/spf13/cobra" ) @@ -63,6 +64,8 @@ func newServerCommandHandler() func(cmd *cobra.Command, args []string) { cfg.Http.ServeWebUI = serveWebUI cfg.Http.SecretKey = secretKey + dependencies.Log.Infof("Starting Shiori v%s", model.BuildVersion) + server := http.NewHttpServer(dependencies.Log).Setup(cfg, dependencies) if err := server.Start(ctx); err != nil { diff --git a/internal/core/url.go b/internal/core/url.go index 0cd2bd0b4..8654c1d45 100644 --- a/internal/core/url.go +++ b/internal/core/url.go @@ -52,7 +52,6 @@ func RemoveUTMParams(url string) (string, error) { } } - tmp.Fragment = "" tmp.RawQuery = queryEncodeWithoutEmptyValues(queries) return tmp.String(), nil } diff --git a/internal/http/routes/legacy.go b/internal/http/routes/legacy.go index d9d3079bb..2ee379e9d 100644 --- a/internal/http/routes/legacy.go +++ b/internal/http/routes/legacy.go @@ -24,9 +24,6 @@ type LegacyAPIRoutes struct { func (r *LegacyAPIRoutes) convertHttprouteParams(params gin.Params) httprouter.Params { routerParams := httprouter.Params{} for _, p := range params { - if p.Key == "filepath" { - r.logger.WithField("value", p.Value).Error("filepath") - } routerParams = append(routerParams, httprouter.Param{ Key: p.Key, Value: p.Value, diff --git a/internal/webserver/handler-api.go b/internal/webserver/handler-api.go index 8362a835f..790324f5b 100644 --- a/internal/webserver/handler-api.go +++ b/internal/webserver/handler-api.go @@ -237,7 +237,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h if payload.Async { go func() { - bookmark, err := downloadBookmarkContent(book, h.DataDir, r, !userHasDefinedTitle, book.Excerpt != "") + bookmark, err := downloadBookmarkContent(book, h.DataDir, r, userHasDefinedTitle, book.Excerpt != "") if err != nil { log.Printf("error downloading boorkmark: %s", err) return @@ -249,7 +249,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h } else { // Workaround. Download content after saving the bookmark so we have the proper database // id already set in the object regardless of the database engine. - book, err = downloadBookmarkContent(book, h.DataDir, r, !userHasDefinedTitle, book.Excerpt != "") + book, err = downloadBookmarkContent(book, h.DataDir, r, userHasDefinedTitle, book.Excerpt != "") if err != nil { log.Printf("error downloading boorkmark: %s", err) } else if _, err := h.DB.SaveBookmarks(ctx, false, *book); err != nil {