Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 0 additions & 90 deletions blog/blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,21 +1002,6 @@ func (b *Blog) Home(c *gin.Context) {
})
}

// Posts is the index page for blog posts
func (b *Blog) Posts(c *gin.Context) {
b.Render(c, http.StatusOK, "posts.html", gin.H{
"logged_in": b.auth.IsLoggedIn(c),
"is_admin": b.auth.IsAdmin(c),
"posts": b.GetPosts(false),
"version": b.Version,
"title": "Posts",
"recent": b.GetLatest(),
"admin_page": false,
"settings": b.GetSettings(),
"nav_pages": b.GetNavPages(),
})
}

// Post is the page for all individual posts
func (b *Blog) Post(c *gin.Context) {
post, err := b.GetPostObject(c)
Expand Down Expand Up @@ -1137,81 +1122,6 @@ func (b *Blog) Tag(c *gin.Context) {
}
}

// Tags is the index page for all Tags
func (b *Blog) Tags(c *gin.Context) {
b.Render(c, http.StatusOK, "tags.html", gin.H{
"version": b.Version,
"title": "Tags",
"tags": b.getTags(),
"recent": b.GetLatest(),
"admin_page": false,
"settings": b.GetSettings(),
"nav_pages": b.GetNavPages(),
})
}

// Speaking is the index page for presentations
func (b *Blog) Speaking(c *gin.Context) {
b.Render(c, http.StatusOK, "presentations.html", gin.H{
"logged_in": b.auth.IsLoggedIn(c),
"is_admin": b.auth.IsAdmin(c),
"version": b.Version,
"title": "Presentations and Speaking",
"recent": b.GetLatest(),
"admin_page": false,
"settings": b.GetSettings(),
"nav_pages": b.GetNavPages(),
})
}

// Projects is the index page for projects / code
func (b *Blog) Projects(c *gin.Context) {
b.Render(c, http.StatusOK, "projects.html", gin.H{
"logged_in": b.auth.IsLoggedIn(c),
"is_admin": b.auth.IsAdmin(c),
"version": b.Version,
"title": "Projects",
"recent": b.GetLatest(),
"admin_page": false,
"settings": b.GetSettings(),
"nav_pages": b.GetNavPages(),
})
}

// About is the about page
func (b *Blog) About(c *gin.Context) {
b.Render(c, http.StatusOK, "about.html", gin.H{
"logged_in": b.auth.IsLoggedIn(c),
"is_admin": b.auth.IsAdmin(c),
"version": b.Version,
"title": "About",
"recent": b.GetLatest(),
"admin_page": false,
"settings": b.GetSettings(),
"nav_pages": b.GetNavPages(),
})
}

// Archives shows the posts by year, month, etc.
func (b *Blog) Archives(c *gin.Context) {
yearKeys, byYear := b.getArchivesByYear()
monthKeys, byYearMonth := b.getArchivesByYearMonth()
b.Render(c, http.StatusOK, "archives.html", gin.H{
"logged_in": b.auth.IsLoggedIn(c),
"is_admin": b.auth.IsAdmin(c),
"version": b.Version,
"title": "Blog Archives",
"yearKeys": yearKeys,
"byYear": byYear,
"yearMonthKeys": monthKeys,
"byYearMonth": byYearMonth,
"recent": b.GetLatest(),
"admin_page": false,
"settings": b.GetSettings(),
"nav_pages": b.GetNavPages(),
})
}

// SiteURL is the site's public origin without a trailing slash: the
// site_url setting, or — when it is unset — the requesting scheme and
// host, honouring X-Forwarded-Proto from a reverse proxy.
Expand Down
2 changes: 1 addition & 1 deletion plugins/docs/content/writing-a-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Beyond those, each template gets its own data. This is the contract of the runni
| `admin*.html` | `/admin/…` | per page: `posts`, `post_types`, `pages`, `comments`, `users`, `themes`, `setting_groups`, `plugin`, … — read `admin/admin.go` and `admin/plugins.go` before overriding one |
| `wizard_*.html` | the install wizard, before there is a database | only `version` and `title` (and `errors`) — none of the common keys exist yet |

Six templates in default — `about.html`, `archives.html`, `posts.html`, `presentations.html`, `projects.html`, `tags.html` — are left over from before pages were configurable; no route renders them today, so there is nothing to override. Post, page, tag and setting objects are goblog's own types: `.post.Title`, `.post.Permalink`, `.post.Tags`, `.post.CreatedAt.Format "Jan 02, 2006"`, `.page.HasHero`, `.page.HeroURL`. Default's templates show what each has; the Go types are in `blog/`.
Post, page, tag and setting objects are goblog's own types: `.post.Title`, `.post.Permalink`, `.post.Tags`, `.post.CreatedAt.Format "Jan 02, 2006"`, `.page.HasHero`, `.page.HeroURL`. Default's templates show what each has; the Go types are in `blog/`.

