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
8 changes: 8 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7167,6 +7167,7 @@ code {
--site-width-wide: 68rem;
--avatar-size-small: 1.5rem;
--avatar-size-normal: 2.5rem;
--link-decoration: none;
}

/* src/rawdata/css/vars-light.css */
Expand Down Expand Up @@ -7261,9 +7262,16 @@ a.external::after,
content: " 1";
vertical-align: middle;
}
a:hover,
.link:hover {
text-decoration: var(--link-decoration);
}
.link-normal {
--link-color: var(--color);
}
.link-underline {
--link-decoration: underline;
}
b,
strong {
font-weight: 600;
Expand Down
8 changes: 8 additions & 0 deletions src/rawdata/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ a,
content: " 1";
vertical-align: middle;
}

&:hover {
text-decoration: var(--link-decoration);
}
}

.link-normal {
--link-color: var(--color);
}

.link-underline {
--link-decoration: underline;
}

b,
strong {
font-weight: 600;
Expand Down
2 changes: 2 additions & 0 deletions src/rawdata/css/vars-common.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@

--avatar-size-small: 1.5rem;
--avatar-size-normal: 2.5rem;

--link-decoration: none;
}
5 changes: 5 additions & 0 deletions src/templates/img/add-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/templates/img/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 27 additions & 29 deletions src/templates/src/blog_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,39 @@
</div>
{{ end }}
{{ end }}
<div class="flex justify-center pa3">
<div class="w-100 mw-site-wide flex flex-column g3">
<div class="flex flex-column g2">
<div class="flex">
{{ if .CanCreatePost }}
<a class="" href="{{ .NewPostUrl }}">{{ svg "add" }}<span>Create Post</span></a>
{{ end }}
<div class="flex-grow-1"></div>
<div class="">
{{ template "pagination.html" .Pagination }}
{{ if and (not .FirstPost) (not .Posts) }}
<div class="f6 pv5 tc">There are no blog posts for this project yet.</div>
{{ else if .Posts }}
<div class="flex justify-center pa3">
<div class="w-100 mw-site-wide flex flex-column g3">
{{ if gt .Pagination.Total 1 }}
<div class="flex flex-column g2">
<div class="flex">
<div class="flex-grow-1"></div>
<div class="">
{{ template "pagination.html" .Pagination }}
</div>
</div>
<hr>
</div>
</div>
<hr>
</div>
{{ if .Posts }}
<div class="grid grid-3 g3">
{{ end }}
<div class="grid grid-1 grid-3-ns g3">
{{ range .Posts }}
{{ template "blog_list_item.html" . }}
{{ end }}
</div>
{{ else if not .FirstPost}}
<div class="f5">There are no blog posts for this project yet.</div>
{{ end }}
<div class="flex flex-column g2">
<hr>
<div class="flex">
{{ if .CanCreatePost }}
<a class="" href="{{ .NewPostUrl }}">{{ svg "add" }}<span>Create Post</span></a>
{{ end }}
<div class="flex-grow-1"></div>
<div class="">
{{ template "pagination.html" .Pagination }}
{{ if gt .Pagination.Total 1 }}
<div class="flex flex-column g2">
<hr>
<div class="flex">
<div class="flex-grow-1"></div>
<div class="">
{{ template "pagination.html" .Pagination }}
</div>
</div>
</div>
</div>
{{ end }}
</div>
</div>
</div>
{{ end }}
{{ end }}
5 changes: 1 addition & 4 deletions src/templates/src/blog_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ <h1 class="tc-ns f3 f2-ns lh-title">{{ .Thread.Title }}</h1>
<span class="f6 f5-ns">
<a class="b link-normal" href="{{ .Author.ProfileUrl }}">{{ .Author.Name }}</a>
— {{ timehtml (absoluteshortdate .PostDate) .PostDate }}
{{ if and $.User (or (eq .Author.ID $.User.ID) $.User.IsStaff) }}
(<a href="{{ .EditUrl }}" title="Edit">Edit</a>, <a href="{{ .DeleteUrl }}" title="Delete">Delete</a>)
{{ end }}
</span>
</div>
{{ end }}
Expand All @@ -39,7 +36,7 @@ <h1 class="tc-ns f3 f2-ns lh-title">{{ .Thread.Title }}</h1>
<div class="flex justify-between">
<h3 class="f4">Comments</h3>
{{ if .Project.HasBlog }}
<a class="flex items-center g2" href="{{ not (not $.User) | ternary .ReplyLink .LoginLink }}">{{ svg "add" }}<span>Leave a Comment</span></a>
<a class="flex items-center g2" href="{{ not (not $.User) | ternary .ReplyLink .LoginLink }}">{{ svg "add" }}<span>Comment</span></a>
{{ end }}
</div>
<div class="flex flex-column g2">
Expand Down
33 changes: 21 additions & 12 deletions src/templates/src/include/header-2024.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,27 @@
</div>
</header>

