Skip to content

Commit

Permalink
Squashed 'memos/' changes from a94855516..9612c302c
Browse files Browse the repository at this point in the history
9612c302c chore: bump version to `v0.22.5`
773ab96bd chore: update thumbnail generator
09586d032 chore: fix user checks
fe01d68d2 fix: user role checks
5bbf57ece chore: update comments of find memo
c5ef5b904 chore: update readme
971128af0 revert: chore: bump mermaid from 10.9.1 to 11.0.2 in /web (#3870)
40d59fc47 chore: fix user role checks
7a9f61967 feat: allow admin users to update other memos
8c6682bd7 chore: regenerate apidocs
d13bb7648 chore: bump mermaid from 10.9.1 to 11.0.2 in /web (#3862)
0b1ca218c chore: bump lucide-react from 0.419.0 to 0.437.0 in /web (#3860)
7bce4f5d7 chore: bump @types/react from 18.3.4 to 18.3.5 in /web (#3859)
c018af624 chore: bump @types/node from 22.5.0 to 22.5.2 in /web (#3858)
45d45d093 chore: bump @bufbuild/buf from 1.38.0 to 1.39.0 in /web (#3861)
04fad85af chore: bump github.com/grpc-ecosystem/grpc-gateway/v2 from 2.21.0 to 2.22.0 (#3863)
a654b1267 chore: bump golang.org/x/mod from 0.19.0 to 0.20.0 (#3864)
2fac11936 chore: bump golang.org/x/oauth2 from 0.21.0 to 0.22.0 (#3866)
acc6c29d0 chore: bump github.com/aws/aws-sdk-go-v2/feature/s3/manager from 1.17.9 to 1.17.16 (#3867)
be25fbe18 chore: tweak readme
4322bfa50 chore: tweak seed data
fa2b01cfb chore: tweak latest schema file name
35b0bd82f chore: migrate of Docker compose v2 (#3857)
bfe57b920 chore: set max thumbnail width to home/explore image max width (#3852)
0156c7e11 perf: reduce image size by 21.3MB (#3849)
960af444f chore: fix linter
20570fc77 refactor: resource thumbnail
9b1adfbbe feat: reintroducing thumbnails (#3821)
615aa9479 fix: base path of migrator
710961d33 chore: fix text color in dark mode
bb86482b7 chore: tweak setting name
f0abd792c chore: update auth service
1167df29d feat: add security related settings
4e5810e20 chore: update workspace setting section
a8ea28066 chore: retire export memos
9bea6e1ee chore: go mod tidy
2dbf92f7f perf: reduce bundle size by 21% with direct icon imports (#3844)
d11bd30ec chore: tweak logger
de980fb7d chore: update setting display name
cce92f513 chore: tweak readme
7134ad488 chore: fix migration history
fbdfaf85d chore: update migrator
ccd3fdcd3 chore: fix tests
70837f88c chore: fix linter
525223c26 chore: add tests for migrator
96b9269cd chore: fix golangci linter
80f9b5b86 chore: fix golangci linter
fb23f4343 chore: update golangci config
eca9649be fix: cancel removes memo cache (#3826)
5f35ac5ca chore: update frontend dependencies
b376a20fb chore: tweak linter warnings
2999f472d chore: fix typo
45ddd05c4 chore: tweak linter warning
d1280bc04 chore: implement memo property runner
f4d667536 chore: add enable memo comment setting
3c5aa41a7 feat: implement week start day setting
06c460b47 chore: tweak linter warning
07012e3f6 chore: remove unused files
1b6685d7c chore: tweak linter warning
710d1b304 chore: update dev mode
6e901fc94 refactor: store migrator
1ae3afc0b chore: tweak memo relation popover
18db78172 feat: add translation for collapse/expand button and update polish locale (#3811)
aae3e8ae6 chore: update memo property checks
506d2ed8c chore: tweak menu style
c3f381c8c chore: add instance url to profile
9a27fdf85 chore: tweak load more button
fc2cd43dc chore: tweak util tests
c0826c43b fix: explicitly disabling `autocapitalize` and `spellcheck` (#3797)
724db203f chore: tweak seed data
04b4fa1d0 chore: tweak icon button container
61b8cee31 chore: retire preview markdown dialog
4ad602868 refactor: use popover instead of dialog for memo relations
a5978e765 fix: tag query for mysql (#3785)
158745704 feat: add memo display setting menu
01819610c chore: bump modernc.org/sqlite from 1.30.2 to 1.31.1 (#3769)
bc5e0b5da chore: bump github.com/aws/aws-sdk-go-v2/feature/s3/manager from 1.17.8 to 1.17.9 (#3770)
4924af523 chore: bump github.com/grpc-ecosystem/grpc-gateway/v2 from 2.20.0 to 2.21.0 (#3771)
12a916585 chore: bump react-router-dom from 6.25.1 to 6.26.0 in /web (#3772)
1fcb867e0 chore: bump react-i18next from 14.1.3 to 15.0.0 in /web (#3774)
222e9dfe5 chore: bump @types/node from 20.14.13 to 22.0.2 in /web (#3775)
55a2e791a chore: bump lucide-react from 0.399.0 to 0.419.0 in /web (#3773)
21f18f7c5 chore: tweak activity service definition
cc91b1e51 chore: buf generate
26fa17264 chore(frontend): add order by time asc
6184375cb chore: upgrade frontend dependencies
07667257d feat: support order by time asc
ea70dd85b chore: remove color in manifest
14194504e chore: remove unused classnames
444ccc03e chore: tweak default title
117077ac8 fix: dead link in README.md (#3750)
342b6ad69 chore: tweak seed data

git-subtree-dir: memos
git-subtree-split: 9612c302c4e897057967112be37f1d4adc0c061c
  • Loading branch information
lincolnthalles committed Sep 3, 2024
1 parent b236051 commit 852ff5a
Show file tree
Hide file tree
Showing 234 changed files with 4,297 additions and 4,434 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.1
version: v1.56.1
args: --verbose --timeout=3m
skip-cache: true

Expand Down
6 changes: 2 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ issues:
# https://golangci-lint.run/usage/configuration/#command-line-options
exclude:
- Rollback
- logger.Sync
- pgInstance.Stop
- fmt.Printf
- Enter(.*)_(.*)
- Exit(.*)_(.*)

linters-settings:
goimports:
Expand Down Expand Up @@ -75,6 +71,8 @@ linters-settings:
disabled: true
- name: if-return
disabled: true
- name: max-control-nesting
disabled: true
gocritic:
disabled-checks:
- ifElseChain
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ WORKDIR /backend-build
COPY . .
COPY --from=frontend /frontend-build/web/dist /backend-build/server/router/frontend/dist

RUN CGO_ENABLED=0 go build -o memos ./bin/memos/main.go
RUN CGO_ENABLED=0 go build -ldflags='-s -w' -trimpath -o memos ./bin/memos/main.go

# Make workspace with above generated files.
FROM alpine:latest AS monolithic
FROM gcr.io/distroless/static-debian12:latest AS monolithic
WORKDIR /usr/local/memos

RUN apk add --no-cache tzdata
ENV TZ="UTC"

COPY --from=backend /backend-build/memos /usr/local/memos/

EXPOSE 5230

# Directory to store the data, which can be referenced as the mounting point.
RUN mkdir -p /var/opt/memos
VOLUME /var/opt/memos

ENV MEMOS_MODE="prod"
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ docker run -d --name memos -p 5230:5230 -v ~/.memos/:/var/opt/memos neosmemo/mem
```

> [!NOTE]
> This command is only applicable for Unix/Linux systems. For Windows, please refer to the detailed [documentation](https://www.usememos.com/docs/install/self-hosting).
> This command is only applicable for Unix/Linux systems. For Windows, please refer to the detailed [documentation](https://www.usememos.com/docs/install/container-install#docker-on-windows).
>
> The `~/.memos/` directory will be used as the data directory on your local machine, while `/var/opt/memos` is the directory of the volume in Docker and should not be modified.
Expand All @@ -39,13 +39,11 @@ Learn more about [other installation methods](https://www.usememos.com/docs/inst

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. We greatly appreciate any contributions you make. Thank you for being a part of our community! 🥰

## Internationalization
## Sponsorship

Memos supports multiple languages. You can help us translate Memos into your language. We use Weblate to manage translations.
If you find Memos helpful, please consider sponsoring us. Your support will help us to continue developing and maintaining the project.

<a href="https://hosted.weblate.org/engage/memos-i18n/">
<img src="https://hosted.weblate.org/widget/memos-i18n/english/287x66-grey.png" alt="Translation status" />
</a>
❤️ Thanks to the following sponsors and backers: **[yourselfhosted](https://github.com/yourselfhosted)**, **[Burning_Wipf](https://github.com/KUKARAF)**, _[...see more](https://github.com/sponsors/usememos)_.

## Star history

Expand Down
67 changes: 22 additions & 45 deletions bin/memos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ var (
Short: `An open source, lightweight note-taking service. Easily capture and share your great thoughts.`,
Run: func(_ *cobra.Command, _ []string) {
instanceProfile := &profile.Profile{
Mode: viper.GetString("mode"),
Addr: viper.GetString("addr"),
Port: viper.GetInt("port"),
Data: viper.GetString("data"),
Driver: viper.GetString("driver"),
DSN: viper.GetString("dsn"),
Public: viper.GetBool("public"),
PasswordAuth: viper.GetBool("password-auth"),
Version: version.GetCurrentVersion(viper.GetString("mode")),
Mode: viper.GetString("mode"),
Addr: viper.GetString("addr"),
Port: viper.GetInt("port"),
Data: viper.GetString("data"),
Driver: viper.GetString("driver"),
DSN: viper.GetString("dsn"),
InstanceURL: viper.GetString("instance-url"),
Version: version.GetCurrentVersion(viper.GetString("mode")),
}
if err := instanceProfile.Validate(); err != nil {
panic(err)
Expand All @@ -57,16 +56,11 @@ var (
slog.Error("failed to create db driver", "error", err)
return
}
if err := dbDriver.Migrate(ctx); err != nil {
cancel()
slog.Error("failed to migrate database", "error", err)
return
}

storeInstance := store.New(dbDriver, instanceProfile)
if err := storeInstance.MigrateManually(ctx); err != nil {
if err := storeInstance.Migrate(ctx); err != nil {
cancel()
slog.Error("failed to migrate manually", "error", err)
slog.Error("failed to migrate", "error", err)
return
}

Expand Down Expand Up @@ -105,58 +99,43 @@ var (
)

func init() {
viper.SetDefault("mode", "demo")
viper.SetDefault("mode", "dev")
viper.SetDefault("driver", "sqlite")
viper.SetDefault("addr", "")
viper.SetDefault("port", 8081)
viper.SetDefault("public", false)
viper.SetDefault("password-auth", true)

rootCmd.PersistentFlags().String("mode", "demo", `mode of server, can be "prod" or "dev" or "demo"`)
rootCmd.PersistentFlags().String("mode", "dev", `mode of server, can be "prod" or "dev" or "demo"`)
rootCmd.PersistentFlags().String("addr", "", "address of server")
rootCmd.PersistentFlags().Int("port", 8081, "port of server")
rootCmd.PersistentFlags().String("data", "", "data directory")
rootCmd.PersistentFlags().String("driver", "sqlite", "database driver")
rootCmd.PersistentFlags().String("dsn", "", "database source name(aka. DSN)")
rootCmd.PersistentFlags().Bool("public", false, "")
rootCmd.PersistentFlags().Bool("password-auth", true, "")
rootCmd.PersistentFlags().String("instance-url", "", "the url of your memos instance")

err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode"))
if err != nil {
panic(err)
}
err = viper.BindPFlag("addr", rootCmd.PersistentFlags().Lookup("addr"))
if err != nil {
if err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode")); err != nil {
panic(err)
}
err = viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port"))
if err != nil {
if err := viper.BindPFlag("addr", rootCmd.PersistentFlags().Lookup("addr")); err != nil {
panic(err)
}
err = viper.BindPFlag("data", rootCmd.PersistentFlags().Lookup("data"))
if err != nil {
if err := viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port")); err != nil {
panic(err)
}
err = viper.BindPFlag("driver", rootCmd.PersistentFlags().Lookup("driver"))
if err != nil {
if err := viper.BindPFlag("data", rootCmd.PersistentFlags().Lookup("data")); err != nil {
panic(err)
}
err = viper.BindPFlag("dsn", rootCmd.PersistentFlags().Lookup("dsn"))
if err != nil {
if err := viper.BindPFlag("driver", rootCmd.PersistentFlags().Lookup("driver")); err != nil {
panic(err)
}
err = viper.BindPFlag("public", rootCmd.PersistentFlags().Lookup("public"))
if err != nil {
if err := viper.BindPFlag("dsn", rootCmd.PersistentFlags().Lookup("dsn")); err != nil {
panic(err)
}
err = viper.BindPFlag("password-auth", rootCmd.PersistentFlags().Lookup("password-auth"))
if err != nil {
if err := viper.BindPFlag("instance-url", rootCmd.PersistentFlags().Lookup("instance-url")); err != nil {
panic(err)
}

viper.SetEnvPrefix("memos")
viper.AutomaticEnv()
if err := viper.BindEnv("password-auth", "MEMOS_PASSWORD_AUTH"); err != nil {
if err := viper.BindEnv("instance-url", "MEMOS_INSTANCE_URL"); err != nil {
panic(err)
}
}
Expand All @@ -170,11 +149,9 @@ dsn: %s
addr: %s
port: %d
mode: %s
public: %t
password-auth: %t
driver: %s
---
`, profile.Version, profile.Data, profile.DSN, profile.Addr, profile.Port, profile.Mode, profile.Public, profile.PasswordAuth, profile.Driver)
`, profile.Version, profile.Data, profile.DSN, profile.Addr, profile.Port, profile.Mode, profile.Driver)

print(greetingBanner)
if len(profile.Addr) == 0 {
Expand Down
Loading

0 comments on commit 852ff5a

Please sign in to comment.