Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Customize the instance from an instance repository

6ce635a84ad5d5d0c862d4deb4d46489dc97c677 · Keenan Nemetz · 1d ago · parent f2fd4024

Customize the instance from an instance repository

The landing page's prose was config-only, so changing it meant editing
vole.toml on the host and restarting, and the packaged service cannot write
that file. Custom CSS, assets, and a favicon had nowhere to live at all.

This adds an instance repository, modelled on GitHub's .github repository:
fixed paths in one private repository, read as data rather than executed.

    profile/README.md           the landing page introduction
    profile/private/README.md   replaces it for signed-in viewers
    profile/custom.css          loaded after the built-in stylesheets
    profile/favicon.svg         favicon override
    assets/                     served at /static/custom/assets/

forge/instancerepo reads one commit into an immutable snapshot on a two
second timer and swaps it atomically; a request never runs git, and a load
failure keeps the previous theme. Markdown goes through the issue sanitiser,
assets are an extension whitelist with size and count caps, and scripts and
HTML are not assets. The repository is private to instance admins and hidden
from the home grid and activity rail, but its files are served to visitors.

The Admin Configuration tab grows an Instance repository panel: status, the
last commit, the last load error, the clone URL, the recognized paths, and a
button that creates the repository with starter files. The home page's pencil
keeps the in-place editor, but a save is now a commit to profile/README.md
with the admin as the author and web.home.intro in the audit log, instead of a
row in users.db.

The rest of the landing page stays in the shape it had: instance_name as the
heading, the introduction card, then the repository grid beside the Latest
rail. Moving a configurable page layout into a template system was tried and
dropped: this is fixed files, not a templating surface.

This replaces the pending introduction-store change, which is closed.

server/web/templates/home.html +36−18

@@ -2,28 +2,25 @@
2 2 {{template "header" .}}
3 3 <section class="hero">
4 4 <div class="hero-main">
5 <h1>{{.Instance.Name}}</h1>
6 <p class="hero-tagline">{{.Instance.Tagline}}</p>
7 {{if .Query}}
8 <p class="hero-vitals">Results for “{{.Query}}” · <a href="/">clear search</a></p>
9 {{else}}
10 <p class="hero-vitals">{{.Vitals.Repos}} {{if eq .Vitals.Repos 1}}repository{{else}}repositories{{end}}{{if not .Vitals.LastActivity.IsZero}} · last activity {{since .Vitals.LastActivity.Unix}}{{end}}</p>
11 {{end}}
5 <h1>{{.InstanceName}}</h1>
12 6 </div>
13 7 <div class="hero-actions">
14 8 {{if and .InstanceAdmin .Cards}}<a class="button" href="/repos/new">{{icon "plus"}}New repository</a>{{end}}
15 9 {{if not .LoggedIn}}
16 10 <a class="button secondary" href="/login">{{icon "user"}}Sign in</a>
17 {{if .OpenRegistration}}<a class="button secondary" href="/register">Create an account</a>{{end}}
11 {{if .OpenRegistration}}<a class="button secondary" href="/register">{{icon "user"}}Create an account</a>{{end}}
18 12 {{end}}
19 13 </div>
20 14 </section>
21 15
16 {{if not .Query}}{{template "home_readme" .}}{{end}}
17
22 18 {{if .Cards}}
23 19 <div class="home-grid">
24 20 <section class="home-main">
25 21 <div class="section-head">
26 22 <h2>{{if .Query}}Results{{else}}Repositories{{end}}</h2>
23 {{if .Query}}<a class="more" href="/">clear search</a>{{end}}
27 24 </div>
28 25 <div class="repo-grid">
29 26 {{range .Cards}}{{template "repo_card" .}}{{end}}
@@ -73,6 +70,37 @@
73 70 {{template "footer" .}}
74 71 {{end}}
75 72
73 {{define "home_readme"}}
74 {{if or .Intro .Editing .InstanceAdmin}}
75 <section class="panel readme-card" id="readme">
76 <div class="readme-head">
77 <span class="readme-name">{{icon "book-open"}}Introduction</span>
78 {{if and .InstanceAdmin (not .Editing) .RepoReady}}
79 <a class="readme-edit" href="/?edit=1#readme" title="Edit the introduction" aria-label="Edit the introduction">{{icon "pencil"}}</a>
80 {{end}}
81 </div>
82 {{if .Editing}}
83 <form method="post" action="/" class="readme-form">
84 <input type="hidden" name="csrf" value="{{.CSRF}}">
85 <textarea name="intro" rows="14" maxlength="20000" placeholder="What this forge is for, who it belongs to, and how to get started.">{{.IntroText}}</textarea>
86 <span class="field-hint">Markdown. It is rendered and sanitized, and shown here on the home page.</span>
87 <div class="form-actions">
88 <button type="submit">{{icon "check"}}Save</button>
89 <a class="button secondary" href="/">Cancel</a>
90 </div>
91 </form>
92 {{else if .Intro}}
93 <div class="md readme-body">{{.Intro}}</div>
94 {{else if .RepoReady}}
95 <p class="readme-empty">This forge has no introduction yet. <a href="/?edit=1#readme">Write one</a> to tell people what it is for.</p>
96 {{else}}
97 <p class="readme-empty">This instance has no repository for customization yet. Create it on the
98 <a href="/admin?tab=configuration">Admin Configuration</a> page to customize this introduction, the styles, and the assets.</p>
99 {{end}}
100 </section>
101 {{end}}
102 {{end}}
103
76 104 {{define "repo_card"}}
77 105 <article class="repo-card">
78 106 <div class="repo-card-top">
@@ -82,16 +110,6 @@
82 110 {{if not .Updated.IsZero}}<span class="repo-updated" title="Last activity">{{since .Updated.Unix}}</span>{{end}}
83 111 </div>
84 112 {{if .Description}}<p class="repo-desc">{{.Description}}</p>{{end}}
85 <p class="repo-meta">
86 {{if .Commit}}
87 <span class="sha">{{.Branch}}@{{short .Commit.SHA}}</span>
88 <span class="repo-subject">{{.Commit.Subject}}</span>
89 <span>{{.Commit.Author}}</span>
90 <span>{{since .Commit.When}}</span>
91 {{else}}
92 <span class="muted">No commits yet</span>
93 {{end}}
94 </p>
95 113 {{if or .OpenIssues .OpenChanges .LastTag}}
96 114 <div class="repo-chips">
97 115 {{if .OpenIssues}}<a class="chip" href="/r/{{.Name}}/issues">{{icon "circle-dot"}}{{.OpenIssues}} issue{{if ne .OpenIssues 1}}s{{end}}</a>{{end}}