mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-12-27 07:03:26 +08:00
fixed mostly view stuff (#55)
Co-authored-by: MiniDigger <admin@minidigger.me>
This commit is contained in:
parent
1ed562d952
commit
e56ec0ec27
@ -3,7 +3,7 @@
|
|||||||
[#-- @ftlvariable name="@helper" type="freemarker.template.TemplateHashModel" --]
|
[#-- @ftlvariable name="@helper" type="freemarker.template.TemplateHashModel" --]
|
||||||
[#-- @ftlvariable name="alerts" type="java.util.Map" --]
|
[#-- @ftlvariable name="alerts" type="java.util.Map" --]
|
||||||
[#-- @ftlvariable name="routes" type="me.minidigger.hangar.util.RouteHelper" --]
|
[#-- @ftlvariable name="routes" type="me.minidigger.hangar.util.RouteHelper" --]
|
||||||
[#-- @ftlvariable name="templateHelper" type="me.minidigger.hangar.util.TemplateHelper" --]
|
[#-- @ftlvariable name="rand" type="java.util.Random" --]
|
||||||
[#-- @ftlvariable name="headerData" type="me.minidigger.hangar.model.viewhelpers.HeaderData" --]
|
[#-- @ftlvariable name="headerData" type="me.minidigger.hangar.model.viewhelpers.HeaderData" --]
|
||||||
[#-- @ftlvariable name="rc" type="org.springframework.web.servlet.support.RequestContext" --]
|
[#-- @ftlvariable name="rc" type="org.springframework.web.servlet.support.RequestContext" --]
|
||||||
[#-- @ftlvariable name="config" type="me.minidigger.hangar.config.HangarConfig" --]
|
[#-- @ftlvariable name="config" type="me.minidigger.hangar.config.HangarConfig" --]
|
||||||
|
@ -13,12 +13,17 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = "hangar")
|
@ConfigurationProperties(prefix = "hangar")
|
||||||
@ComponentScan("me.minidigger.hangar")
|
@ComponentScan("me.minidigger.hangar")
|
||||||
public class HangarConfig {
|
public class HangarConfig {
|
||||||
|
|
||||||
|
private String logo = "https://paper.readthedocs.io/en/latest/_images/papermc_logomark_500.png";
|
||||||
|
private String service = "Hangar";
|
||||||
|
private List<Sponsor> sponsors;
|
||||||
|
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
private int debugLevel = 3;
|
private int debugLevel = 3;
|
||||||
private boolean staging = true;
|
private boolean staging = true;
|
||||||
@ -41,6 +46,37 @@ public class HangarConfig {
|
|||||||
@NestedConfigurationProperty
|
@NestedConfigurationProperty
|
||||||
public HangarApiConfig api;
|
public HangarApiConfig api;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public static class Sponsor {
|
||||||
|
private String name;
|
||||||
|
private String image;
|
||||||
|
private String link;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(String image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public HangarConfig(FakeUserConfig fakeUser, HangarHomepageConfig homepage, HangarChannelsConfig channels, HangarPagesConfig pages, HangarProjectsConfig projects, HangarUserConfig user, HangarOrgConfig org, HangarApiConfig api) {
|
public HangarConfig(FakeUserConfig fakeUser, HangarHomepageConfig homepage, HangarChannelsConfig channels, HangarPagesConfig pages, HangarProjectsConfig projects, HangarUserConfig user, HangarOrgConfig org, HangarApiConfig api) {
|
||||||
this.fakeUser = fakeUser;
|
this.fakeUser = fakeUser;
|
||||||
@ -53,6 +89,30 @@ public class HangarConfig {
|
|||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLogo() {
|
||||||
|
return logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogo(String logo) {
|
||||||
|
this.logo = logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getService() {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setService(String service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Sponsor> getSponsors() {
|
||||||
|
return sponsors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSponsors(List<Sponsor> sponsors) {
|
||||||
|
this.sponsors = sponsors;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDebug() {
|
public boolean isDebug() {
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import me.minidigger.hangar.config.HangarConfig;
|
import me.minidigger.hangar.config.HangarConfig;
|
||||||
import me.minidigger.hangar.service.MarkdownService;
|
import me.minidigger.hangar.service.MarkdownService;
|
||||||
import me.minidigger.hangar.service.UserService;
|
import me.minidigger.hangar.service.UserService;
|
||||||
import me.minidigger.hangar.util.RouteHelper;
|
import me.minidigger.hangar.util.RouteHelper;
|
||||||
import me.minidigger.hangar.util.TemplateHelper;
|
|
||||||
|
|
||||||
public abstract class HangarController {
|
public abstract class HangarController {
|
||||||
|
|
||||||
@ -22,8 +22,6 @@ public abstract class HangarController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateHelper templateHelper;
|
|
||||||
@Autowired
|
|
||||||
private HangarConfig hangarConfig;
|
private HangarConfig hangarConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MarkdownService markdownService;
|
private MarkdownService markdownService;
|
||||||
@ -31,13 +29,13 @@ public abstract class HangarController {
|
|||||||
protected ModelAndView fillModel(ModelAndView mav) {
|
protected ModelAndView fillModel(ModelAndView mav) {
|
||||||
// helpers
|
// helpers
|
||||||
mav.addObject("routes", routeHelper);
|
mav.addObject("routes", routeHelper);
|
||||||
mav.addObject("templateHelper", templateHelper);
|
|
||||||
BeansWrapperBuilder builder = new BeansWrapperBuilder(Configuration.VERSION_2_3_30);
|
BeansWrapperBuilder builder = new BeansWrapperBuilder(Configuration.VERSION_2_3_30);
|
||||||
builder.setExposeFields(true);
|
builder.setExposeFields(true);
|
||||||
builder.setUseModelCache(true);
|
builder.setUseModelCache(true);
|
||||||
mav.addObject("@helper", builder.build().getStaticModels());
|
mav.addObject("@helper", builder.build().getStaticModels());
|
||||||
mav.addObject("config", hangarConfig);
|
mav.addObject("config", hangarConfig);
|
||||||
mav.addObject("markdownService", markdownService);
|
mav.addObject("markdownService", markdownService);
|
||||||
|
mav.addObject("rand", ThreadLocalRandom.current());
|
||||||
|
|
||||||
// alerts
|
// alerts
|
||||||
if (mav.getModelMap().getAttribute("alerts") == null) {
|
if (mav.getModelMap().getAttribute("alerts") == null) {
|
||||||
|
@ -16,7 +16,7 @@ public class RolesTable {
|
|||||||
private long permission;
|
private long permission;
|
||||||
|
|
||||||
public static RolesTable fromRole(Role role) {
|
public static RolesTable fromRole(Role role) {
|
||||||
return new RolesTable(role.getRoleId(), role.getValue(), role.getCategory(), role.getTitle(), role.getColor().getHex(), role.isAssignable(), null, role.getPermissions().getValue());
|
return new RolesTable(role.getRoleId(), role.getValue(), role.getCategory(), role.getTitle(), role.getColor().getHex(), role.isAssignable(), role.getRank(), role.getPermissions().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public RolesTable() {
|
public RolesTable() {
|
||||||
|
@ -26,11 +26,11 @@ public enum Role {
|
|||||||
CONTRIBUTOR("Contributor", 12, GLOBAL, None, "Contributor", GREEN),
|
CONTRIBUTOR("Contributor", 12, GLOBAL, None, "Contributor", GREEN),
|
||||||
ADVISOR("Advisor", 13, GLOBAL, None, "Advisor", AQUA),
|
ADVISOR("Advisor", 13, GLOBAL, None, "Advisor", AQUA),
|
||||||
|
|
||||||
STONE_DONOR("Stone_Donor", 14, GLOBAL, None, "Stone Donor", GRAY),
|
STONE_DONOR("Stone_Donor", 14, GLOBAL, None, "Stone Donor", GRAY, 5L),
|
||||||
QUARTZ_DONOR("Quartz_Donor",15, GLOBAL, None, "Quartz Donor", QUARTZ),
|
QUARTZ_DONOR("Quartz_Donor",15, GLOBAL, None, "Quartz Donor", QUARTZ, 4L),
|
||||||
IRON_DONOR("Iron_Donor",16, GLOBAL, None, "Iron Donor", SILVER),
|
IRON_DONOR("Iron_Donor",16, GLOBAL, None, "Iron Donor", SILVER, 3L),
|
||||||
GOLD_DONOR("Gold_Donor",17, GLOBAL, None, "Gold Donor", GOLD),
|
GOLD_DONOR("Gold_Donor",17, GLOBAL, None, "Gold Donor", GOLD, 2L),
|
||||||
DIAMOND_DONOR("Diamond_Donor",18, GLOBAL, None, "Diamond Donor", LIGHTBLUE),
|
DIAMOND_DONOR("Diamond_Donor",18, GLOBAL, None, "Diamond Donor", LIGHTBLUE, 1L),
|
||||||
|
|
||||||
PROJECT_SUPPORT("Project_Support", 22, PROJECT, IsProjectMember, "Support", TRANSPARENT),
|
PROJECT_SUPPORT("Project_Support", 22, PROJECT, IsProjectMember, "Support", TRANSPARENT),
|
||||||
PROJECT_EDITOR("Project_Editor", 21, PROJECT, EditPage.add(PROJECT_SUPPORT.getPermissions()), "Editor", TRANSPARENT),
|
PROJECT_EDITOR("Project_Editor", 21, PROJECT, EditPage.add(PROJECT_SUPPORT.getPermissions()), "Editor", TRANSPARENT),
|
||||||
@ -51,11 +51,17 @@ public enum Role {
|
|||||||
private String title;
|
private String title;
|
||||||
private Color color;
|
private Color color;
|
||||||
private boolean isAssignable;
|
private boolean isAssignable;
|
||||||
|
private Long rank = null;
|
||||||
|
|
||||||
Role(String value, int roleId, RoleCategory category, Permission permissions, String title, Color color) {
|
Role(String value, int roleId, RoleCategory category, Permission permissions, String title, Color color) {
|
||||||
this(value, roleId, category, permissions, title, color, true);
|
this(value, roleId, category, permissions, title, color, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Role(String value, int roleId, RoleCategory category, Permission permissions, String title, Color color, Long rank) {
|
||||||
|
this(value, roleId, category, permissions, title, color);
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
Role(String value, int roleId, RoleCategory category, Permission permissions, String title, Color color, boolean isAssignable) {
|
Role(String value, int roleId, RoleCategory category, Permission permissions, String title, Color color, boolean isAssignable) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
@ -94,6 +100,10 @@ public enum Role {
|
|||||||
return isAssignable;
|
return isAssignable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getRank() {
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
public static Role fromTitle(String title) {
|
public static Role fromTitle(String title) {
|
||||||
for (Role r : values()) {
|
for (Role r : values()) {
|
||||||
if (r.title.equals(title)) {
|
if (r.title.equals(title)) {
|
||||||
|
@ -73,4 +73,8 @@ public class Author {
|
|||||||
public void setCount(long count) {
|
public void setCount(long count) {
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAvatarUrl() {
|
||||||
|
return "https://paper.readthedocs.io/en/latest/_images/papermc_logomark_500.png"; // TODO figure out what to do with avatar url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,4 +53,8 @@ public class Staff {
|
|||||||
public void setCreatedAt(OffsetDateTime createdAt) {
|
public void setCreatedAt(OffsetDateTime createdAt) {
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAvatarUrl() {
|
||||||
|
return "https://paper.readthedocs.io/en/latest/_images/papermc_logomark_500.png"; // TODO figure out what to do with avatar url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package me.minidigger.hangar.util;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class TemplateHelper {
|
|
||||||
|
|
||||||
public Map<String, String> randomSponsor() {
|
|
||||||
// TODO implement random sponsor stuff
|
|
||||||
return Map.of("link", "https://minidigger.me", "image", "https://avatars2.githubusercontent.com/u/2185527?s=400&v=4");
|
|
||||||
}
|
|
||||||
}
|
|
@ -35,6 +35,14 @@ hangar:
|
|||||||
staging: true
|
staging: true
|
||||||
log-timings: false
|
log-timings: false
|
||||||
|
|
||||||
|
sponsors:
|
||||||
|
- name: Theranos
|
||||||
|
image: https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Theranos_Logo.svg/1200px-Theranos_Logo.svg.png
|
||||||
|
link: https://en.wikipedia.org/wiki/Theranos
|
||||||
|
- name: MiniDigger
|
||||||
|
image: https://avatars2.githubusercontent.com/u/2185527?s=400&v=4
|
||||||
|
link: https://minidigger.me
|
||||||
|
|
||||||
homepage:
|
homepage:
|
||||||
update-interval: 10m
|
update-interval: 10m
|
||||||
|
|
||||||
|
@ -23,6 +23,11 @@ sorted according to different criteria.
|
|||||||
<meta property="og:description" content="<@spring.message "general.description" />" />
|
<meta property="og:description" content="<@spring.message "general.description" />" />
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
|
<#function randomSponsor>
|
||||||
|
<#local index = rand.nextInt(config.getSponsors()?size) />
|
||||||
|
<#return config.sponsors[index] />
|
||||||
|
</#function>
|
||||||
|
|
||||||
<#assign message><@spring.message "general.title" /></#assign>
|
<#assign message><@spring.message "general.title" /></#assign>
|
||||||
<#assign scriptsVar><@scripts /></#assign>
|
<#assign scriptsVar><@scripts /></#assign>
|
||||||
<#assign stylesheetsVar><@stylesheets /></#assign>
|
<#assign stylesheetsVar><@stylesheets /></#assign>
|
||||||
@ -46,9 +51,10 @@ sorted according to different criteria.
|
|||||||
<div class="panel sponsor-panel">
|
<div class="panel sponsor-panel">
|
||||||
<span>Sponsored by</span>
|
<span>Sponsored by</span>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<#assign sponsor=templateHelper.randomSponsor() />
|
<#-- @ftlvariable name="sponsor" type="me.minidigger.hangar.config.HangarConfig.Sponsor" -->
|
||||||
|
<#assign sponsor=randomSponsor() />
|
||||||
<a href="${sponsor.link}">
|
<a href="${sponsor.link}">
|
||||||
<img class="logo" src="${sponsor.image}" alt="Sponsor" />
|
<img class="logo" src="${sponsor.image}" alt="${sponsor.name}" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
@pageSize = @{ config.ore.users.authorPageSize }
|
@pageSize = @{ config.ore.users.authorPageSize }
|
||||||
-->
|
-->
|
||||||
|
<#assign pageSize=config.user.authorPageSize />
|
||||||
|
|
||||||
<#function direction>
|
<#function direction>
|
||||||
<#if ordering?startsWith("-")>
|
<#if ordering?startsWith("-")>
|
||||||
@ -40,6 +41,7 @@
|
|||||||
<script <#--@CSPNonce.attr-->>CURRENT_PAGE = ${page};</script>
|
<script <#--@CSPNonce.attr-->>CURRENT_PAGE = ${page};</script>
|
||||||
</#assign>
|
</#assign>
|
||||||
|
|
||||||
|
<#-- @ftlvariable name="page" type="java.lang.Integer" -->
|
||||||
<@base.base title="Authors - Hangar" additionalScripts=scriptsVar>
|
<@base.base title="Authors - Hangar" additionalScripts=scriptsVar>
|
||||||
<#assign UserOrdering = @helper["me.minidigger.hangar.model.UserOrdering"]>
|
<#assign UserOrdering = @helper["me.minidigger.hangar.model.UserOrdering"]>
|
||||||
<#-- @ftlvariable name="UserOrdering" type="me.minidigger.hangar.model.UserOrdering" -->
|
<#-- @ftlvariable name="UserOrdering" type="me.minidigger.hangar.model.UserOrdering" -->
|
||||||
@ -70,13 +72,13 @@
|
|||||||
<#list authors as author>
|
<#list authors as author>
|
||||||
<tr>
|
<tr>
|
||||||
<#import "*/utils/userAvatar.ftlh" as userAvatar>
|
<#import "*/utils/userAvatar.ftlh" as userAvatar>
|
||||||
<td><@userAvatar.userAvatar userName=author.name avatarUrl=User.avatarUrl(author.name) clazz="user-avatar-xs"></@userAvatar.userAvatar></td>
|
<td><@userAvatar.userAvatar userName=author.name avatarUrl=author.avatarUrl clazz="user-avatar-xs"></@userAvatar.userAvatar></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="${routes.getRouteUrl("users.showProjects", author.name)}">${author.name}</a>
|
<a href="${routes.getRouteUrl("users.showProjects", author.name)}">${author.name}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<#if author.donatorRole??>
|
<#if author.donatorRole??>
|
||||||
<span class="channel channel-sm" style="background-color: ${role.color.hex}">
|
<span class="channel channel-sm" style="background-color: ${author.donatorRole.color.hex}">
|
||||||
${author.donatorRole}
|
${author.donatorRole}
|
||||||
</span>
|
</span>
|
||||||
</#if>
|
</#if>
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
<#import "*/utils/hangar.ftlh" as hangar />
|
<#import "*/utils/hangar.ftlh" as hangar />
|
||||||
<#import "*/layout/base.ftlh" as base>
|
<#import "*/layout/base.ftlh" as base>
|
||||||
|
|
||||||
<#--
|
|
||||||
@(staff: Seq[(String, Role, Option[OffsetDateTime], OffsetDateTime)], ordering: String, page: Int)(implicit messages: Messages, request: OreRequest[_], config: OreConfig, flash: Flash, assetsFinder: AssetsFinder)
|
|
||||||
-->
|
|
||||||
|
|
||||||
<#function direction>
|
<#function direction>
|
||||||
<#if ordering?startsWith("-")>
|
<#if ordering?startsWith("-")>
|
||||||
<#return "chevron-down">
|
<#return "chevron-down">
|
||||||
@ -50,22 +46,23 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<#list staff as user>
|
<#list staff as staffUser>
|
||||||
<tr>
|
<tr>
|
||||||
<#import "*/utils/userAvatar.ftlh" as userAvatar>
|
<#import "*/utils/userAvatar.ftlh" as userAvatar>
|
||||||
<td><@userAvatar.userAvatar userName=user.name avatarUrl=User.avatarUrl(user.name) clazz="user-avatar-xs"></@userAvatar.userAvatar></td>
|
<td><@userAvatar.userAvatar userName=staffUser.name avatarUrl=staffUser.avatarUrl clazz="user-avatar-xs"></@userAvatar.userAvatar></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="${routes.getRouteUrl("showActivities", user.name)}">${user.name}</a>
|
<a href="${routes.getRouteUrl("showActivities", staffUser.name)}">${staffUser.name}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="user-role channel" style="background-color: ${user.role.color.hex}">
|
<span class="user-role channel" style="background-color: ${staffUser.role.color.hex}">
|
||||||
${user.role.title}
|
${staffUser.role.title}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>${(user.joinDate!user.createdAt).format("yyyy-MM-dd")}</td>
|
<td>${(staffUser.joinDate!staffUser.createdAt).format("yyyy-MM-dd")}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</#list>
|
</#list>
|
||||||
|
<#-- @ftlvariable name="page" type="java.lang.Integer" -->
|
||||||
|
<#-- @ftlvariable name="pageSize" type="java.lang.Integer" -->
|
||||||
<#if page gt 1 || staff?size gte pageSize>
|
<#if page gt 1 || staff?size gte pageSize>
|
||||||
<tr class="authors-footer">
|
<tr class="authors-footer">
|
||||||
<td></td>
|
<td></td>
|
||||||
|
Loading…
Reference in New Issue
Block a user