Improve CBF topics #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "improve-cbf-topics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cbf-will now receive special care within the code. It can only be removed and viewed by Instance admins. Repository owners are no longer able to remove these topics or even see that this topic was added to their repository(just the warning banner).cbf-prefixed topics we need to give some special care when users do update their topics, this PR adds theAddMissingRepositoryTopicsfunction which will make sure that all currentcbf-prefixed topics will be added to the updated topics list.HasMissingLicenseTopicfunction as the Topics slice no longer contains thecbf-prefixed topics.cbf-text, this to avoid accidental leakage of repository that hascbf-topics.as normal repoAdmin (not instance admin) you can add
cbf-...topics but not remove or see them ... (via webUI)@ -18,0 +39,4 @@// HasMissingLicenseTopic returns if repository has a "cbf-nolicense" or "cbf-abuse-nolicense" topic.func (r *Repository) HasMissingLicenseTopic() bool {for _, topic := range r.Topics {if topic == "cbf-nolicense" || topic == "cbf-abuse-nolicense" {can we create a const block where we put these strings to?
Why? The function is specific to that flag, I don't see a need to define this somewhere. For other labels, you obviously define new functions anyway.
I just somehow think that these functions are obviously less performant than scanning in the template, aren't they? I mean, previously I looped through the topics twice, once to print them and once to display banners.
Now we iterate through them for each check. e.g. in the future, if the templates do check
HasMissingLicenseTopic(), HasStorageAbuseTopic(), HasStorageExceptionTopic, HasEventXyParticipationTopic(), HasBonusFeatureAbcTopic() ... we iterate through the topics many times, right?
it improves codestile ...
I'm fine with making
cbf-a const. But the specific licenses is either a global slice or just hardcoded within the function.Yeah, if users want to break their repository. They should free to do so! (Forget to check for this endpoint).
from @fnetX
I would say it depends how mouch overhead the template engine does add to in-template-functions.
Templates have huge overhead when doing computations(especially for-loops). It's not a general purposed dynamic scripting language. It's to construct a HTML page.
If you would like to run your benchmarks: https://codeberg.org/Gusted/benchmark-loops-go-template
we can run a lot of loops before we have to worry about golang overhead 😆
@ -44,2 +39,3 @@{{end}}</div>{{end}}why rm last \n ?
Not sure WTF Gitea is doing here(try to click on expanding the code below this hunk). But there is another new line there(this just removes the other new line). So 2 empty last new lines -> 1 empty last new line.
beside file format nit
@Gusted
58a0298bc0Please check if the rendered HTML still looks fine. I just copied pasted it.
Weird, it current isn't horizontal centered:

Ref: https://codeberg.org/nogerine/solar
Yeah, horizontal centering is hard to read with multiline text, so I made it align left. But maybe I forgot to add that to some of the banners.
I think we can ad the fix in here
I'm not sure which banners are incorrect. So @6543 feel free to mess with my PR to add a fix.
My proposal for next steps with this (I'm fine to merge as-is in case of missing agreement)
cbf-prefix is renamed to something not codeberg-specific, so this patch can be used by other instances and the Codeberg Moderation/Admin tool will be usable without disabling codeberg-specific features like that (because it can be used by every other instance then)What about
internal-orreserved-?Alright moving to
HasTopic(x)interface.we might merge it ... as we can itterate on it later
Y/N?
@Gusted since there is a limit in length and I prefer if the label names are descriptive, we should choose a short prefix IMHO. It could be "iflag" (internal flag) or we could use some disallowed name if this is not a problem (starting with - for example).
Otherwise, what about 0-- or something like this? (0--abuse ...)
iflag is fine with me.
The disadvantage of choosing a term is that the "iflag" project that comes up in two years faces unexpected behaviour if they want to label a repo with iflag-official, iflag-meta and iflag-contribution-welcome ^^
(Feel free to go ahead, anyway, this idea just came to my mind)
should I rebase it to v18 ?!?
Once Gusted has some free cycles, this is probably best forwarded to Forgejo and fixed for the iflag- prefix.
Pull request closed