Port various bits of modals, projects and user templates

This commit is contained in:
md678685 2020-07-14 12:38:37 +01:00
parent 53babc212a
commit 01fd34eef9
8 changed files with 519 additions and 496 deletions

View File

@ -1,55 +1,58 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/projects/channels/helper/popoverColorPicker.ftlh" as popoverColorPicker />
@import ore.OreConfig
@import views.html.helper.{CSRF, form}
@()(implicit messages: Messages, config: OreConfig, request: Request[_])
<div class="modal fade" id="channel-settings" tabindex="-1" role="dialog" aria-labelledBy="settings-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="<@spring.message "general.cancel" />">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"></h4>
</div>
@form(action = routes.Application.showHome()) {
@CSRF.formField
<div class="modal-body">
<div class="form-inline">
<label for="channel-input"><@spring.message "channel.name" /></label>
<input class="form-control channel-input" name="channel-input" type="text" value=""
maxlength="@config.ore.channels.maxNameLen"/>
<input type="hidden" name="channel-color-input" class="channel-color-input" value="" />
<a href="#">
<span class="color-picker" data-toggle="popover" data-placement="right" data-trigger="hover">
<i class="fas fa-circle channel-id" style=""></i>
</span>
</a>
@projects.channels.helper.popoverColorPicker()
<span class="pull-right channel preview" style="display: none;"></span>
<p class="help-block"><@spring.message "channel.nameRequirements" /></p>
<br/>
<span class="minor"><@spring.message "channel.nonReviewed" /></span>
<input class="form-control non-reviewed"
name="non-reviewed"
type="checkbox"
value="true" />
<a href="#">
<i class="fas fa-question-circle"
title="<@spring.message "channel.nonReviewed.info" />"
data-toggle="tooltip"></i>
</a>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
<#macro modalManage>
<div class="modal fade" id="channel-settings" tabindex="-1" role="dialog" aria-labelledBy="settings-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="<@spring.message "general.cancel" />">
<span aria-hidden="true">&times;</span>
</button>
<input type="submit" value="" class="btn btn-primary" disabled />
<h4 class="modal-title"></h4>
</div>
}
@form(action = routes.Application.showHome()) {
@CSRF.formField
<div class="modal-body">
<div class="form-inline">
<label for="channel-input"><@spring.message "channel.name" /></label>
<input class="form-control channel-input" name="channel-input" type="text" value=""
maxlength="@config.ore.channels.maxNameLen"/>
<input type="hidden" name="channel-color-input" class="channel-color-input" value="" />
<a href="#">
<span class="color-picker" data-toggle="popover" data-placement="right" data-trigger="hover">
<i class="fas fa-circle channel-id" style=""></i>
</span>
</a>
<@popoverColorPicker.popoverColorPicker />
<span class="pull-right channel preview" style="display: none;"></span>
<p class="help-block"><@spring.message "channel.nameRequirements" /></p>
<br/>
<span class="minor"><@spring.message "channel.nonReviewed" /></span>
<input class="form-control non-reviewed"
name="non-reviewed"
type="checkbox"
value="true" />
<a href="#">
<i class="fas fa-question-circle"
title="<@spring.message "channel.nonReviewed.info" />"
data-toggle="tooltip"></i>
</a>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "channel.edit.close" />
</button>
<input type="submit" value="" class="btn btn-primary" disabled />
</div>
}
</div>
</div>
</div>
</div>
</#macro>

View File

@ -1,51 +1,55 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#-- TODO: all the color stuff -->
<#-- also, we could just move this macro over to modalManage? not used anywhere else -->
@import ore.models.project.Channel.Colors
@()
<table class="popover-color-picker" style="display: none;">
<tbody>
<tr>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors.head.hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(1).hex"></i></td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(2).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(3).hex"></i>
</td>
</tr>
<tr>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(4).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(5).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(6).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(7).hex"></i>
</td>
</tr>
<tr>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(8).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(9).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(10).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(11).hex"></i>
</td>
</tr>
</tbody>
</table>
<#macro popoverColorPicker>
<table class="popover-color-picker" style="display: none;">
<tbody>
<tr>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors.head.hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(1).hex"></i></td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(2).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(3).hex"></i>
</td>
</tr>
<tr>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(4).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(5).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(6).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(7).hex"></i>
</td>
</tr>
<tr>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(8).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(9).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(10).hex"></i>
</td>
<td style="padding: 3px;">
<i class="fas fa-circle channel-id" style="color: @Colors(11).hex"></i>
</td>
</tr>
</tbody>
</table>
</#macro>

View File

@ -1,5 +1,6 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/projects/channels/helper/modalManage.ftlh" as modalManage />
@import controllers.sugar.Requests.OreRequest
@import models.viewhelper.ProjectData
@ -97,7 +98,7 @@
>
<i class="fas fa-plus"></i>
</a>
${projects.channels.helper.modalManage()}
<@modalManage.modalManage />
</div>
</div>
</div>

