allow linking to wikis, closes #549

This commit is contained in:
MiniDigger | Martin 2022-06-19 19:30:23 +02:00
parent 77d051647b
commit b5e2e663a0
13 changed files with 46 additions and 7 deletions

View File

@ -48,5 +48,8 @@ function childRoute(route = ""): string {
<ProjectNavItem v-if="props.project.settings.support" :href="linkout(props.project.settings.support)">
{{ i18n.t("project.tabs.support") }}
</ProjectNavItem>
<ProjectNavItem v-if="props.project.settings.wiki" :href="linkout(props.project.settings.wiki)">
{{ i18n.t("project.tabs.wiki") }}
</ProjectNavItem>
</nav>
</template>

View File

@ -182,7 +182,8 @@
"homepage": "Homepage",
"issues": "Issues",
"source": "Source",
"support": "Support"
"support": "Support",
"wiki": "Wiki"
},
"new": {
"step1": {
@ -213,6 +214,7 @@
"issues": "Issue Tracker",
"source": "Source Code",
"support": "External Support",
"wiki": "External Wiki",
"license": "License",
"type": "Type",
"customName": "Name",
@ -291,8 +293,10 @@
"issuesSub": "Providing an issue tracker helps your users get support more easily and provides you with an easy way to track bugs.",
"source": "Source code",
"sourceSub": "Support the community of developers by making your project open source!",
"support": "External support",
"support": "External wiki",
"supportSub": "An external place where you can offer support to your users. Could be a forum, a Discord server, or somewhere else.",
"wiki": "External Wiki",
"wikiSub": "An external place where you can offer additional documentation to your users.",
"license": "License",
"licenseSub": "What can people do (and not do) with your project?",
"forum": "Create posts on the forums",

View File

@ -262,6 +262,9 @@ useHead(
<ProjectSettingsSection title="project.settings.support" description="project.settings.supportSub">
<InputText v-model.trim="form.settings.support" :label="i18n.t('project.new.step3.support')" :rules="[url()]" />
</ProjectSettingsSection>
<ProjectSettingsSection title="project.settings.support" description="project.settings.wikiSub">
<InputText v-model.trim="form.settings.wiki" :label="i18n.t('project.new.step3.wiki')" :rules="[url()]" />
</ProjectSettingsSection>
<ProjectSettingsSection title="project.settings.license" description="project.settings.licenseSub">
<div class="flex">
<div class="basis-full" :md="isCustomLicense ? 'basis-4/12' : 'basis-6/12'">

View File

@ -198,6 +198,7 @@ function createProject() {
<div class="basis-full mt-4"><InputText v-model.trim="form.settings.issues" :label="i18n.t('project.new.step3.issues')" :rules="[url()]" /></div>
<div class="basis-full mt-4"><InputText v-model.trim="form.settings.source" :label="i18n.t('project.new.step3.source')" :rules="[url()]" /></div>
<div class="basis-full mt-4"><InputText v-model.trim="form.settings.support" :label="i18n.t('project.new.step3.support')" :rules="[url()]" /></div>
<div class="basis-full mt-4"><InputText v-model.trim="form.settings.wiki" :label="i18n.t('project.new.step3.wiki')" :rules="[url()]" /></div>
</div>
<div class="text-lg mt-6 flex gap-2 items-center">
<IconMdiLicense />

View File

@ -33,6 +33,7 @@ declare module "hangar-api" {
issues: string | null;
source: string | null;
support: string | null;
wiki: string | null;
license: License;
keywords: string[];
forumSync: boolean;

View File

@ -69,6 +69,7 @@ declare module "hangar-internal" {
issues: string | null;
source: string | null;
support: string | null;
wiki: string | null;
keywords: string[];
license: {
type?: string | null;

View File

@ -48,6 +48,7 @@ public interface HangarProjectsDAO {
" ps.issues," +
" ps.source," +
" ps.support," +
" ps.wiki," +
" ps.license_name," +
" ps.license_type," +
" ps.license_url," +

View File

@ -21,14 +21,14 @@ public interface ProjectsDAO {
@Timestamped
@GetGeneratedKeys
@SqlUpdate("insert into projects (created_at, name, slug, owner_name, owner_id, category, description, visibility, homepage, issues, source, support, keywords, license_type, license_name, license_url, donation_enabled, donation_subject, sponsors) " +
"values (:now, :name, :slug, :ownerName,:ownerId, :category, :description, :visibility, :homepage, :issues, :source, :support, :keywords, :licenseType, :licenseName, :licenseUrl, :donationEnabled, :donationSubject, :sponsors)")
@SqlUpdate("insert into projects (created_at, name, slug, owner_name, owner_id, category, description, visibility, homepage, issues, source, support, wiki, keywords, license_type, license_name, license_url, donation_enabled, donation_subject, sponsors) " +
"values (:now, :name, :slug, :ownerName,:ownerId, :category, :description, :visibility, :homepage, :issues, :source, :support, :wiki, :keywords, :licenseType, :licenseName, :licenseUrl, :donationEnabled, :donationSubject, :sponsors)")
ProjectTable insert(@BindBean ProjectTable project);
@GetGeneratedKeys
@SqlUpdate("UPDATE projects SET name = :name, slug = :slug, category = :category, keywords = :keywords, issues = :issues, source = :source, " +
"license_type = :licenseType, license_name = :licenseName, license_url = :licenseUrl, forum_sync = :forumSync, description = :description, visibility = :visibility, " +
"support = :support, homepage = :homepage, post_id = :postId, topic_id = :topicId, donation_enabled = :donationEnabled, donation_subject = :donationSubject, " +
"support = :support, homepage = :homepage, wiki = :wiki, post_id = :postId, topic_id = :topicId, donation_enabled = :donationEnabled, donation_subject = :donationSubject, " +
"sponsors = :sponsors WHERE id = :id")
ProjectTable update(@BindBean ProjectTable project);

View File

@ -50,6 +50,7 @@ public interface ProjectsApiDAO {
" p.issues," +
" p.source," +
" p.support," +
" p.wiki," +
" p.license_name," +
" p.license_url," +
" p.keywords," +
@ -94,6 +95,7 @@ public interface ProjectsApiDAO {
p.issues,
p.source,
p.support,
p.wiki,
p.license_name,
p.license_type,
p.license_url,

View File

@ -19,6 +19,8 @@ public class ProjectSettings {
private final String source;
@Validate(SpEL = "@validate.regex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
private final String support;
@Validate(SpEL = "@validate.regex(#root, @hangarConfig.urlRegex)", message = "validation.invalidUrl")
private final String wiki;
@Valid
private final ProjectLicense license;
@Valid
@ -31,11 +33,12 @@ public class ProjectSettings {
private final String sponsors;
@JsonCreator
public ProjectSettings(@Nullable String homepage, @Nullable String issues, @Nullable String source, @Nullable String support, @Nested("license") ProjectLicense license, @Nested("donation") ProjectDonationSettings donation, Collection<String> keywords, boolean forumSync, String sponsors) {
public ProjectSettings(@Nullable String homepage, @Nullable String issues, @Nullable String source, @Nullable String support, @Nullable String wiki, @Nested("license") ProjectLicense license, @Nested("donation") ProjectDonationSettings donation, Collection<String> keywords, boolean forumSync, String sponsors) {
this.homepage = homepage;
this.issues = issues;
this.source = source;
this.support = support;
this.wiki = wiki;
this.license = license;
this.donation = donation;
this.keywords = keywords;
@ -59,6 +62,10 @@ public class ProjectSettings {
return support;
}
public String getWiki() {
return wiki;
}
public ProjectLicense getLicense() {
return license;
}
@ -86,6 +93,7 @@ public class ProjectSettings {
", issues='" + issues + '\'' +
", source='" + source + '\'' +
", support='" + support + '\'' +
", support='" + wiki + '\'' +
", license=" + license +
", donation=" + donation +
", keywords=" + keywords +

View File

@ -31,6 +31,7 @@ public class ProjectTable extends Table implements Visitable, ModelVisible, Proj
private String issues;
private String source;
private String support;
private String wiki;
private String licenseType;
private String licenseName;
private String licenseUrl;
@ -54,6 +55,7 @@ public class ProjectTable extends Table implements Visitable, ModelVisible, Proj
this.issues = form.getSettings().getIssues();
this.source = form.getSettings().getSource();
this.support = form.getSettings().getSupport();
this.wiki = form.getSettings().getWiki();
this.keywords = form.getSettings().getKeywords();
this.licenseType = form.getSettings().getLicense().getType();
this.licenseName = form.getSettings().getLicense().getName();
@ -78,6 +80,7 @@ public class ProjectTable extends Table implements Visitable, ModelVisible, Proj
this.issues = other.issues;
this.source = other.source;
this.support = other.support;
this.wiki = other.wiki;
this.licenseType = other.licenseType;
this.licenseName = other.licenseName;
this.licenseUrl = other.licenseUrl;
@ -90,7 +93,7 @@ public class ProjectTable extends Table implements Visitable, ModelVisible, Proj
@JdbiConstructor
public ProjectTable(OffsetDateTime createdAt, long id, String name, String slug, String ownerName, long ownerId, Long topicId,
Long postId, @EnumByOrdinal Category category, String description, @EnumByOrdinal Visibility visibility, Collection<String> keywords,
String homepage, String issues, String source, String support, String licenseType, String licenseName, String licenseUrl, boolean forumSync,
String homepage, String issues, String source, String support, String wiki, String licenseType, String licenseName, String licenseUrl, boolean forumSync,
boolean donationEnabled, String donationSubject, String sponsors) {
super(createdAt, id);
this.name = name;
@ -107,6 +110,7 @@ public class ProjectTable extends Table implements Visitable, ModelVisible, Proj
this.issues = issues;
this.source = source;
this.support = support;
this.wiki = wiki;
this.licenseType = licenseType;
this.licenseName = licenseName;
this.licenseUrl = licenseUrl;
@ -235,6 +239,14 @@ public class ProjectTable extends Table implements Visitable, ModelVisible, Proj
this.support = support;
}
public String getWiki() {
return wiki;
}
public void setWiki(String wiki) {
this.wiki = wiki;
}
public String getLicenseType() {
return licenseType;
}
@ -318,6 +330,7 @@ public class ProjectTable extends Table implements Visitable, ModelVisible, Proj
", issues='" + issues + '\'' +
", source='" + source + '\'' +
", support='" + support + '\'' +
", wiki='" + wiki + '\'' +
", licenseType='" + licenseType + '\'' +
", licenseName='" + licenseName + '\'' +
", licenseUrl='" + licenseUrl + '\'' +

View File

@ -127,6 +127,7 @@ public class ProjectService extends HangarComponent {
projectTable.setIssues(settingsForm.getSettings().getIssues());
projectTable.setSource(settingsForm.getSettings().getSource());
projectTable.setSupport(settingsForm.getSettings().getSupport());
projectTable.setWiki(settingsForm.getSettings().getWiki());
String licenseName = org.apache.commons.lang3.StringUtils.stripToNull(settingsForm.getSettings().getLicense().getName());
if (licenseName == null) {
licenseName = settingsForm.getSettings().getLicense().getType();

View File

@ -0,0 +1 @@
ALTER TABLE projects ADD COLUMN wiki varchar(255);