Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pr/pacoesteban/780
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed Dec 27, 2023
2 parents a7937f3 + f01f2db commit 6720944
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ BASH ?= $(shell command -v bash 2> /dev/null)
# Development
SHIORI_DIR ?= dev-data

# Testing
GO_TEST_FLAGS ?= -v -race -count=1 -covermode=atomic -coverprofile=coverage.out
GOTESTFMT_FLAGS ?=

# Build
CGO_ENABLED ?= 0
BUILD_TIME := $(shell date -u +%Y%m%d.%H%M%S)
Expand Down
48 changes: 48 additions & 0 deletions docs/CLI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Content
---

<!-- TOC -->

- [Add bookmark](#add-bookmark)

<!-- /TOC -->

Add bookmark
---

To add bookmark with CLI you can use `shiori add`.

Shiori has flags to add bookmark: `shiori add --help`

```
Bookmark the specified URL
Usage:
shiori add url [flags]
Flags:
-e, --excerpt string Custom excerpt for this bookmark
-h, --help help for add
--log-archival Log the archival process
-a, --no-archival Save bookmark without creating offline archive
-o, --offline Save bookmark without fetching data from internet
-t, --tags strings Comma-separated tags for this bookmark
-i, --title string Custom title for this bookmark
Global Flags:
--log-caller logrus report caller or not
--log-level string set logrus loglevel (default "info")
--portable run shiori in portable mode
--storage-directory string path to store shiori data
```

Examples:

Add url:
`shiori add https://example.com`

Add url with tags:
`shiori add https://example.com -t "example-1,example-2"`

Add url with custom title:
`shiori add https://example.com --title "example example"`
124 changes: 118 additions & 6 deletions docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ There are several installation methods available :

<!-- TOC -->

- [Using Precompiled Binary](#using-precompiled-binary)
- [Building From Source](#building-from-source)
- [Using Docker Image](#using-docker-image)
- [Supported](#supported)
- [Using Precompiled Binary](#using-precompiled-binary)
- [Building From Source](#building-from-source)
- [Using Docker Image](#using-docker-image)
- [Community provided](#community-provided)
- [Using Kubernetes manifests](#using-kubernetes-manifests)

<!-- /TOC -->

## Using Precompiled Binary
## Supported

### Using Precompiled Binary

Download the latest version of `shiori` from [the release page](https://github.com/go-shiori/shiori/releases/latest), then put it in your `PATH`.

Expand All @@ -28,15 +33,15 @@ source $HOME/.profile

On Windows, you can simply set the `PATH` by using the advanced system settings.

## Building From Source
### Building From Source

Shiori uses Go module so make sure you have version of `go >= 1.14.1` installed, then run:

```
go get -u -v github.com/go-shiori/shiori
```

## Using Docker Image
### Using Docker Image

To use Docker image, you can pull the latest automated build from Docker Hub :

Expand All @@ -49,3 +54,110 @@ If you want to build the Docker image on your own, Shiori already has its [Docke
```
docker build -t shiori .
```

## Community provided

Below this there are other ways to deploy Shiori which are not supported by the team but were provided by the community to help others have a starting point.

### Using Kubernetes manifests

If you're self-hosting with a Kubernetes cluster, here are manifest files that
you can use to deploy Shiori:

`deploy.yaml`:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: shiori
labels:
app: shiori
spec:
replicas: 1
selector:
matchLabels:
app: shiori
template:
metadata:
labels:
app: shiori
spec:
volumes:
- name: app
hostPath:
path: /path/to/data/dir
containers:
- name: shiori
image: ghcr.io/go-shiori/shiori:latest
command: ["/usr/bin/shiori", "serve", "--webroot", "/shiori"]
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /srv/shiori
name: app
env:
- name: SHIORI_DIR
value: /srv/shiori
- name: HTTP_ROOT_PATH
value: "/shiori"
```
Here we are using a local directory to persist Shiori's data. You will need
to replace `/path/to/data/dir` with the path to the directory where you want
to keep your data. Since we haven't configured a database in particular,
Shiori will use SQLite. I don't think Postgres or MySQL is worth it for
such an app, but that's up to you. If you decide to use SQLite, I strongly
suggest to keep `replicas` set to 1 since SQLite usually allows at most
one writer to proceed concurrently.

Also, not that we're serving the app on the `/shiori` suffix. This is
only necessary if you want to access Shiori with an URL that looks like:
`http://your_domain_name/shiori`. This is also why we override the container's
command: to pass the webroot. If you want to use such suffix, you'll probably
need to deploy an ingress as well:

`ingress.yaml`:

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: shiori
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /shiori
pathType: Prefix
backend:
service:
name: shiori
port:
number: 8080
```

Finally, here is the service's config:

`service.yaml`

```yaml
apiVersion: v1
kind: Service
metadata:
name: shiori
spec:
type: NodePort
selector:
app: shiori
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 32654
```

I'm using the NodePort type for the service so I can access it easily on
my local network, but it's not necessary if you setup the ingress.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Shiori is a simple bookmarks manager written in Go language. Intended as a simpl
- [API](./API.md) (Deprecated)
- [APIv1](./APIv1.md) ([What is this?](https://github.com/go-shiori/shiori/issues/640))
- [Contributing](./Contribute.md)
- [Command Line Interface](./CLI.md)
- [Configuration](./Configuration.md)
- [FAQ](./Frequently-Asked-Question.md)
- [Installation](./Installation.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const docTemplate = `{
}
}
},
"/api/v1/bookmaeks/cache": {
"/api/v1/bookmarks/cache": {
"put": {
"produces": [
"application/json"
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
}
}
},
"/api/v1/bookmaeks/cache": {
"/api/v1/bookmarks/cache": {
"put": {
"produces": [
"application/json"
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ paths:
summary: Refresh a token for an account
tags:
- Auth
/api/v1/bookmaeks/cache:
/api/v1/bookmarks/cache:
put:
parameters:
- description: Update Cache Payload
Expand Down
2 changes: 1 addition & 1 deletion internal/http/routes/api/v1/bookmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func NewBookmarksPIRoutes(logger *logrus.Logger, deps *config.Dependencies) *Boo
// @Produce json
// @Success 200 {object} model.Bookmark
// @Failure 403 {object} nil "Token not provided/invalid"
// @Router /api/v1/bookmaeks/cache [put]
// @Router /api/v1/bookmarks/cache [put]
func (r *BookmarksAPIRoutes) updateCache(c *gin.Context) {
ctx := context.NewContextFromGin(c)
if !ctx.UserIsLogged() {
Expand Down
4 changes: 2 additions & 2 deletions internal/view/assets/js/component/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var template = `
v-if="editMode"
@click="selectBookmark">
</a>
<a class="bookmark-link" :href="mainURL" target="_blank" rel="noopener">
<a class="bookmark-link" :href="mainURL" target="_blank" rel="noopener noreferrer">
<span class="thumbnail" v-if="thumbnailVisible" :style="thumbnailStyleURL"></span>
<p class="title" dir="auto">{{title}}
<i v-if="hasContent" class="fas fa-file-alt"></i>
Expand All @@ -19,7 +19,7 @@ var template = `
</div>
<div class="spacer"></div>
<div class="bookmark-menu">
<a class="url" :href="url" target="_blank" rel="noopener">
<a class="url" :href="url" target="_blank" rel="noopener noreferrer">
{{hostnameURL}}
</a>
<template v-if="!editMode && menuVisible">
Expand Down
4 changes: 2 additions & 2 deletions internal/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<p id="metadata" v-cloak>Added {{localtime()}}</p>
<p id="title" dir="auto">$$.Book.Title$$</p>
<div id="links">
<a href="$$.Book.URL$$" target="_blank" rel="noopener">View Original</a>
<a href="$$.Book.URL$$" target="_blank" rel="noopener noreferrer">View Original</a>
$$if .Book.HasArchive$$
<a href="bookmark/$$.Book.ID$$/archive">View Archive</a>
$$end$$
Expand Down Expand Up @@ -82,7 +82,7 @@

document.querySelectorAll("#content a").forEach(elem => {
elem.setAttribute("target", "_blank");
elem.setAttribute("rel", "noopener");
elem.setAttribute("rel", "noopener noreferrer");
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion internal/webserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (h *Handler) PrepareTemplates() error {
`<div id="shiori-archive-header">
<p id="shiori-logo"><span>栞</span>shiori</p>
<div class="spacer"></div>
<a href="$$.URL$$" target="_blank">View Original</a>
<a href="$$.URL$$" target="_blank" rel="noopener noreferrer">View Original</a>
$$if .HasContent$$
<a href="/bookmark/$$.ID$$/content">View Readable</a>
$$end$$
Expand Down

0 comments on commit 6720944

Please sign in to comment.