View File

@ -1,9 +1,10 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/projects/view.ftlh" as projectView />
@*
<#--
Documentation page within Project overview.
*@
-->
@import java.text.NumberFormat
@ -44,7 +45,7 @@ Documentation page within Project overview.
</#if>
</#assign>
@projects.view(p, sp, "#docs", additionalScripts = scripts) {
<@projectView.view p sp "#docs" additionalScripts=scriptsVar>
<div class="row">
<div class="col-md-9">
<div class="row">
@ -64,18 +65,18 @@ Documentation page within Project overview.
<div class="col-md-3">
<div class="stats minor">
<p><@spring.message "project.category.info", p.project.category.title /></p>
<p><@spring.message "project.publishDate", prettifyDate(p.project.createdAt) /></p>
<p><@spring.messageArgs "project.category.info", p.project.category.title /></p>
<p><@spring.messageArgs "project.publishDate", prettifyDate(p.project.createdAt) /></p>
<p><span id="view-count"></span> views</p>
<p><span id="star-count"></span> <a href="${routes.getRouteUrl("projects.showStargazers", p.project.ownerName, p.project.slug, "")}">stars</a></p>
<p><span id="watcher-count"></span> <a href="${routes.getRouteUrl("projects.showWatchers", p.project.ownerName, p.project.slug, "")}">watchers</a></p>
<p><span id="download-count"></span> total downloads</p>
@p.project.settings.licenseName.map { licenseName =>
<#list p.project.settings.licenseName as licenseName>
<p>
@Html(messages("project.license.link"))
<a target="_blank" rel="noopener" href="${p.project.settings.licenseUrl}">${licenseName}</a>
<@spring.message "project.license.link" />
<a target="_blank" rel="noopener" href="${p.project.settings.licenseUrl}">${licenseName}</a>
</p>
}
</#list>
</div>
<div class="panel panel-default">
@ -144,5 +145,4 @@ Documentation page within Project overview.
)
</div>
</div>
}
</@projectView.view>

View File

@ -189,6 +189,6 @@
</div>
${projects.channels.helper.modalManage()}
<@modalManage.modalManage />
</@base.base>

View File

