-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Package registry: add description from UI #20628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e7c2d82
adb7da0
86d371e
413a27d
3dceba9
28f3f4e
39a9549
7d309b6
0e96572
329aa26
bb23e8d
ae6f2f5
3cb0f99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2022 The Gitea Authors. All rights reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you move this migration into a versioned directory? |
||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"xorm.io/xorm" | ||
) | ||
|
||
func addDescriptionAndReadmeColsForPackage(x *xorm.Engine) error { | ||
type Package struct { | ||
Description string `xorm:"TEXT"` | ||
Readme string `xorm:"LONGBLOB"` | ||
} | ||
|
||
return x.Sync(new(Package)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,8 @@ type Package struct { | |
Name string `xorm:"NOT NULL"` | ||
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"` | ||
SemverCompatible bool `xorm:"NOT NULL DEFAULT false"` | ||
Description string `xorm:"VARCHAR(255)"` | ||
Readme string `xorm:"LONGBLOB"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe TEXT is more suitable for this column, as xorm should translate it into the appropriate type for each database There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
// TryInsertPackage inserts a package. If a package exists already, ErrDuplicatePackage is returned | ||
|
@@ -167,6 +169,15 @@ func SetRepositoryLink(ctx context.Context, packageID, repoID int64) error { | |
return err | ||
} | ||
|
||
// SetDescriptions sets descriptions | ||
func SetDescriptions(ctx context.Context, packageID int64, description, readme string) error { | ||
_, err := db.GetEngine(ctx).ID(packageID).Update(&Package{ | ||
Description: description, | ||
Readme: readme, | ||
}) | ||
return err | ||
} | ||
|
||
// UnlinkRepositoryFromAllPackages unlinks every package from the repository | ||
func UnlinkRepositoryFromAllPackages(ctx context.Context, repoID int64) error { | ||
_, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Cols("repo_id").Update(&Package{}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2824,7 +2824,13 @@ error.unit_not_allowed=Vous n'êtes pas autorisé à accéder à cette section d | |
|
||
[packages] | ||
empty.repo=Avez-vous téléchargé un paquet, mais il n'est pas affiché ici? Allez dans les <a href="%[1]s">paramètres du paquet</a> et liez le à ce dépôt. | ||
settings.descriptions.success = Les descriptifs ont été mises à jour | ||
settings.descriptions.error = Échec de la mise à jour des descriptifs | ||
settings.descriptions = Descriptifs | ||
settings.description.description = Description | ||
settings.readme.description = Readme | ||
settings.descriptions.button = Mettre à jour les descriptifs | ||
readme = Readme | ||
Comment on lines
+2827
to
+2833
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be overridden by the CI again |
||
published_by_in=%[1]s publié par <a href="%[2]s">%[3]s</a> en <a href="%[4]s"><strong>%[5]s</strong></a> | ||
rubygems.required.ruby=Nécessite la version de Ruby | ||
rubygems.required.rubygems=Nécessite la version de RubyGem | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
</div> | ||
</div> | ||
|
||
{{template "package/content/readme" .}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few more registries have been merged in the mean time. |
||
|
||
{{if .PackageDescriptor.Metadata.Description}} | ||
<h4 class="ui top attached header">{{.locale.Tr "packages.about"}}</h4> | ||
<div class="ui attached segment"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,6 @@ | |
</div> | ||
</div> | ||
</div> | ||
|
||
{{template "package/content/readme" .}} | ||
{{end}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{if .PackageDescriptor.Package.Readme}} | ||
<h4 class="ui top attached header">{{.locale.Tr "packages.readme"}}</h4> | ||
<div class="ui attached segment"> | ||
{{RenderMarkdownToHtml .PackageDescriptor.Package.Readme}} | ||
</div> | ||
{{end}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="ui top tabular menu" data-write="write" data-preview="preview"> | ||
<a class="active item" data-tab="write">{{.locale.Tr "write"}}</a> | ||
<a class="item" data-tab="preview" data-url="{{.PackageDescriptor.PackageWebLink}}/markdown" data-context="{{.PackageDescriptor.Owner.Name}}/{{.PackageDescriptor.Package.Name}}">{{.locale.Tr "preview"}}</a> | ||
</div> | ||
<div class="field"> | ||
<div class="ui bottom active tab" data-tab="write"> | ||
<textarea id="content" class="edit_area js-quick-submit" name="readme" tabindex="4" data-id="-{{.PackageDescriptor.Package.ID}}" data-url="{{.PackageDescriptor.PackageWebLink}}/markdown" data-context="{{.PackageDescriptor.Owner.Name}}/{{.PackageDescriptor.Package.Name}}"> | ||
{{- .PackageDescriptor.Package.Readme -}} | ||
</textarea> | ||
</div> | ||
<div class="ui bottom tab markup" data-tab="preview"> | ||
{{.locale.Tr "loading"}} | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import $ from 'jquery'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Linting rules should prevent the addition of new jQuery code, could you utilize vanilla JS instead? Cc: @silverwind who has more insight into linting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no linting for it, I don't think it's possible for the linter to distinguish old and new code. But yes, new code should prefer not to use jQuery, we want to eventually remove it. |
||
|
||
const {csrfToken} = window.config; | ||
|
||
function initEditPreviewTab($form) { | ||
const $tabMenu = $form.find('.tabular.menu'); | ||
$tabMenu.find('.item').tab(); | ||
$tabMenu.find(`.item[data-tab="${$tabMenu.data('preview')}"]`).on('click', function () { | ||
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This selector looks really fragile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's just the old code, after the "editor" refactoring, no such code is needed. Actually, this PR has been stale for too long time, I guess the author might have lost interest on it? If it is still stale and inactive, it needs the maintainers who have writer permission to help. |
||
const $this = $(this); | ||
const context = `/${$this.data('context')}`; | ||
const mode = $this.data('markdown-mode') || 'comment'; | ||
|
||
$.post($this.data('url'), { | ||
_csrf: csrfToken, | ||
mode, | ||
context, | ||
text: $form.find(`.tab[data-tab="${$tabMenu.data('write')}"] textarea`).val(), | ||
}, (data) => { | ||
const $diffPreviewPanel = $form.find(`.tab[data-tab="${$tabMenu.data('preview')}"]`); | ||
$diffPreviewPanel.html(data); | ||
}); | ||
}); | ||
} | ||
|
||
export function initPackageEditor() { | ||
if ($('.package.settings .descriptions').length === 0) { | ||
return; | ||
} | ||
|
||
initEditPreviewTab($('.package.settings .descriptions')); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is absolutely outdated by now as @techknowlogick mentioned in https://github.com/go-gitea/gitea/pull/20628/files#r1194390383