Skip to content

Commit bb629da

Browse files
committed
2 parents d56a930 + 10fc103 commit bb629da

File tree

74 files changed

+215
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+215
-26
lines changed

.github/workflows/docker-image.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create and publish a Docker image
2+
3+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
4+
on:
5+
push:
6+
branches: ['release']
7+
8+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
14+
jobs:
15+
build-and-push-image:
16+
runs-on: ubuntu-latest
17+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
18+
permissions:
19+
contents: read
20+
packages: write
21+
#
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
33+
- name: Extract metadata (tags, labels) for Docker
34+
id: meta
35+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
39+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
40+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
41+
- name: Build and push Docker image
42+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
43+
with:
44+
context: .
45+
push: true
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}

README.md

+2-2

public/codecircles.png

-6.03 KB
Binary file not shown.

public/codecircles.webp

9.34 KB
Binary file not shown.

public/katex/README.md

+125

public/katex/contrib/auto-render.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
62.1 KB
Binary file not shown.
32.7 KB
Binary file not shown.
27.4 KB
Binary file not shown.
12.1 KB
Binary file not shown.
7.54 KB
Binary file not shown.
6.75 KB
Binary file not shown.
12.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
19.1 KB
Binary file not shown.
13 KB
Binary file not shown.
11.1 KB
Binary file not shown.
19.1 KB
Binary file not shown.
12.9 KB
Binary file not shown.
11.1 KB
Binary file not shown.
50.1 KB
Binary file not shown.
29.2 KB
Binary file not shown.
24.7 KB
Binary file not shown.
32.2 KB
Binary file not shown.
19 KB
Binary file not shown.
16.4 KB
Binary file not shown.
32.8 KB
Binary file not shown.
19.2 KB
Binary file not shown.
16.6 KB
Binary file not shown.
52.3 KB
Binary file not shown.
30.1 KB
Binary file not shown.
25.7 KB
Binary file not shown.
30.5 KB
Binary file not shown.
18.2 KB
Binary file not shown.
Binary file not shown.
30.6 KB
Binary file not shown.
18.3 KB
Binary file not shown.
16.1 KB
Binary file not shown.
23.9 KB
Binary file not shown.
14.1 KB
Binary file not shown.
11.9 KB
Binary file not shown.
21.8 KB
Binary file not shown.
13.8 KB
Binary file not shown.
11.7 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
10.1 KB
Binary file not shown.
16.3 KB
Binary file not shown.
10.3 KB
Binary file not shown.
9.42 KB
Binary file not shown.
11.9 KB
Binary file not shown.
6.34 KB
Binary file not shown.
5.34 KB
Binary file not shown.
11.2 KB
Binary file not shown.
6.04 KB
Binary file not shown.
5.09 KB
Binary file not shown.
7.41 KB
Binary file not shown.
4.32 KB
Binary file not shown.
3.54 KB
Binary file not shown.
10.1 KB
Binary file not shown.
5.84 KB
Binary file not shown.
4.81 KB
Binary file not shown.
26.9 KB
Binary file not shown.
15.7 KB
Binary file not shown.
Binary file not shown.

public/katex/katex.min.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/katex/katex.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/question.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const doRender = () => {
2+
renderMathInElement(document.body, {
3+
delimiters: [
4+
{ left: '$$', right: '$$', display: true },
5+
{ left: '\\[', right: '\\]', display: true },
6+
{ left: '$', right: '$', display: false },
7+
{ left: '\\(', right: '\\)', display: false },
8+
],
9+
})
10+
}
11+
12+
doRender();

src/middleware/options.go

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
package middleware
22

3-
import "github.com/gin-gonic/gin"
3+
import (
4+
"github.com/gin-gonic/gin"
5+
)
46

57
func OptionsMiddleware() gin.HandlerFunc {
68
return func(c *gin.Context) {
79
c.Set("disable_images", false)
810
c.Set("theme", "dark")
911

1012
imagesCookie, err := c.Cookie("disable_images")
11-
if err != nil {
12-
c.Next()
13-
return
14-
}
15-
16-
if imagesCookie == "true" {
17-
c.Set("disable_images", true)
13+
if err == nil {
14+
if imagesCookie == "true" {
15+
c.Set("disable_images", true)
16+
}
1817
}
1918

2019
themeCookie, err := c.Cookie("theme")
21-
if err != nil {
22-
c.Next()
23-
return
24-
}
25-
26-
if themeCookie == "light" {
27-
c.Set("theme", "light")
20+
if err == nil {
21+
if themeCookie == "light" {
22+
c.Set("theme", "light")
23+
}
2824
}
2925

3026
c.Next()

src/routes/options.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ func ChangeOptions(c *gin.Context) {
3030
if c.MustGet("theme").(string) == "dark" {
3131
text = "light"
3232
}
33+
3334
c.SetCookie("theme", text, 60*60*24*365*10, "/", "", false, true)
3435
// get redirect url from query
3536
redirectUrl := c.Query("redirect_url")
36-
if redirectUrl == "" {
37-
redirectUrl = os.Getenv("APP_URL")
38-
}
3937

4038
if !strings.HasPrefix(redirectUrl, os.Getenv("APP_URL")) {
4139
redirectUrl = os.Getenv("APP_URL")

templates/home.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
http-equiv="Content-Security-Policy"
88
content="default-src 'none'; style-src 'self'; script-src 'none'; img-src 'self';"
99
/>
10-
<link rel="icon" href="/static/codecircles.png" />
10+
<link rel="icon" href="/static/codecircles.webp" />
1111
<meta
1212
name="description"
1313
content="View StackOverflow threads in privacy and without the clutter."
@@ -19,7 +19,7 @@
1919
<div class="title">
2020
<img
2121
class="logo"
22-
src="/static/codecircles.png"
22+
src="/static/codecircles.webp"
2323
alt="4 circles with alternating colors between green and white"
2424
/>
2525
<h1>AnonymousOverflow</h1>

templates/question.html

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@
77
<link rel="stylesheet" href="/static/comments.css" />
88
<meta
99
http-equiv="Content-Security-Policy"
10-
content="default-src 'none'; style-src 'self'; script-src 'none'; img-src {{ .imagePolicy }};"
10+
content="default-src 'none'; style-src 'self'; script-src 'self'; img-src {{ .imagePolicy }};"
1111
/>
1212
<meta name="description" content="{{ .question.ShortenedBody }}..." />
1313
{{ template "sharedHead.html" }}
14-
</head>
14+
<link rel="stylesheet" href="/static/katex/katex.min.css">
15+
16+
<!-- The loading of KaTeX is deferred to speed up page rendering -->
17+
<script defer src="/static/katex/katex.min.js"></script>
18+
19+
<!-- To automatically render math in text elements, include the auto-render extension: -->
20+
<script defer src="/static/katex/contrib/auto-render.min.js"></script>
21+
<script defer src="/static/question.js" type="text/javascript"></script>
22+
</head>
1523
<body>
1624
<div class="parent">
1725
<div class="header">
1826
<a href="/" class="logo-link">
1927
<img
2028
class="logo"
21-
src="/static/codecircles.png"
29+
src="/static/codecircles.webp"
2230
alt="4 circles with alternating colors between green and white"
2331
/>
2432
</a>

templates/sharedHead.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<meta name="theme-color" content="#8CFFC1" />
2-
<meta name="og:image" content="/static/codecircles.png" />
2+
<meta name="og:image" content="/static/codecircles.webp" />
33
<meta name="viewport" content="width=device-width, initial-scale=1" />
44
<link rel="stylesheet" href="/static/globals.css" />

0 commit comments

Comments
 (0)