@ -4,6 +4,7 @@
<#--
Base template for Project overview.
TODO: this is a layout, should we move/rename it?
-->
<#--
@ -21,41 +22,43 @@ Base template for Project overview.
request: OreRequest[_], flash: Flash, config: OreConfig, renderer: MarkdownRenderer, assetsFinder: AssetsFinder)
-->
<#assign scriptsVar>
<script type="text/javascript" src="<@hangar.url "javascripts/projectDetail.js" />"></script>
<script type="text/javascript" src="<@hangar.url "javascripts/pageEdit.js" />"></script>
<script <#-- @CSPNonce.attr -->>
var projectOwner = "${p.project.ownerName}";
var projectSlug = "${p.project.slug}";
var projectId = "${p.project.pluginId}";
var alreadyStarred = ${sp.starred};
$(function() { $(".nav").find("${active}").addClass("active"); });
</script>
}
</#assign>
<#macro view p sp active noButtons=false additionalScripts="" additionalStyling="">
<#assign scriptsVar>
<script type="text/javascript" src="<@hangar.url "javascripts/projectDetail.js" />"></script>
<script type="text/javascript" src="<@hangar.url "javascripts/pageEdit.js" />"></script>
${additionalScripts}
<script <#-- @CSPNonce.attr -->>
var projectOwner = "${p.project.ownerName}";
var projectSlug = "${p.project.slug}";
var projectId = "${p.project.pluginId}";
var alreadyStarred = ${sp.starred};
$(function() { $(".nav").find("${active}").addClass("active"); });
</script>
}
</#assign>
<#assign metaVar>
<meta property="og:title" content="${p.project.ownerName} / ${p.project.name}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="${config.app.baseUrl}${Projects.show(p.project.ownerName, p.project.slug)}" />
<meta property="og:image" content="${p.iconUrl}" />
<meta property="og:site_name" content="<@spring.message "general.appName" />" />
<meta property="og:description" content="${p.project.description!}" />
</#assign>
<#assign metaVar>
<meta property="og:title" content="${p.project.ownerName} / ${p.project.name}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="${config.app.baseUrl}${Projects.show(p.project.ownerName, p.project.slug)}" />
<meta property="og:image" content="${p.iconUrl}" />
<meta property="og:site_name" content="<@spring.message "general.appName" />" />
<meta property="og:description" content="${p.project.description!}" />
</#assign>
<@base.base title=(p.project.ownerName + " / " + p.project.name) additionalScripts=scriptsVar additionalMeta=metaVar>
<div class="project-header-container">
<#if p.visibility != Visibility.Public>
<div class="row">
<div class="col-xs-12">
<div class="alert alert-danger" role="alert" style="margin: 0.2em 0 0 0">
<#if p.visibility == Visibility.NeedsChanges>
<#if sp.perms(Permission.EditPage)>
<a class="btn btn-success pull-right" href="${p.fullSlug}/manage/sendforapproval">Send for approval</a>
}
<strong><@spring.message "visibility.notice." + p.visibility.nameKey /></strong>
<br>
${p.renderVisibilityChange!"Unknown"}
<@base.base title=(p.project.ownerName + " / " + p.project.name) additionalScripts=scriptsVar additionalStyling=additionalStyling additionalMeta=metaVar>
<div class="project-header-container">
<#if p.visibility != Visibility.Public>
<div class="row">
<div class="col-xs-12">
<div class="alert alert-danger" role="alert" style="margin: 0.2em 0 0 0">
<#if p.visibility == Visibility.NeedsChanges>
<#if sp.perms(Permission.EditPage)>
<a class="btn btn-success pull-right" href="${p.fullSlug}/manage/sendforapproval">Send for approval</a>
</#if>
<strong><@spring.message "visibility.notice." + p.visibility.nameKey /></strong>
<br>
${p.renderVisibilityChange!"Unknown"}
<#else>
<#if p.visibility == Visibility.SoftDelete>
<@spring.messageArgs "visibility.notice." + p.visibility.nameKey, [p.lastVisibilityChangeUser] />
@ -64,217 +67,218 @@ Base template for Project overview.
${p.renderVisibilityChange!}
</#if>
</#if>
</#if>
</div>
</div>
</div>
</div>
</#if>
</#if>
<!-- Header -->
<div class="row">
<div class="col-md-6">
<div class="project-header">
<div class="project-path">
<a href="${routes.Users.showProjects(p.project.ownerName)}">${p.project.ownerName}</a>
/
<a class="project-name" href="${Projects.show(p.project.ownerName, p.project.slug)}">${@p.project.name}</a>
</div>
<div>
<i class="minor" title="@description">${p.project.description!}</i>
</div>
</div>
</div>
<div class="col-md-6">
<#if !noButtons>
<div class="pull-right project-controls">
<#-- TODO
@flash.get("reported").map { _ =>
<span class="flag-msg">
<i class="fas fa-thumbs-up"></i> Flag submitted for review
</span>
}
-->
<#if p.project.visibility != Visibility.SoftDelete>
<#if request.currentUser.exists(u => !p.project.isOwner(u))> <#-- todo: if current user == owner -->
<button class="btn btn-default btn-star">
<i id="icon-star" <#if sp.starred>
class="fas fa-star"
<#else>
class="far fa-star"
</#if>></i>
<span class="starred">${p.starCount}</span>
</button>
<button class="btn btn-watch btn-default <#if sp.watching> watching </#if>">
<i class="fas <#if sp.watching> fa-eye-slash <#else> fa-eye </#if>"></i>
<span class="watch-status"> <#if sp.watching> Unwatch <#else> Watch </#if></span>
</button>
<#else>
<span class="minor stars-static">
<i class="fas fa-star"></i> ${p.starCount}
</span>
<!-- Header -->
<div class="row">
<div class="col-md-6">
<div class="project-header">
<div class="project-path">
<a href="${routes.getRouteUrl("users.showProjects", p.project.ownerName)}">${p.project.ownerName}</a>
/
<a class="project-name" href="${routes.getRouteUrl("projects.show", p.project.ownerName, p.project.slug)}">${@p.project.name}</a>
</div>
<div>
<#if p.project.description>
<i class="minor" title="${p.project.description}">${p.project.description}</i>
</#if>
</#if>
</div>
</div>
</div>
<div class="col-md-6">
<#if !noButtons>
<div class="pull-right project-controls">
<!-- Flag button -->
<#if request.hasUser && !request.currentUser.name.equals(p.project.ownerName)
&& !sp.uProjectFlags
&& p.project.visibility != Visibility.SoftDelete>
<button data-toggle="modal" data-target="#modal-flag" class="btn btn-default">
<i class="fas fa-flag"></i> <@spring.message "project.flag" />
</button>
<div class="modal fade" id="modal-flag" tabindex="-1" role="dialog"
aria-labelledby="label-flag">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="label-flag">Flag project</h4>
<#-- TODO
@flash.get("reported").map { _ =>
<span class="flag-msg">
<i class="fas fa-thumbs-up"></i> Flag submitted for review
</span>
}
-->
<#if p.project.visibility != Visibility.SoftDelete>
<#if request.currentUser.exists(u => !p.project.isOwner(u))> <#-- todo: if current user == owner -->
<button class="btn btn-default btn-star">
<i id="icon-star" <#if sp.starred>
class="fas fa-star"
<#else>
class="far fa-star"
</#if>></i>
<span class="starred">${p.starCount}</span>
</button>
<button class="btn btn-watch btn-default <#if sp.watching> watching </#if>">
<i class="fas <#if sp.watching> fa-eye-slash <#else> fa-eye </#if>"></i>
<span class="watch-status"> <#if sp.watching> Unwatch <#else> Watch </#if></span>
</button>
<#else>
<span class="minor stars-static">
<i class="fas fa-star"></i> ${p.starCount}
</span>
</#if>
</#if>
<!-- Flag button -->
<#if request.hasUser && !request.currentUser.name.equals(p.project.ownerName)
&& !sp.uProjectFlags
&& p.project.visibility != Visibility.SoftDelete>
<button data-toggle="modal" data-target="#modal-flag" class="btn btn-default">
<i class="fas fa-flag"></i> <@spring.message "project.flag" />
</button>
<div class="modal fade" id="modal-flag" tabindex="-1" role="dialog"
aria-labelledby="label-flag">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="label-flag">Flag project</h4>
</div>
@form(action = Projects.flag(
p.project.ownerName, p.project.slug)) {
@CSRF.formField
<div class="modal-body">
<ul class="list-group list-flags">
<#list FlagReason.values.indices as i>
<li class="list-group-item">
<span>${FlagReason.withValue(i).title}</span> <#-- todo: how do you freemarker this -->
<span class="pull-right">
<input required type="radio"
value="${FlagReason.withValue(i).value}" name="flag-reason"/>
</span>
</li>
</#list>
</ul>
<input class="form-control" name="comment" type="text"
maxlength="255" required="required"
placeholder="<@spring.message "ph.comment" />&hellip;" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
<button type="submit" class="btn btn-primary">Flag</button>
</div>
}
</div>
<#-- todo: ???
@form(action = Projects.flag(
p.project.ownerName, p.project.slug)) {
@CSRF.formField
-->
<div class="modal-body">
<ul class="list-group list-flags">
<#list FlagReason.values.indices as i>
<li class="list-group-item">
<span>${FlagReason.withValue(i).title}</span> <#-- todo: how do you freemarker this -->
<span class="pull-right">
<input required type="radio"
value="@FlagReason.withValue(i).value" name="flag-reason"/>
</span>
</li>
</#list>
</ul>
<input class="form-control" name="comment" type="text"
maxlength="255" required="required"
placeholder="<@spring.message "ph.comment" />&hellip;" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
<button type="submit" class="btn btn-primary">Flag</button>
</div>
<#-- closes @form
}
-->
</div>
</div>
</div>
</#if>
</#if>
<#if request.hasUser && (request.headerData.globalPerm(Permission.ModNotesAndFlags) || request.headerData.globalPerm(Permission.ViewLogs))>
<button class="btn btn-alert dropdown-toggle" type="button" id="admin-actions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Admin actions
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="admin-actions">
<#if request.headerData.globalPerm(Permission.ModNotesAndFlags)>
<li><a href="${Projects.showFlags(p.project.ownerName, p.project.slug)}">
Flag history (${p.flagCount} </a></li>
<#if request.hasUser && (request.headerData.globalPerm(Permission.ModNotesAndFlags) || request.headerData.globalPerm(Permission.ViewLogs))>
<button class="btn btn-alert dropdown-toggle" type="button" id="admin-actions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Admin actions
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="admin-actions">
<#if request.headerData.globalPerm(Permission.ModNotesAndFlags)>
<li><a href="${Projects.showFlags(p.project.ownerName, p.project.slug)}">
Flag history (${p.flagCount} </a></li>
</#if>
<#if request.headerData.globalPerm(Permission.ModNotesAndFlags)>
<li><a href="${Projects.showNotes(p.project.ownerName, p.project.slug)}">
Staff notes ${p.noteCount} </a></li>
</#if>
<#if request.headerData.globalPerm(Permission.ViewLogs)>
<li><a href="${routes.getRouteUrl("showLog", "", "", p.project.pluginId, "", "", "", "")}">
User Action Logs</a></li>
</#if>
<li><a href="https://papermc.io/forums/${p.project.ownerName}">Owner on forum <i class="fas fa-external-link-alt" aria-hidden="true"></i></a></li>
</ul>
</#if>
<#if request.headerData.globalPerm(Permission.ModNotesAndFlags)>
<li><a href="${Projects.showNotes(p.project.ownerName, p.project.slug)}">
Staff notes ${p.noteCount} </a></li>
</#if>
<#if request.headerData.globalPerm(Permission.ViewLogs)>
<li><a href="${routes.getRouteUrl("showLog", "", "", p.project.pluginId, "", "", "", "")}">
User Action Logs</a></li>
</#if>
<li><a href="https://papermc.io/forums/${p.project.ownerName}">Owner on forum <i class="fas fa-external-link-alt" aria-hidden="true"></i></a></li>
</ul>
</#if>
</div>
</#if>
</div>
</#if>
</div>
</div>
</div>
<!-- Nav -->
<div class="row row-nav">
<div class="col-md-12">
<div class="navbar navbar-default project-navbar pull-left">
<div class="navbar-inner">
<ul class="nav navbar-nav">
<!-- Tabs -->
<li id="docs" class="">
<a href="${Projects.show(p.project.ownerName, p.project.slug}">
<i class="fas fa-book"></i> <@spring.message "project.docs" /></a>
</li>
<!-- Nav -->
<div class="row row-nav">
<div class="col-md-12">
<div class="navbar navbar-default project-navbar pull-left">
<div class="navbar-inner">
<ul class="nav navbar-nav">
<!-- Tabs -->
<li id="docs" class="">
<a href="${Projects.show(p.project.ownerName, p.project.slug}">
<i class="fas fa-book"></i> <@spring.message "project.docs" /></a>
</li>
<li id="versions" class="">
<a href="${Versions.showList(
p.project.ownerName, p.project.slug)}">
<i class="fas fa-download"></i> <@spring.message "project.versions" />
</a>
</li>
<#if p.project.topicId??>
<li id="discussion" class="">
<a href="${Projects.showDiscussion(
<li id="versions" class="">
<a href="${Versions.showList(
p.project.ownerName, p.project.slug)}">
<i class="fas fa-users"></i> <@spring.message "project.discuss" />
<i class="fas fa-download"></i> <@spring.message "project.versions" />
</a>
</li>
</#if>
<#if sp.perms(Permission.EditProjectSettings)>
<#-- Show manager if permitted -->
<li id="settings" class="">
<a href="${Projects.showSettings(p.project.ownerName, p.project.slug)}">
<i class="fas fa-cog"></i> <@spring.message "project.settings" />
</a>
</li>
</#if>
<#if p.project.topicId??>
<li id="discussion" class="">
<a href="${Projects.showDiscussion(
p.project.ownerName, p.project.slug)}">
<i class="fas fa-users"></i> <@spring.message "project.discuss" />
</a>
</li>
</#if>
<#if p.project.settings.homepage??>
<#assign homepage>${p.project.settings.homepage}</#assign> <#-- move these assigns? -->
<li id="homepage">
<a title="${homepage}" target="_blank" rel="noopener"
href="<@hangar.linkout homepage/>">
<i class="fas fa-home"></i> Homepage <i class="fas fa-external-link-alt"></i></a>
</li>
</#if>
<#if sp.perms(Permission.EditProjectSettings)>
<#-- Show manager if permitted -->
<li id="settings" class="">
<a href="${Projects.showSettings(p.project.ownerName, p.project.slug)}">
<i class="fas fa-cog"></i> <@spring.message "project.settings" />
</a>
</li>
</#if>
<#if p.project.settings.issues??>
<#assign issues>${p.project.settings.issues}</#assign>
<li id="issues">
<a title="${issues}" target="_blank" rel="noopener"
href="<@hangar.linkout issues/>">
<i class="fas fa-bug"></i> Issues <i class="fas fa-external-link-alt"></i></a>
</li>
</#if>
<#if p.project.settings.homepage??>
<#assign homepage>${p.project.settings.homepage}</#assign> <#-- move these assigns? -->
<li id="homepage">
<a title="${homepage}" target="_blank" rel="noopener"
href="<@hangar.linkout homepage/>">
<i class="fas fa-home"></i> Homepage <i class="fas fa-external-link-alt"></i></a>
</li>
</#if>
<#if p.project.settings.source??>
<#assign source>${p.project.settings.source}</#assign>
<li id="source">
<a title="${source}" target="_blank" rel="noopener"
href="<@hangar.linkout source/>">
<i class="fas fa-code"></i> Source <i class="fas fa-external-link-alt"></i>
</a>
</li>
</#if>
<#if p.project.settings.issues??>
<#assign issues>${p.project.settings.issues}</#assign>
<li id="issues">
<a title="${issues}" target="_blank" rel="noopener"
href="<@hangar.linkout issues/>">
<i class="fas fa-bug"></i> Issues <i class="fas fa-external-link-alt"></i></a>
</li>
</#if>
<#if p.project.settings.support??>
<#assign support>${p.project.settings.support}</#assign>
<li id="support">
<a title="${support}" target="_blank" rel="noopener"
href="<@hangar.linkout support/>">
<i class="fas fa-question-circle"></i> Support <i class="fas fa-external-link-alt"></i>
</a>
</li>
</#if>
</ul>
<#if p.project.settings.source??>
<#assign source>${p.project.settings.source}</#assign>
<li id="source">
<a title="${source}" target="_blank" rel="noopener"
href="<@hangar.linkout source/>">
<i class="fas fa-code"></i> Source <i class="fas fa-external-link-alt"></i>
</a>
</li>
</#if>
<#if p.project.settings.support??>
<#assign support>${p.project.settings.support}</#assign>
<li id="support">
<a title="${support}" target="_blank" rel="noopener"
href="<@hangar.linkout support/>">
<i class="fas fa-question-circle"></i> Support <i class="fas fa-external-link-alt"></i>
</a>
</li>
</#if>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</@base.base>
<#nested>
</@base.base>
</#macro>