{{/* TODO: Re-enable breadcrumbs after fixing mobile */}}
{{ if and false .Header.Breadcrumbs (not .Header.SuppressBreadcrumbs) }}
<div class="bg1 bb pv2 pr3 link-normal flex items-center" style="padding-left: 0.72rem">
{{ range $i, $breadcrumb := .Header.Breadcrumbs }}
{{ if gt $i 0 }}<span class="ph2">/</span>{{ end }}
<div class="flex g2 items-center">
{{ if $breadcrumb.Project }}
<div class="avatar-small">{{ template "project_logo.html" $breadcrumb.Project }}</div>
{{ end }}
<a href="{{ $breadcrumb.Url }}">{{ $breadcrumb.Name }}</a>
</div>
{{ end }}
{{ if and (or .Header.Breadcrumbs .Header.Actions) (not .Header.SuppressBreadcrumbs) }}
<div class="f6 bg1 bb pr3 link-normal link-underline flex items-center justify-between" style="padding-left: 0.72rem">
<div class="flex items-center">
{{ range $i, $breadcrumb := .Header.Breadcrumbs }}
{{ if gt $i 0 }}<span class="ph2">/</span>{{ end }}
<div class="flex g2 items-center">
{{ if $breadcrumb.Project }}
<div class="avatar-small">{{ template "project_logo.html" $breadcrumb.Project }}</div>
{{ end }}
<a class="pv2 lh-copy truncate" href="{{ $breadcrumb.Url }}">{{ $breadcrumb.Name }}</a>
</div>
{{ end }}
</div>
<div class="flex items-center g3">
{{ range .Header.Actions }}
<a class="flex items-center pv2 lh-copy" href="{{ .Url }}">
<span class="f5 svgicon svgicon-nofix mr1 flex items-center">{{ svg .Icon }}</span>
{{ .Name }}
</a>
{{ end }}
</div>
</div>
{{ else if and .Header.BannerEvent (not .Header.SuppressBanners) }}
{{ with .Header.BannerEvent }}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/src/include/link_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<input data-tmpl="nameInput" size="1" class="link_name flex-grow-1" type="text" placeholder="Name" oninput="linkInput(event)" />
<input data-tmpl="urlInput" size="1" class="link_url flex-grow-1" type="url" placeholder="Link" oninput="linkInput(event)" />
</div>
<a class="delete_link svgicon link-normal pl2 pl3-ns f3" href="javascript:;" onclick="deleteLink(event)">{{ svg "delete" }}</a>
<a class="delete_link svgicon link-normal pl2 pl3-ns f4" href="javascript:;" onclick="deleteLink(event)">{{ svg "delete" }}</a>
</div>
</template>
<template id="link_row_dummy">
Expand Down
9 changes: 1 addition & 8 deletions src/templates/src/project_homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
--angle: {{ .Project.Flowsnake.Angle }}deg;
"></div>
<div class="flex flex-column flex-row-ns pa2 pa3-ns relative">
<div class="flex g3">
{{ if .CanEdit }}
<div class="project-links">
<a class="ph3 pv2 flex items-center" href="{{ .EditUrl }}"><span class="mr2 flex items-center">{{ svg "edit-line" }}</span>Edit Project</a>
</div>
{{ end }}
</div>
<div class="project-links-spacer"></div>
<div class="flex flex-column flex-row-ns items-end g2 g3-ns">
{{ with .PrimaryLinks }}
Expand Down Expand Up @@ -112,7 +105,7 @@
</div>
</div>
{{ if .Project.ParsedDescription }}
<div id="longdesc" class="description w-100 ph3 ph0-ns mw-site-narrow pt4">
<div id="longdesc" class="description w-100 ph3 ph0-ns pt4">
<h3 class="f4">About {{ .Project.Name }}</h3>
<hr class="mv3">
<div class="longdesc-content post-content maxh-5 overflow-hidden">
Expand Down
6 changes: 6 additions & 0 deletions src/templates/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type Header struct {
Project *ProjectHeader

Breadcrumbs []Breadcrumb
Actions []Action
SuppressBreadcrumbs bool

BannerEvent *BannerEvent
Expand Down Expand Up @@ -451,6 +452,11 @@ type Breadcrumb struct {
Project *Project
}

type Action struct {
Name, Url string
Icon string
}

type Pagination struct {
Current int
Total int
Expand Down
1 change: 1 addition & 0 deletions src/website/base_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func getBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadc
loginUrl = hmnurl.BuildLoginPage(c.FullUrl(), "")
}

// Prepend the project breadcrumb
if !c.UrlContext.IsHMN() {
projectUrl := c.UrlContext.BuildHomepage()
rootBreadcrumb := templates.Breadcrumb{
Expand Down
30 changes: 24 additions & 6 deletions src/website/blogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ func BlogIndex(c *RequestContext) ResponseData {
FirstPost *templates.BlogIndexEntry
Posts []templates.BlogIndexEntry
Pagination templates.Pagination

CanCreatePost bool
NewPostUrl string
}

const postsPerPage = 21
Expand Down Expand Up @@ -93,6 +90,13 @@ func BlogIndex(c *RequestContext) ResponseData {

canCreate = c.CurrentUser.IsStaff || isProjectOwner
}
if canCreate {
baseData.Header.Actions = append(baseData.Header.Actions, templates.Action{
Name: "Create Post",
Url: c.UrlContext.BuildBlogNewThread(),
Icon: "add-small",
})
}

var res ResponseData
res.MustWriteTemplate("blog_index.html", blogIndexData{
Expand All @@ -108,9 +112,6 @@ func BlogIndex(c *RequestContext) ResponseData {
PreviousUrl: c.UrlContext.BuildBlog(utils.Clamp(1, page-1, numPages)),
NextUrl: c.UrlContext.BuildBlog(utils.Clamp(1, page+1, numPages)),
},

CanCreatePost: canCreate,
NewPostUrl: c.UrlContext.BuildBlogNewThread(),
}, c.Perf)
return res
}
Expand Down Expand Up @@ -179,6 +180,23 @@ func BlogThread(c *RequestContext) ResponseData {
Value: posts[0].Post.PreviewPlaintext,
})

mainPost := templatePosts[0]
canEdit := c.CurrentUser != nil && (mainPost.Author.ID == c.CurrentUser.ID || c.CurrentUser.IsStaff)
if canEdit {
baseData.Header.Actions = append(baseData.Header.Actions, []templates.Action{
{
Name: "Edit",
Url: mainPost.EditUrl,
Icon: "edit-line",
},
{
Name: "Delete",
Url: mainPost.DeleteUrl,
Icon: "delete",
},
}...)
}

var res ResponseData
res.MustWriteTemplate("blog_post.html", blogPostData{
BaseData: baseData,
Expand Down
3 changes: 0 additions & 3 deletions src/website/breadcrumb_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ func ForumBreadcrumb(projectUrlContext *hmnurl.UrlContext) templates.Breadcrumb

func SubforumBreadcrumbs(projectUrlContext *hmnurl.UrlContext, lineageBuilder *models.SubforumLineageBuilder, subforumID int) []templates.Breadcrumb {
var result []templates.Breadcrumb
// if projectUrlContext.ProjectID != models.HMNProjectID {
// result = append(result, ProjectBreadcrumb(projectUrlContext))
// }
result = append(result, ForumBreadcrumb(projectUrlContext))
subforums := lineageBuilder.GetSubforumLineage(subforumID)
slugs := lineageBuilder.GetSubforumLineageSlugs(subforumID)
Expand Down
17 changes: 15 additions & 2 deletions src/website/hsf.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package website

import (
"git.handmade.network/hmn/hmn/src/hmnurl"
"git.handmade.network/hmn/hmn/src/templates"
)

Expand All @@ -11,20 +12,32 @@ func HSFLanding(c *RequestContext) ResponseData {
}

func HSFDetails(c *RequestContext) ResponseData {
breadcrumbs := []templates.Breadcrumb{
hsfBaseBreadcrumb,
{Name: "Details", Url: hmnurl.BuildHSFDetails()},
}

var res ResponseData
res.MustWriteTemplate("hsf_details.html", getHSFBaseData(c, "Details", nil), c.Perf)
res.MustWriteTemplate("hsf_details.html", getHSFBaseData(c, "Details", breadcrumbs), c.Perf)
return res
}

func HSFMembership(c *RequestContext) ResponseData {
baseData := getHSFBaseData(c, "Membership", nil)
breadcrumbs := []templates.Breadcrumb{
hsfBaseBreadcrumb,
{Name: "Membership", Url: hmnurl.BuildHSFMembership()},
}

baseData := getHSFBaseData(c, "Membership", breadcrumbs)
baseData.HideMembershipCTA = true

var res ResponseData
res.MustWriteTemplate("hsf_membership.html", baseData, c.Perf)
return res
}

var hsfBaseBreadcrumb = templates.Breadcrumb{Name: "Handmade Software Foundation", Url: hmnurl.BuildHSFLanding()}

func getHSFBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadcrumb) templates.BaseData {
baseData := getBaseData(c, title, breadcrumbs)
baseData.SiteTitleOverride = "Handmade Software Foundation"
Expand Down
10 changes: 10 additions & 0 deletions src/website/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,16 @@ func ProjectHomepage(c *RequestContext) ResponseData {
if err != nil {
return c.ErrorResponse(http.StatusInternalServerError, oops.New(err, "failed to fetch following status"))
}

if c.CurrentUserCanEditCurrentProject {
templateData.Header.Actions = []templates.Action{
{
Name: "Edit Project",
Url: c.UrlContext.BuildProjectEdit(""),
Icon: "edit-line",
},
}
}
}
templateData.FollowUrl = followUrl
templateData.Following = following
Expand Down
Loading