Skip to content

Commit 4ce7cf5

Browse files
committed
Add optional CSS column layout
1 parent 93e44e6 commit 4ce7cf5

File tree

6 files changed

+48
-1
lines changed

6 files changed

+48
-1
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ VOLUME /data
33
ENV EXTERNAL_URL=http://localhost:8080
44
ENV OAUTH2_CLIENT_ID=""
55
ENV OAUTH2_SECRET=""
6+
ENV GBM_CSS_COLUMNS=""
67
EXPOSE 8080
78
EXPOSE 8443
89
COPY gobookmarks /bin/gobookmarks

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ You will require 3 environment arguments:
7171
| `OAUTH2_CLIENT_ID` | The Client ID generated from setting up Oauth2 on github: https://github.com/settings/developers |
7272
| `OAUTH2_SECRET` | Secret ID generated from setting up Oauth2 on github: https://github.com/settings/developers |
7373
| `EXTERNAL_URL` | The fully qualified URL that it is to accept connections from. Ie `http://localhost:8080` |
74+
| `GBM_CSS_COLUMNS` | If set (to any value) the `Column` keyword in your bookmarks will create CSS multi-column breaks rather than table cells. |
7475

7576
## Oauth2 setup
7677

funcs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ func NewFuncs(r *http.Request) template.FuncMap {
4646
"ref": func() string {
4747
return r.URL.Query().Get("ref")
4848
},
49+
"useCssColumns": func() bool {
50+
return UseCssColumns
51+
},
4952
"loggedIn": func() (bool, error) {
5053
session := r.Context().Value(ContextValues("session")).(*sessions.Session)
5154
githubUser, ok := session.Values["GithubUser"].(*github.User)

main.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,18 @@ div.title {
114114
.category-form textarea {
115115
height: 30vh;
116116
}
117+
118+
.cssColumns .bookmarkColumns {
119+
column-width: 18em;
120+
column-gap: 1em;
121+
}
122+
123+
.cssColumns .columnBreak {
124+
break-before: column;
125+
}
126+
127+
.cssColumns .categoryBlock {
128+
break-inside: avoid;
129+
page-break-inside: avoid;
130+
-webkit-column-break-inside: avoid;
131+
}

settings.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package gobookmarks
2+
3+
import "os"
4+
5+
var UseCssColumns = os.Getenv("GBM_CSS_COLUMNS") != ""

templates/indexPage.gohtml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,33 @@
44
<a href="{{ OAuth2URL }}">Login</a><br>
55
{{else}}
66
{{- range bookmarkPages }}
7-
<div class="bookmarkPage">
7+
<div class="bookmarkPage{{ if useCssColumns }} cssColumns{{ end }}">
88
{{- range .Blocks }}
99
{{- if .HR }}
1010
<hr class="bookmarkHr" />
1111
{{- else }}
12+
{{- if useCssColumns }}
13+
<div class="bookmarkColumns">
14+
{{- $first := true }}
15+
{{- range .Columns }}
16+
{{- if not $first }}<div class="columnBreak"></div>{{ end }}
17+
{{- range .Categories }}
18+
<div class="categoryBlock">
19+
<h2>{{ .Name }} <a class="edit-link" href="/editCategory?index={{ .Index }}&ref={{ref}}" title="Edit">&#9998;</a></h2>
20+
<ul style="list-style-type: none;">
21+
{{- range .Entries }}
22+
<li>
23+
<img src="/proxy/favicon?url={{ .Url }}" alt="" style="width: 1em; max-height: 1em; font-weight: bolder; font-family: -moz-bullet-font;" />
24+
<a href="{{ .Url }}" target="_blank">{{ .Name }}</a>
25+
</li>
26+
{{- end }}
27+
</ul>
28+
</div>
29+
{{- end }}
30+
{{- $first = false }}
31+
{{- end }}
32+
</div>
33+
{{- else }}
1234
<table>
1335
<tr valign="top">
1436
{{- range .Columns }}

0 commit comments

Comments
 (0)