View File

@ -1,185 +1,198 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
<#import "*/layout/base.ftlh" as base />
<#import "*/utils/modal.ftlh" as modal />
<#import "*/utils/prompt.ftlh" as prompt />
<#import "*/utils/userAvatar.ftlh" as userAvatar />
<#--
@(u: UserData, o: Option[(OrganizationData, ScopedOrganizationData)], additionalScripts: Html = Html(""))(content: Html)(implicit messages: Messages, flash: Flash, request: OreRequest[_], config: OreConfig, assetsFinder: AssetsFinder)
-->
@canEditOrgSettings = @{
u.isOrga &&
o.exists { case (_, scopedData) =>
scopedData.permissions.has(Permission.EditOrganizationSettings)
}
}
<#assign scriptsVar>
<script type="text/javascript" src="<@hangar.url "javascripts/userPage.js" />"></script>
<script <#-- @CSPNonce.attr -->>
window.USERNAME ='${u.user.name}';
<#list Category.values as category> <#-- todo -->
CATEGORY_TITLE['${category.apiName}'] = '${category.title}';
CATEGORY_ICON['${category.apiName}'] = '${category.icon}';
</#list>
NO_ACTION_MESSAGE.starred = '<@spring.messageArgs "user.noStars" u.user.name />';
NO_ACTION_MESSAGE.watching = '<@spring.messageArgs "user.noWatching" u.user.name />';
</script>
</#assign>
<#macro view u o additionalScripts="">
@canEditOrgSettings = @{
u.isOrga &&
o.exists { case (_, scopedData) =>
scopedData.permissions.has(Permission.EditOrganizationSettings)
}
}
<@base.base title=u.user.name additionalScripts=scriptsVar>
<!-- Updated by JS -->
<div class="alert alert-success alert-dismissable" role="alert" style="display: none;">
<button type="button" class="close" data-dismiss="alert" aria-label="<@spring.message "general.close" />">
<span aria-hidden="true">&times;</span>
</button>
<strong>Success!</strong> <span class="success"></span>
</div>
<#assign scriptsVar>
<script type="text/javascript" src="<@hangar.url "javascripts/userPage.js" />"></script>
<script <#-- @CSPNonce.attr -->>
window.USERNAME ='${u.user.name}';
<#list Category.values as category> <#-- todo -->
CATEGORY_TITLE['${category.apiName}'] = '${category.title}';
CATEGORY_ICON['${category.apiName}'] = '${category.icon}';
</#list>
NO_ACTION_MESSAGE.starred = '<@spring.messageArgs "user.noStars" u.user.name />';
NO_ACTION_MESSAGE.watching = '<@spring.messageArgs "user.noWatching" u.user.name />';
</script>
</#assign>
<!-- Header -->
<div class="row user-header">
<div class="header-body">
<!-- Title -->
<span class="user-badge">
@userAvatar(
userName = u.user.name,
avatarUrl = u.user.avatarUrl,
clazz = "user-avatar-md" + (if (canEditOrgSettings) " organization-avatar" else ""))
<@base.base title=u.user.name additionalScripts=scriptsVar>
<!-- Updated by JS -->
<div class="alert alert-success alert-dismissable" role="alert" style="display: none;">
<button type="button" class="close" data-dismiss="alert" aria-label="<@spring.message "general.close" />">
<span aria-hidden="true">&times;</span>
</button>
<strong>Success!</strong> <span class="success"></span>
</div>
<#if canEditOrgSettings>
<div class="edit-avatar" style="display: none;">
<a href="${routes.Organizations.updateAvatar(u.user.name)}"><i class="fas fa-edit"></i> <@spring.message "user.editAvatar" /></a>
</div>
<!-- Header -->
<div class="row user-header">
<div class="header-body">
<!-- Title -->
<span class="user-badge">
<#assign avatarClass>
user-avatar-md <#if canEditOrgSettings>organization-avatar</#if>
</#assign>
<@userAvatar.userAvatar userName=u.user.name avatarUrl=u.user.avatarUrl clazz=avatarClass />
<#if !u.currentUser.readPrompts.contains(Prompt.ChangeAvatar)>
@prompt(Prompt.ChangeAvatar, "popover-avatar")
</#if>
</#if>
<#if canEditOrgSettings>
<div class="edit-avatar" style="display: none;">
<a href="${routes.Organizations.updateAvatar(u.user.name)}"><i class="fas fa-edit"></i> <@spring.message "user.editAvatar" /></a>
</div>
<span class="user-title">
<h1 class="username">
${u.user.name}
<#if u.isCurrent && !u.isOrga>
<a class="user-settings" href="@config.security.api.url/accounts/settings">
<i class="fas fa-cog" data-toggle="tooltip"
data-placement="top" title="Settings"></i>
</a>
<span data-toggle="modal" data-target="#modal-lock">
<i class="fas @{if (u.user.isLocked) "fa-lock" else "fa-unlock-alt"} action-lock-account" data-toggle="tooltip"
data-placement="top" title="<@spring.message "user.lock" />"></i>
</span>
<a class="action-api" href="${routes.getRouteUrl("users.editApiKeys", u.user.name)}">
<i class="fas fa-key" data-toggle="tooltip" data-placement="top" title="API Keys"></i>
</a>
<#if !u.currentUser.readPrompts.contains(Prompt.ChangeAvatar)>
@prompt(Prompt.ChangeAvatar, "popover-avatar")
</#if>
</#if>
<#if u.hasUser>
<#if u.userPerm.has(Permission.ModNotesAndFlags) || u.userPerm.has(Permission.Reviewer)>
<a class="user-settings" href="${routes.getRouteUrl("showActivities", u.user.name)}">
<i class="fas fa-calendar" data-toggle="tooltip"
data-placement="top" title="Activity"></i>
<span class="user-title">
<h1 class="username">
${u.user.name}
<#if u.isCurrent && !u.isOrga>
<a class="user-settings" href="@config.security.api.url/accounts/settings">
<i class="fas fa-cog" data-toggle="tooltip"
data-placement="top" title="Settings"></i>
</a>
<span data-toggle="modal" data-target="#modal-lock">
<i class="fas @{if (u.user.isLocked) "fa-lock" else "fa-unlock-alt"} action-lock-account" data-toggle="tooltip"
data-placement="top" title="<@spring.message "user.lock" />"></i>
</span>
<a class="action-api" href="${routes.getRouteUrl("users.editApiKeys", u.user.name)}">
<i class="fas fa-key" data-toggle="tooltip" data-placement="top" title="API Keys"></i>
</a>
</#if>
</#if>
<#if request.headerData.globalPerm(Permission.EditAllUserSettings)>
<a class="user-settings" href="${routes.getRouteUrl("userAdmin", u.user.name)}">
<i class="fas fa-wrench" data-toggle="tooltip"
data-placement="top" title="User Admin"></i>
</a>
</#if>
</h1>
<#if u.hasUser>
<#if u.userPerm.has(Permission.ModNotesAndFlags) || u.userPerm.has(Permission.Reviewer)>
<a class="user-settings" href="${routes.getRouteUrl("showActivities", u.user.name)}">
<i class="fas fa-calendar" data-toggle="tooltip"
data-placement="top" title="Activity"></i>
</a>
</#if>
</#if>
<div class="user-tag">
<i class="minor">
<#if u.user.tagline??>
${u.user.tagline.get}
<#elseif u.isCurrent || canEditOrgSettings>
Add a tagline
</#if>
</i>
<#if request.headerData.globalPerm(Permission.EditAllUserSettings)>
<a class="user-settings" href="${routes.getRouteUrl("userAdmin", u.user.name)}">
<i class="fas fa-wrench" data-toggle="tooltip"
data-placement="top" title="User Admin"></i>
</a>
</#if>
</h1>
<#if u.isCurrent || canEditOrgSettings>
<a href="#" data-toggle="modal" data-target="#modal-tagline">
<i class="fas fa-edit"></i>
</a>
</#if>
</div>
<div class="user-tag">
<i class="minor">
<#if u.user.tagline??>
${u.user.tagline.get}
<#elseif u.isCurrent || canEditOrgSettings>
Add a tagline
</#if>
</i>
<#if u.isCurrent || canEditOrgSettings>
<a href="#" data-toggle="modal" data-target="#modal-tagline">
<i class="fas fa-edit"></i>
</a>
</#if>
</div>
</span>
</span>
</span>
<!-- Roles -->
<ul class="user-roles">
@defining(u.globalRoles.toSeq.sortBy(_.permissions: Long).lastOption) { roleOpt =>
@roleOpt.map { role =>
<li class="user-role channel" style="background-color: ${role.color.hex}">${role.title}</li>
<!-- Roles -->
<ul class="user-roles">
@defining(u.globalRoles.toSeq.sortBy(_.permissions: Long).lastOption) { roleOpt =>
@roleOpt.map { role =>
<li class="user-role channel" style="background-color: ${role.color.hex}">${role.title}</li>
}
}
}
</ul>
</ul>
<div class="user-info">
<i class="minor">${u.projectCount}&nbsp;<#if u.projectCount == 1>project<#else>projects</#if></i><br/>
<i class="minor">
@messages(
"user.memberSince",
u.user.joinDate.map(prettifyDate)!prettifyDate(u.user.createdAt))
</i><br/>
<a href="https://papermc.io/forums/users/${u.user.name}">
<@spring.message "user.viewOnForums" /> <i class="fas fa-external-link-alt"></i>
</a>
</div>
</div>
</div>
@content
@modal("modal-lock", "label-lock", if (u.user.isLocked) "user.unlock" else "user.lock") {
<div class="modal-body">
<p class="minor">
<#if u.user.isLocked>
<@spring.message "user.unlock.confirm" />
<#else>
<@spring.message "user.lock.confirm" />
</#if>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><@spring.message "general.close" /></button>
@form(action = routes.Users.verify(Some(routes.Users.setLocked(
user = u.user.name,
locked = !u.user.isLocked,
sso = None,
sig = None
).path())), Symbol("class") -> "form-inline") {
@CSRF.formField
<button type="submit" class="btn btn-primary"><@spring.message "general.continue" /></button>
}
</div>
}
@modal("modal-tagline", "label-tagline", "user.tagline.edit") {
@form(action = routes.Users.saveTagline(u.user.name)) {
@CSRF.formField
<div class="modal-body">
<div class="setting setting-no-border">
<div class="setting-description">
<h4><@spring.message "user.tagline" /></h4>
<p><@spring.message "user.tagline.info" /></p>
</div>
<input class="form-control" type="text" value="${u.user.tagline!""}" id="tagline"
name="tagline" maxlength="${config.ore.users.maxTaglineLen}" />
<div class="user-info">
<i class="minor">${u.projectCount}&nbsp;<#if u.projectCount == 1>project<#else>projects</#if></i><br/>
<i class="minor">
@messages(
"user.memberSince",
u.user.joinDate.map(prettifyDate)!prettifyDate(u.user.createdAt))
</i><br/>
<a href="https://papermc.io/forums/users/${u.user.name}">
<@spring.message "user.viewOnForums" /> <i class="fas fa-external-link-alt"></i>
</a>
</div>
<div class="clearfix"></div>
</div>
</div>
@content
<#assign lockModalTitle>
<#if u.user.isLocked>
user.unlock
<#else>
user.lock
</#if>
</#assign>
<@modal.modal lockModalTitle "modal-lock" "label-lock">
<div class="modal-body">
<p class="minor">
<#if u.user.isLocked>
<@spring.message "user.unlock.confirm" />
<#else>
<@spring.message "user.lock.confirm" />
</#if>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "general.close" />
</button>
<input type="submit" value="<@spring.message "general.save" />" class="btn btn-primary" />
<button type="button" class="btn btn-default" data-dismiss="modal"><@spring.message "general.close" /></button>
@form(action = routes.Users.verify(Some(routes.Users.setLocked(
user = u.user.name,
locked = !u.user.isLocked,
sso = None,
sig = None
).path())), Symbol("class") -> "form-inline") {
@CSRF.formField
<button type="submit" class="btn btn-primary"><@spring.message "general.continue" /></button>
}
</div>
}
}
</@base.base>
</@modal.modal>
<@modal.modal "user.tagline.edit" "modal-tagline" "label-tagline">
@form(action = routes.Users.saveTagline(u.user.name)) {
@CSRF.formField
<div class="modal-body">
<div class="setting setting-no-border">
<div class="setting-description">
<h4><@spring.message "user.tagline" /></h4>
<p><@spring.message "user.tagline.info" /></p>
</div>
<input class="form-control" type="text" value="${u.user.tagline!""}" id="tagline"
name="tagline" maxlength="${config.ore.users.maxTaglineLen}" />
</div>
<div class="clearfix"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
<@spring.message "general.close" />
</button>
<input type="submit" value="<@spring.message "general.save" />" class="btn btn-primary" />
</div>
}
</@modal.modal>
</@base.base>
</#macro>

View File

@ -1,21 +1,19 @@
<#import "/spring.ftl" as spring />
<#import "*/utils/hangar.ftlh" as hangar />
@(id: String = "",
label: String = "",
titleId: String)(content: Html)(implicit messages: Messages)
<div class="modal fade" id="${id}" tabindex="-1" role="dialog" aria-labelledby="${label}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="<@spring.message "general.close" />">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><@spring.message titleId /></h4>
<#macro modal titleId id="" label="">
<div class="modal fade" id="${id}" tabindex="-1" role="dialog" aria-labelledby="${label}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="<@spring.message "general.close" />">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><@spring.message titleId /></h4>
</div>
<#nested>
</div>
${content}
</div>
</div>
</div>
</#macro>