Post, page and comment bodies are rendered to HTML by goblog: use
`{{ .post.HTML }}`, `{{ .page.HTML }}` and, for each comment, `{{ .HTML }}`.
Expand Down
52 changes: 0 additions & 52 deletions themes/default/templates/about.html

This file was deleted.

38 changes: 36 additions & 2 deletions themes/default/templates/admin_edit_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ <h1>Edit Page: {{ .page.Title }}</h1>
</div>

<div class="mb-3">
<label for="hero_url" class="form-label">Hero URL</label>
<input type="text" class="form-control" id="hero_url" value="{{ .page.HeroURL }}" placeholder="/img/hero.jpg or /vid/hero.mp4">
<label for="hero_url" class="form-label">Hero image or video</label>
<input type="text" class="form-control" id="hero_url" value="{{ .page.HeroURL }}" placeholder="/uploads/hero.jpg or /uploads/hero.mp4">
<label for="hero_file" class="form-label mt-2 mb-1"><small>Or upload an image or a video; that fills in the URL and the type.</small></label>
<input type="file" class="form-control form-control-sm" id="hero_file" accept="image/*,video/*" aria-describedby="hero_upload_status">
<small id="hero_upload_status" class="text-muted" role="status" aria-live="polite"></small>
</div>

<div class="mb-3">
Expand Down Expand Up @@ -105,6 +108,37 @@ <h1>Edit Page: {{ .page.Title }}</h1>
</div>

<script>
// Hero upload: send the file to /api/v1/upload (the same endpoint the
// settings page and the post editor use), then fill in the URL and pick the
// type from the file, so nobody has to know the path or the right option.
document.getElementById('hero_file').addEventListener('change', function () {
var file = this.files[0];
if (!file) { return; }
var status = document.getElementById('hero_upload_status');
status.className = 'text-muted';
status.textContent = 'Uploading ' + file.name + '…';
var form = new FormData();
form.append('file', file);
fetch('/api/v1/upload', {method: 'POST', body: form})
.then(function (resp) {
return resp.json().then(function (body) {
if (!resp.ok) { throw new Error(typeof body === 'string' ? body : resp.status); }
return body;
});
})
.then(function (body) {
document.getElementById('hero_url').value = body.filename;
document.getElementById('hero_type').value = file.type.indexOf('video/') === 0 ? 'video' : 'image';
status.className = 'text-success';
status.textContent = 'Uploaded ' + file.name + '. Save the page to use it.';
})
.catch(function (err) {
status.className = 'text-danger';
status.textContent = 'Upload failed: ' + err.message;
});
this.value = '';
});

// setupEditorTabs comes from the deferred admin-script.js, so the wiring waits
// for DOMContentLoaded. savePage() below stays a global for its onclick.
document.addEventListener("DOMContentLoaded", function () {
Expand Down
28 changes: 0 additions & 28 deletions themes/default/templates/archives.html

This file was deleted.

33 changes: 0 additions & 33 deletions themes/default/templates/posts.html

This file was deleted.

19 changes: 0 additions & 19 deletions themes/default/templates/presentations.html

This file was deleted.

22 changes: 0 additions & 22 deletions themes/default/templates/projects.html

This file was deleted.

24 changes: 0 additions & 24 deletions themes/default/templates/tags.html

This file was deleted.

4 changes: 0 additions & 4 deletions tools/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,6 @@ Edit it under **Admin → Pages**.
{
Title: "Writing",
Slug: "posts",
HeroURL: "/vid/redtree.mp4",
HeroType: "video",
PageType: blog.PageTypeWriting,
ShowInNav: true,
NavOrder: 1,
Expand All @@ -620,8 +618,6 @@ Edit it under **Admin → Pages**.
Title: "About",
Slug: "about",
Content: aboutContent,
HeroURL: "/img/hero_rigolet.jpg",
HeroType: "image",
PageType: blog.PageTypeAbout,
ShowInNav: true,
NavOrder: 3,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed www/img/aidecentralized.jpg
Binary file not shown.
Binary file removed www/img/code.jpg
Binary file not shown.
Binary file removed www/img/hero_rigolet.jpg
Binary file not shown.
Binary file removed www/img/jason.jpg
Binary file not shown.
Binary file modified www/img/profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed www/vid/mesh.mp4
Binary file not shown.
Binary file removed www/vid/redtree.mp4
Binary file not shown.
Loading