mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
Languages Statusbar #890
Closed
opened 2025-11-02 03:40:27 -06:00 by GiteaMirror
·
26 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16.0
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.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/feature
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#890
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
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?
Originally created by @TimerWolf on GitHub (Jul 14, 2017).
Are there any plans for gitea to get a status-bar that shows how much of different code its used in the git?
And when you click on it you see the different languages that are used and how many % of the code that is used of that language in the git?
Its a really neat feature that i really miss!
@tonivj5 commented on GitHub (Jul 19, 2017):
Here is the PR to gogs (it was not merged) implemeting that feature https://github.com/gogits/gogs/pull/2135. It could be reused to add it in gitea 😉
@lunny commented on GitHub (Jul 20, 2017):
@xxxtonixxx maybe someone could send it to Gitea.
@tonivj5 commented on GitHub (Jul 21, 2017):
If @generaltso want, he could do it! If not, I think I could attempt it 😅
@dayvonjersen commented on GitHub (Jul 21, 2017):
https://github.com/gogits/gogs/pull/2135 is certainly out of date by now as the gogs codebase has probably changed and the API for linguist has definitely changed.
Of course anyone is more than welcome to use my library but implementing this feature isn't going to be a copy/paste job.
That said, I copied and pasted the CSS I whipped up for those screenshots into a codepen: https://codepen.io/anon/pen/PjMdBy
-tso
@lafriks commented on GitHub (Jul 21, 2017):
And I don't think it can be accepted in that form, stats should be generated and cached only once when repository default branch changes, not on every page load
@dayvonjersen commented on GitHub (Jul 21, 2017):
@lafriks yes, exactly. probably best to have like a post-receive hook that runs in the background and stores the result in the db.
and have a setting to disable it entirely for those concerned about server resource usage
it would also be cool if the classifier could then be retrained on real-world code samples but I'm probably jumping the gun here >_>
-tso
@OmarAssadi commented on GitHub (Oct 11, 2017):
I put up a small ($5) bounty on this one. Miss this feature!
EDIT: Here is the current pledge amount. If anyone else feels like contributing, feel free!

@dayvonjersen commented on GitHub (Oct 19, 2017):
Hm, now my interest is piqued ;)
I could take another stab at it maybe tomorrow evening (I'm in EST). But be forewarned, my preliminary attempt will probably be an awful hack job. I will need to rely on the rest of the community's advice to do it right.
-tso
@OmarAssadi commented on GitHub (Oct 19, 2017):
Sounds great! In addition to caching, the final version should probably also be limited by file size. Maybe an adjustable setting?
@dayvonjersen commented on GitHub (Oct 19, 2017):
@54 Hm so you mean don't try to classify individual files that are larger than, e.g. 1MB? Most of the time what linguist does is it goes by file extension but hm, yes I see what you mean just thinking aloud... Good idea :)
@OmarAssadi commented on GitHub (Oct 19, 2017):
@generaltso Yeah, I just figure it'd kinda suck if someone uploaded some monstrous set of files that the server had to analyze. But, I haven't looked at your linguist library. Does it ever actually do some content analysis or is it pretty much entirely based on extension?
If it is purely based on the extension, then I don't think it's necessary to add that particular limitation.
@dayvonjersen commented on GitHub (Oct 19, 2017):
well it can do either.
in the reference implementation, after being filtered by linguist.ShouldIgnoreFilename() the file extension is passed to linguist.LanguageHints().
if there is more than one possible language for an extension (e.g.
.phpcould be either PHP or Facebook's "Hack" language) then it first checks if the file is a binary blob with linguist.ShouldIgnoreContents() and then uses a bayesian classifier which has been trained on the same dataset as github/linguist to analyse the text (using a tokenizer which could use some improvement) and determine the language (the function is called linguist.Analyse())a pretty straightforward process imo but I'm a tiny bit biased since I wrote it :p
it might be more convenient to encapsulate all the nuance into a single package-level function instead of requiring all of those steps for the typical use-case, I welcome any input in improving the library for users as well if you or anyone else have any suggestions :)
-tso
@OmarAssadi commented on GitHub (Oct 19, 2017):
Ah, thanks for the clarification! By the way, #2108 appears to include its own submenu—minus the linguist functionality, though.
Might be worth waiting for that to get merged?
@dayvonjersen commented on GitHub (Oct 19, 2017):
@54 that would seem to make the most sense in the grand scheme of things, but I'm just gonna get to hacking away at something on a separate branch based off master since I just reinstalled MySQL and setup gitea and I'm ready to go, just to get the ball moving
I'll update here with screenshots and code and stuff in a couple hours makes coffee ☕ 😁
@OmarAssadi commented on GitHub (Oct 19, 2017):
Yeah, of course. I just meant since there is some overlap, probably best not to make something super polished just yet 😁
Good luck, @generaltso!
@dayvonjersen commented on GitHub (Oct 19, 2017):
OK I got my feet wet in the code base and basically just implemented the design I had previously come up with some dummy placeholder results for now.
I have lots of questions but I think I made some decent progress for 1.5 hours of work
you can view my commits:
41cabf2d85https://github.com/generaltso/gitea/commits/feature/language-statistics
these should be probably squashed with a rebase if/when it's ready for a PR
NOTE: I had to
cp -r my-local-fork-of-gitea-sdk gitea/vendor/manually. I don't fully understand how to use vendoring with go build in this project atmFirst thing I did was add a table to the DB (even though I'm not using it just yet)
00427a9095/language_statistics.sqlALTERNATIVE TO THIS would be a single
rowfield in therepositorytable with JSON data containing all the language stats.Here's the Commits/Branches/Releases/Contributors bar

