Skip to content

Commit feb3db1

Browse files
fnetXCodeberg Admins @ build
authored andcommitted
CB/feat+tmpl: Codeberg banners (static + targetted)
hardcoding limits for now, to be made configurable CB/feat: Targeted banners w/ repo topics (go-gitea#27) flag repos using the repo topics, adding - `cbf-nolicense` for repos without any license indication, or - `cbf-nofloss` for repos with a non-free or custom license will result in warnings to the repo admins and the end users. CB: Improve no license banner with feedback from the community - shorter and precise text - add that it might take a while for the banner to disappear (many people tried x-many different names, wondering if any would trigger a removal) - make text left-aligned (dirty for now) CB: Announce private pages will stop working
1 parent 5ea28ae commit feb3db1

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

models/repo/codeberg.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2021 Codeberg e.V.. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
// This file contains codeberg-specific additions to Gitea
6+
// that can live outside of the upstream source code.
7+
8+
package repo
9+
10+
import (
11+
"strings"
12+
)
13+
14+
// check if a repo topic is used as a Codeberg flag
15+
func (t *Topic) IsCodebergFlag() bool {
16+
return strings.HasPrefix(t.Name, "cbf-")
17+
}

templates/repo/codeberg_banners.tmpl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!-- Pages Warning that content is accessible even on private repos -->
2+
{{if and (eq .Repository.LowerName "pages") (.Repository.IsPrivate)}}
3+
<div class="ui warning message">
4+
If you expected this content to be served via <a href="https://docs.codeberg.org/codeberg-pages/">Codeberg Pages</a>, please note that we stopped serving private repositories in December 2021. Please switch the visibility to public if you want to publish this content again.
5+
</div>
6+
{{end}}
7+
8+
<!-- Warning if private repo exceeds a certain size (hardcoded to 100MB + 250MB different warning-->
9+
{{if and (.Repository.IsPrivate) (ge .Repository.Size 100000000)}}
10+
<div class="ui error message">
11+
Your private repo uses up a{{if ge .Repository.Size 250000000}}n insanely{{end}} large amount of disk storage, while
12+
all content should ideally be public and licensed under an
13+
<a href="https://opensource.org/licenses/" rel="noopener noreferrer" target="_blank">OSI</a>- or
14+
<a href="https://www.gnu.org/licenses/license-list.html" rel="noopener noreferrer" target="_blank">FSF</a>-approved Free Software licence.<br/>
15+
<strong>Please refer to our ToS and the FAQ about
16+
<a href="https://docs.codeberg.org/getting-started/faq/#is-it-allowed-to-host-non-free-software%3F">software licenses</a>
17+
and <a href="https://docs.codeberg.org/getting-started/faq/#can-i-host-private-repositories%3F">private repositories</a></strong><br/>
18+
Thank you for considering to release this repo to the public or reducing your required disk space for this repo.
19+
</div>
20+
{{end}}
21+
22+
<!-- go through the Codeberg-specific flags (repo topics) to display some targeted banners -->
23+
{{range .Topics}}
24+
25+
<!-- warning if repo is flagged as missing a license -->
26+
{{if or (eq .Name "cbf-nolicense") (eq .Name "cbf-abuse-nolicense")}}
27+
<div class="ui error message" style="text-align: left;">
28+
<strong>Warning:</strong> Missing License<br/>
29+
We looked everywhere, but we couldn't find an
30+
<a href="https://opensource.org/licenses/" rel="noopener noreferrer" target="_blank">OSI</a>- or
31+
<a href="https://www.gnu.org/licenses/license-list.html" rel="noopener noreferrer" target="_blank">FSF</a>-approved
32+
Free Software or Content License, which is a requirement for hosting content on Codeberg.<br/>
33+
Learn about why no license or custom ones are a bad idea and get started
34+
<a href="https://docs.codeberg.org/getting-started/licensing/">on the docs</a>.<br/>
35+
{{if $.Permission.IsAdmin}}
36+
Please add a license to your code to make your work usable to others.
37+
Expect some delay until this banner disappears.
38+
{{else}}
39+
Please consider carefully if you want to use (parts of) this project, as doing so might put you in legal trouble.
40+
{{end}}
41+
</div>
42+
{{end}}
43+
44+
{{end}}
45+

templates/repo/home.tmpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
{{end}}
3030
</div>
3131
<div class="mt-3" id="repo-topics">
32-
{{range .Topics}}<a class="ui repo-topic large label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}}
32+
{{range .Topics}}
33+
{{if not .IsCodebergFlag}}
34+
<a class="ui repo-topic large label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>
35+
{{end}}
36+
{{end}}
3337
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}<a id="manage_topic" class="muted">{{.locale.Tr "repo.topic.manage_topics"}}</a>{{end}}
3438
</div>
3539
{{end}}
@@ -56,6 +60,9 @@
5660
<span id="count_prompt">{{.locale.Tr "repo.topic.count_prompt"}}</span>
5761
<span id="format_prompt">{{.locale.Tr "repo.topic.format_prompt"}}</span>
5862
</div>
63+
64+
{{template "repo/codeberg_banners" .}}
65+
5966
{{if .Repository.IsArchived}}
6067
<div class="ui warning message">
6168
{{.locale.Tr "repo.archive.title"}}

0 commit comments

Comments
 (0)