-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch publisher to Bootstrap based tempaltes & add dark theme
Signed-off-by: Igor Shishkin <[email protected]>
- Loading branch information
Showing
22 changed files
with
596 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,45 @@ FROM alpine:3.20.3 AS certificates | |
RUN apk add --update --no-cache \ | ||
ca-certificates=20240705-r0 | ||
|
||
FROM scratch | ||
FROM index.docker.io/library/node:22.12.0 AS depsbuilder | ||
|
||
RUN mkdir /src | ||
WORKDIR /src | ||
RUN npm install \ | ||
[email protected] \ | ||
[email protected] | ||
|
||
FROM index.docker.io/library/node:22.12.0 AS tsbuilder | ||
|
||
RUN mkdir /src | ||
WORKDIR /src | ||
RUN npm install -g \ | ||
[email protected] | ||
COPY publisher/presenter/html/static/scripts /src/scripts | ||
RUN tsc scripts/index.ts --strict --removeComments --outDir /build | ||
|
||
FROM ubuntu:24.04 | ||
|
||
RUN mkdir -p \ | ||
/static/archived/scripts \ | ||
/static/archived/styles | ||
|
||
|
||
COPY dockerfiles/rootfs/etc/passwd /etc/passwd | ||
COPY dockerfiles/rootfs/etc/group /etc/group | ||
|
||
COPY --from=certificates /etc/ssl/cert.pem /etc/ssl/cert.pem | ||
COPY --from=certificates --chown=root:root --chmod=0644 /etc/ssl/cert.pem /etc/ssl/cert.pem | ||
COPY --chmod=0755 --chown=root:root dist/archived-publisher_linux_amd64_v3/archived-publisher /archived-publisher | ||
COPY --chmod=0644 --chown=root:root publisher/presenter/html/templates /templates | ||
COPY --chmod=0755 --chown=root:root publisher/presenter/html/templates /templates | ||
COPY --chmod=0755 --chown=root:root publisher/presenter/html/static /static/archived | ||
|
||
COPY --from=tsbuilder --chown=root:root --chmod=0644 /build /static/archived/scripts | ||
|
||
COPY --from=depsbuilder --chown=root:root /src/node_modules/bootstrap/dist /static/bootstrap | ||
COPY --from=depsbuilder --chown=root:root /src/node_modules/@popperjs/core/dist/umd /static/popperjs | ||
COPY --from=depsbuilder --chown=root:root /src/node_modules/bootstrap-icons/bootstrap-icons.svg /static/bootstrap-icons/bootstrap-icons.svg | ||
COPY --from=depsbuilder --chown=root:root /src/node_modules/bootstrap-icons/font /static/bootstrap-icons/font | ||
COPY --from=depsbuilder --chown=root:root /src/node_modules/bootstrap-icons/icons /static/bootstrap-icons/icons | ||
|
||
ENV HTML_TEMPLATE_DIR=/templates | ||
ENV STATIC_DIR=/static | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package html | ||
|
||
import "strconv" | ||
|
||
type Pagination struct { | ||
HasPrevious bool | ||
PreviousPageNum uint64 | ||
PreviousPageURL string | ||
Pages []Page | ||
HasNext bool | ||
NextPageNum uint64 | ||
NextPageURL string | ||
} | ||
|
||
type Page struct { | ||
IsCurrent bool | ||
Number uint64 | ||
URL string | ||
} | ||
|
||
func NewPagination(total, current, maxPages uint64, pageURL string) Pagination { | ||
pages := []Page{} | ||
max := current + maxPages | ||
if current+maxPages > total { | ||
max = total | ||
} | ||
for i := current; i <= max; i++ { | ||
isCurrent := false | ||
if i == current { | ||
isCurrent = true | ||
} | ||
pages = append(pages, Page{ | ||
IsCurrent: isCurrent, | ||
Number: i, | ||
URL: pageURL + "?page=" + strconv.FormatUint(i, 10), | ||
}) | ||
} | ||
|
||
var ( | ||
hasPrevious bool | ||
previousPageNum uint64 | ||
previousPageURL string | ||
) | ||
if current > 1 { | ||
hasPrevious = true | ||
previousPageNum = current - 1 | ||
previousPageURL = pageURL + "?page=" + strconv.FormatUint(previousPageNum, 10) | ||
} | ||
|
||
var ( | ||
hasNext bool | ||
nextPageNum uint64 | ||
nextPageURL string | ||
) | ||
if max < total { | ||
hasNext = true | ||
nextPageNum = current + maxPages + 1 | ||
nextPageURL = pageURL + "?page=" + strconv.FormatUint(nextPageNum, 10) | ||
} | ||
|
||
return Pagination{ | ||
HasPrevious: hasPrevious, | ||
PreviousPageNum: previousPageNum, | ||
PreviousPageURL: previousPageURL, | ||
Pages: pages, | ||
HasNext: hasNext, | ||
NextPageNum: nextPageNum, | ||
NextPageURL: nextPageURL, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package html | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPagination(t *testing.T) { | ||
r := require.New(t) | ||
|
||
pagination := NewPagination(305, 10, 3, "/some/page") | ||
r.Equal(Pagination{ | ||
HasPrevious: true, | ||
PreviousPageNum: 9, | ||
PreviousPageURL: "/some/page?page=9", | ||
Pages: []Page{ | ||
{IsCurrent: true, URL: "/some/page?page=10", Number: 10}, | ||
{IsCurrent: false, URL: "/some/page?page=11", Number: 11}, | ||
{IsCurrent: false, URL: "/some/page?page=12", Number: 12}, | ||
{IsCurrent: false, URL: "/some/page?page=13", Number: 13}, | ||
}, | ||
HasNext: true, | ||
NextPageNum: 14, | ||
NextPageURL: "/some/page?page=14", | ||
}, pagination) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
window.addEventListener('load', () => { | ||
const currentSwitch = localStorage.getItem('lightSwitch')?.toString() | ||
const htmlTag = document.getElementById('html'); | ||
const lightSwitch = document.getElementById('lightSwitch'); | ||
|
||
if (currentSwitch) { | ||
htmlTag?.setAttribute('data-bs-theme', currentSwitch); | ||
} | ||
|
||
lightSwitch?.addEventListener('click', () => { | ||
if (document.getElementById('html')?.getAttribute('data-bs-theme')?.toString() == "dark") { | ||
htmlTag?.setAttribute('data-bs-theme', 'light'); | ||
lightSwitch?.classList.remove('dark'); | ||
lightSwitch?.classList.add('light'); | ||
|
||
localStorage.setItem('lightSwitch', 'light'); | ||
return | ||
} | ||
htmlTag?.setAttribute('data-bs-theme', 'dark'); | ||
lightSwitch?.classList.remove('light'); | ||
lightSwitch?.classList.add('dark'); | ||
|
||
localStorage.setItem('lightSwitch', 'dark'); | ||
return | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.container { | ||
margin: 15px; | ||
} | ||
nav.pagination { | ||
margin-left: 45px; | ||
} |
Oops, something went wrong.