to complete this I need to know how to
here's the language bar

It's already using
linguist.LanguageColor()to use the "proper" github colors...to complete this I need:
models/repo.goormodels/language_statistics.gomy biggest questions I need guidance with now are:
post-receive? (so that language statistics can be populated and kept up-to-date in the background)ADDITIONALLY and this is me getting way ahead of myself here but for the future:
again my commits are viewable here:
41cabf2d85https://github.com/generaltso/gitea/commits/feature/language-statistics
I appreciate any further guidance but I think I'm going to make dinner now and relax a bit.
<3
-tso
EDIT: also note there is a transition for the commits/etc bar -> language %'s. It looks like this codepen of a 3D cube flip effect because I took it directly from that and changed the timing function (see also
fdcd6b8b9e/templates/repo/home.tmpl (L77))@lunny commented on GitHub (Oct 20, 2017):
@genedna all db related operation on
modelssub module.@genedna commented on GitHub (Oct 20, 2017):
@lunny @genedna -> @generaltso ?
@lunny commented on GitHub (Oct 20, 2017):
@genedna sorry for wrong mention. :) @generaltso
@dayvonjersen commented on GitHub (Oct 20, 2017):
@lunny thanks I'll have to read over the code in
modelsmore in-depth then; will probably work on it some more later today :)any other comments/feedback on what I did so far? or does it look ok
@kolaente commented on GitHub (Apr 29, 2018):
@generaltso liking it so far! Any progress update?
@OmarAssadi commented on GitHub (May 10, 2018):
Bumped the bounty to $20. If anyone else would like to see this, feel free to contribute to the bounty.
@alexanderadam commented on GitHub (May 11, 2018):
I just want to add that I would love to see the repository size in it (like this extension does it for GitHub).
And this is probably also easier than language recognition.
EDIT: created a new issue for it as wished
@OmarAssadi commented on GitHub (May 11, 2018):
@alexanderadam Good idea as well! As far as the language recognition goes, there is already a linguist port to Go.
@kolaente commented on GitHub (May 11, 2018):
@alexanderadam mind opening a seperate issue for that?
@OmarAssadi commented on GitHub (Nov 18, 2018):
Looks like @lafriks started work on this a little while back 👍 Figured it'd be worth linking the PR and issue - #4824.