From b5e2e663a03c32fecbbc315467cba8882aaad720 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Sun, 19 Jun 2022 19:30:23 +0200 Subject: [PATCH] allow linking to wikis, closes #549 --- frontend/src/components/projects/ProjectNav.vue | 3 +++ frontend/src/i18n/locales/en.json | 8 ++++++-- frontend/src/pages/[user]/[project]/settings.vue | 3 +++ frontend/src/pages/new.vue | 1 + frontend/src/types/api/projects.d.ts | 1 + frontend/src/types/internal/projects.d.ts | 1 + .../dao/internal/projects/HangarProjectsDAO.java | 1 + .../dao/internal/table/projects/ProjectsDAO.java | 6 +++--- .../papermc/hangar/db/dao/v1/ProjectsApiDAO.java | 2 ++ .../hangar/model/api/project/ProjectSettings.java | 10 +++++++++- .../hangar/model/db/projects/ProjectTable.java | 15 ++++++++++++++- .../service/internal/projects/ProjectService.java | 1 + src/main/resources/db/migration/V1.0.1__wiki.sql | 1 + 13 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/db/migration/V1.0.1__wiki.sql diff --git a/frontend/src/components/projects/ProjectNav.vue b/frontend/src/components/projects/ProjectNav.vue index e44e4e7f..bcf614c5 100644 --- a/frontend/src/components/projects/ProjectNav.vue +++ b/frontend/src/components/projects/ProjectNav.vue @@ -48,5 +48,8 @@ function childRoute(route = ""): string { {{ i18n.t("project.tabs.support") }} + + {{ i18n.t("project.tabs.wiki") }} + diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 7c0d1c11..9364149d 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -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", diff --git a/frontend/src/pages/[user]/[project]/settings.vue b/frontend/src/pages/[user]/[project]/settings.vue index 5fef5e9f..9fcdc6d0 100644 --- a/frontend/src/pages/[user]/[project]/settings.vue +++ b/frontend/src/pages/[user]/[project]/settings.vue @@ -262,6 +262,9 @@ useHead( + + +
diff --git a/frontend/src/pages/new.vue b/frontend/src/pages/new.vue index b89b9318..55e37b21 100644 --- a/frontend/src/pages/new.vue +++ b/frontend/src/pages/new.vue @@ -198,6 +198,7 @@ function createProject() {
+
diff --git a/frontend/src/types/api/projects.d.ts b/frontend/src/types/api/projects.d.ts index 1da1c388..5e5096c2 100644 --- a/frontend/src/types/api/projects.d.ts +++ b/frontend/src/types/api/projects.d.ts @@ -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; diff --git a/frontend/src/types/internal/projects.d.ts b/frontend/src/types/internal/projects.d.ts index 63d42c20..85777b9f 100644 --- a/frontend/src/types/internal/projects.d.ts +++ b/frontend/src/types/internal/projects.d.ts @@ -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; diff --git a/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectsDAO.java b/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectsDAO.java index 0d313866..47373737 100644 --- a/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectsDAO.java +++ b/src/main/java/io/papermc/hangar/db/dao/internal/projects/HangarProjectsDAO.java @@ -48,6 +48,7 @@ public interface HangarProjectsDAO { " ps.issues," + " ps.source," + " ps.support," + + " ps.wiki," + " ps.license_name," + " ps.license_type," + " ps.license_url," + diff --git a/src/main/java/io/papermc/hangar/db/dao/internal/table/projects/ProjectsDAO.java b/src/main/java/io/papermc/hangar/db/dao/internal/table/projects/ProjectsDAO.java index ee738f72..7fea7000 100644 --- a/src/main/java/io/papermc/hangar/db/dao/internal/table/projects/ProjectsDAO.java +++ b/src/main/java/io/papermc/hangar/db/dao/internal/table/projects/ProjectsDAO.java @@ -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); diff --git a/src/main/java/io/papermc/hangar/db/dao/v1/ProjectsApiDAO.java b/src/main/java/io/papermc/hangar/db/dao/v1/ProjectsApiDAO.java index 314ec6eb..d1ed86c7 100644 --- a/src/main/java/io/papermc/hangar/db/dao/v1/ProjectsApiDAO.java +++ b/src/main/java/io/papermc/hangar/db/dao/v1/ProjectsApiDAO.java @@ -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, diff --git a/src/main/java/io/papermc/hangar/model/api/project/ProjectSettings.java b/src/main/java/io/papermc/hangar/model/api/project/ProjectSettings.java index 0d42e21a..1860cbb4 100644 --- a/src/main/java/io/papermc/hangar/model/api/project/ProjectSettings.java +++ b/src/main/java/io/papermc/hangar/model/api/project/ProjectSettings.java @@ -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 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 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 + diff --git a/src/main/java/io/papermc/hangar/model/db/projects/ProjectTable.java b/src/main/java/io/papermc/hangar/model/db/projects/ProjectTable.java index 15ce1304..b5e08649 100644 --- a/src/main/java/io/papermc/hangar/model/db/projects/ProjectTable.java +++ b/src/main/java/io/papermc/hangar/model/db/projects/ProjectTable.java @@ -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 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 + '\'' + diff --git a/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java b/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java index da1445b4..d031f82a 100644 --- a/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java +++ b/src/main/java/io/papermc/hangar/service/internal/projects/ProjectService.java @@ -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(); diff --git a/src/main/resources/db/migration/V1.0.1__wiki.sql b/src/main/resources/db/migration/V1.0.1__wiki.sql new file mode 100644 index 00000000..b879e818 --- /dev/null +++ b/src/main/resources/db/migration/V1.0.1__wiki.sql @@ -0,0 +1 @@ +ALTER TABLE projects ADD COLUMN wiki varchar(255);