mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-01 15:17:07 +08:00
Replace some optional usage
This commit is contained in:
parent
3ab43a8c19
commit
53babc212a
@ -53,9 +53,4 @@
|
||||
* [ ] email
|
||||
* [ ] modal
|
||||
* [ ] prompt
|
||||
* [ ] userAvatar
|
||||
|
||||
---
|
||||
Notes to self (or anyone if they want to jump at it)
|
||||
* Search for `.isDefined`/`.get`/`.orElse` optional usage (left some behind, `x.orElse(y)` -> `x!y`)
|
||||
* `prettifyDateAndTime(x)` -> `x?string.long`
|
||||
* [ ] userAvatar
|
@ -46,7 +46,7 @@
|
||||
<tr>
|
||||
<td>${by}</td>
|
||||
<td>${flag.reason}, ${flag.comment}</td>
|
||||
<td>${prettifyDateAndTime(flag.createdAt)}</td>
|
||||
<td>${flag.createdAt?string.long}</td>
|
||||
<#if flag.isResolved>
|
||||
<td>${resolvedBy.get}
|
||||
at ${(flag.resolvedAt!OffsetDateTime.MIN)?string.long}</td>
|
||||
|
@ -29,14 +29,14 @@ Discussion page within Project overview.
|
||||
|
||||
<div id='discourse-comments'></div>
|
||||
<div class="row">
|
||||
<#if request.headerData.currentUser.isDefined>
|
||||
<#if request.headerData.currentUser??>
|
||||
<div class="col-md-8">
|
||||
<div class="reply-box">
|
||||
<#if sp.canPostAsOwnerOrga>
|
||||
<div class="pull-right push-down">
|
||||
<i class="minor"><@spring.message "project.discuss.postAs" /></i>
|
||||
<select name="poster" form="form-editor-save">
|
||||
<option selected>${request.headerData.currentUser.get.name}</option>
|
||||
<option selected>${request.headerData.currentUser.name}</option>
|
||||
<option>${p.projectOwner.name}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
@ -22,10 +22,10 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="setting-content">
|
||||
<select class="form-control" id="category" name="category" form="@form">
|
||||
<select class="form-control" id="category" name="category" form="${form}">
|
||||
<#list Category.values as category>
|
||||
<#if category.isVisible>
|
||||
<option <#if selected.isDefined && selected.get.equals(category)> selected </#if> >
|
||||
<option <#if selected?? && selected.equals(category)> selected </#if> >
|
||||
${category.title}
|
||||
</option>
|
||||
</#if>
|
||||
@ -55,7 +55,7 @@
|
||||
to gather information about your project.
|
||||
</p>
|
||||
</div>
|
||||
<input <#if homepage.isDefined> value="${homepage.get}" </#if> form="@form" type="url" class="form-control" id="homepage"
|
||||
<input <#if homepage??> value="${homepage}" </#if> form="${form}" type="url" class="form-control" id="homepage"
|
||||
name="homepage" placeholder="https://papermc.io" />
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
@ -68,7 +68,7 @@
|
||||
track bugs.
|
||||
</p>
|
||||
</div>
|
||||
<input <#if issues.isDefined> value="${issues.get}" </#if> form="@form" type="url" class="form-control" id="issues"
|
||||
<input <#if issues??> value="${issues}" </#if> form="${form}" type="url" class="form-control" id="issues"
|
||||
name="issues" placeholder="https://github.com/MiniDigger/Hangar/issues" />
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
@ -78,7 +78,7 @@
|
||||
<h4>Source code <i>(optional)</i></h4>
|
||||
<p>Support the community of developers by making your project open source!</p>
|
||||
</div>
|
||||
<input <#if source.isDefined> value="@source.get" </#if> form="@form" type="url" class="form-control" id="source"
|
||||
<input <#if source??> value="${source}" </#if> form="${form}" type="url" class="form-control" id="source"
|
||||
name="source" placeholder="https://github.com/MiniDigger/Hangar" />
|
||||
</div>
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
somewhere else.
|
||||
</p>
|
||||
</div>
|
||||
<input <#if support.isDefined> value="${support.get}" </#if> form="@form" type="url" class="form-control" id="support"
|
||||
<input <#if support??> value="${support}" </#if> form="${form}" type="url" class="form-control" id="support"
|
||||
name="support" placeholder="https://discord.gg/papermc" />
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
@ -104,11 +104,11 @@
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default btn-license dropdown-toggle" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">
|
||||
<span class="license">${licenseName.getOrElse(messages("licenses.mit"))}</span>
|
||||
<span class="license">${licenseName!messages("licenses.mit")}</span>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<input type="text" class="form-control" style="display: none;" name="license-name" form="@form"
|
||||
value="@licenseName.getOrElse(messages("licenses.mit"))" />
|
||||
<input type="text" class="form-control" style="display: none;" name="license-name" form="${form}"
|
||||
value="${licenseName!messages("licenses.mit")}" />
|
||||
<ul class="dropdown-menu dropdown-license">
|
||||
<li><a><@spring.message "licenses.mit" /></a></li>
|
||||
<li><a><@spring.message "licenses.apache2.0" /></a></li>
|
||||
@ -118,8 +118,8 @@
|
||||
<li><a class="license-custom"><@spring.message "licenses.custom" />…</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<input type="text" name="license-url" class="form-control" form="@form"
|
||||
placeholder="https://github.com/MiniDigger/Hangar/LICENSE.txt" value="@licenseUrl">
|
||||
<input type="text" name="license-url" class="form-control" form="${form}"
|
||||
placeholder="https://github.com/MiniDigger/Hangar/LICENSE.txt" value="${licenseUrl}">
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
@ -42,7 +42,7 @@
|
||||
<span>@Html(messages("version.create.info", projectName, pluginId))</span>
|
||||
</div>
|
||||
|
||||
<#if pending.isDefined>
|
||||
<#if pending??>
|
||||
@* Show plugin meta *@
|
||||
@defining(pending.get) { version: PendingVersion =>
|
||||
<div class="plugin-meta">
|
||||
@ -57,7 +57,7 @@
|
||||
@version.description.map { description =>
|
||||
${description}
|
||||
}.getOrElse {
|
||||
${projectDescription.getOrElse(messages("version.create.noDescription"))}
|
||||
${projectDescription!messages("version.create.noDescription")}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
@ -138,7 +138,7 @@
|
||||
@editor(
|
||||
savable = false,
|
||||
enabled = true,
|
||||
raw = version.description.getOrElse(""),
|
||||
raw = version.description!"",
|
||||
cancellable = false,
|
||||
targetForm = "form-publish"
|
||||
)
|
||||
@ -156,10 +156,10 @@
|
||||
<@spring.message "version.create.selectFile" />
|
||||
</label>
|
||||
|
||||
@projects.helper.alertFile()
|
||||
${projects.helper.alertFile()}
|
||||
}
|
||||
|
||||
<#if pending.isDefined>
|
||||
<#if pending??>
|
||||
@* Ready to go! *@
|
||||
@defining(pending.get) { version: PendingVersion =>
|
||||
@form(action = routes.getRouteUrl("versions.publish",
|
||||
@ -181,14 +181,14 @@
|
||||
</div>
|
||||
<span class="pull-left tos"><i>@Html(messages("version.create.tos", "#"))</i></span>
|
||||
</div>
|
||||
<#if pending.isDefined>
|
||||
@projects.helper.createSteps(2)
|
||||
<#if pending??>
|
||||
${projects.helper.createSteps(2)}
|
||||
<#else>
|
||||
@projects.helper.createSteps(1)
|
||||
${projects.helper.createSteps(1)}
|
||||
</#if>
|
||||
|
||||
</div>
|
||||
|
||||
@projects.channels.helper.modalManage()
|
||||
${projects.channels.helper.modalManage()}
|
||||
|
||||
</@base.base>
|
||||
|
@ -42,10 +42,10 @@
|
||||
@visibilityChanges.reverse.map { case (entry, createdBy) =>
|
||||
<tr>
|
||||
<td>${entry.visibility}</td>
|
||||
<td>${prettifyDateAndTime(entry.createdAt)}</td>
|
||||
<td>${entry.createdAt?string.long}</td>
|
||||
<td>${entry.obj.render}</td>
|
||||
<#if createdBy.isDefined>
|
||||
<td>${createdBy.get.name}</td>
|
||||
<#if createdBy??>
|
||||
<td>${createdBy.name}</td>
|
||||
<#else>
|
||||
<td>Unknown</td>
|
||||
</#if>
|
||||
|
@ -169,7 +169,7 @@
|
||||
v.p.project.ownerName, v.p.project.slug, v.v.versionString
|
||||
),
|
||||
enabled = sp.perms(Permission.EditPage),
|
||||
raw = v.v.description.getOrElse(""),
|
||||
raw = v.v.description!"",
|
||||
cooked = v.v.obj.render,
|
||||
subject = "Version"
|
||||
)
|
||||
@ -200,9 +200,9 @@
|
||||
|
||||
@v.filteredDependencies.map { case (depend, project)=>
|
||||
<li class="list-group-item">
|
||||
<#if project.isDefined>
|
||||
<a href="${routes.getRouteUrl("projects.show", project.get.ownerName, project.get.slug)}">
|
||||
<strong>${project.get.name}</strong>
|
||||
<#if project??>
|
||||
<a href="${routes.getRouteUrl("projects.show", project.ownerName, project.slug)}">
|
||||
<strong>${project.name}</strong>
|
||||
</a>
|
||||
<#else>
|
||||
<div class="minor">
|
||||
|
@ -21,8 +21,6 @@ Base template for Project overview.
|
||||
request: OreRequest[_], flash: Flash, config: OreConfig, renderer: MarkdownRenderer, assetsFinder: AssetsFinder)
|
||||
-->
|
||||
|
||||
<#assign appRoutes>${controllers.routes.Application}</#assign>
|
||||
|
||||
<#assign scriptsVar>
|
||||
<script type="text/javascript" src="<@hangar.url "javascripts/projectDetail.js" />"></script>
|
||||
<script type="text/javascript" src="<@hangar.url "javascripts/pageEdit.js" />"></script>
|
||||
@ -121,7 +119,7 @@ Base template for Project overview.
|
||||
</#if>
|
||||
|
||||
<!-- Flag button -->
|
||||
<#if request.hasUser && !request.currentUser.get.name.equals(p.project.ownerName)
|
||||
<#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">
|
||||
@ -188,7 +186,7 @@ Base template for Project overview.
|
||||
Staff notes ${p.noteCount} </a></li>
|
||||
</#if>
|
||||
<#if request.headerData.globalPerm(Permission.ViewLogs)>
|
||||
<li><a href="${appRoutes.showLog(None, None, Some(p.project.pluginId), None, None, None, None)}">
|
||||
<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>
|
||||
@ -218,7 +216,7 @@ Base template for Project overview.
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<#if p.project.topicId.isDefined>
|
||||
<#if p.project.topicId??>
|
||||
<li id="discussion" class="">
|
||||
<a href="${Projects.showDiscussion(
|
||||
p.project.ownerName, p.project.slug)}">
|
||||
|
@ -74,8 +74,8 @@
|
||||
<span class="channel" style="background-color: ${entry.channelColor.hex}">${entry.channelName}</span>
|
||||
</td>
|
||||
<td>
|
||||
<#if entry.versionAuthor.isDefined>
|
||||
<a href="https://papermc.io/forums/users/@entry.versionAuthor.get">
|
||||
<#if entry.versionAuthor??>
|
||||
<a href="https://papermc.io/forums/users/${entry.versionAuthor}">
|
||||
${entry.versionAuthor}
|
||||
</a>
|
||||
<#else>
|
||||
@ -163,7 +163,7 @@
|
||||
<span class="channel" style="background-color: ${entry.channelColor.hex};">${entry.channelName}</span>
|
||||
</td>
|
||||
<td>
|
||||
<#if entry.versionAuthor.isDefined>
|
||||
<#if entry.versionAuthor??>
|
||||
<a href="https://papermc.io/forums/users/${entry.versionAuthor}">
|
||||
${entry.versionAuthor}
|
||||
</a>
|
||||
|
@ -40,8 +40,8 @@
|
||||
<a href="${routes.getRouteUrl("versions.downloadJar", project.ownerName, project.slug, version.versionString, "")}" class="btn btn-info">Download File</a>
|
||||
</span>
|
||||
<span class="btn-group-sm">
|
||||
<#if mostRecentUnfinishedReview.isDefined>
|
||||
<#if request.headerData.isCurrentUser(mostRecentUnfinishedReview.get.userId)>
|
||||
<#if mostRecentUnfinishedReview??>
|
||||
<#if request.headerData.isCurrentUser(mostRecentUnfinishedReview.userId)>
|
||||
<button class="btn btn-review-stop btn-danger"><i class="fas fa-stop-circle"></i> <@spring.message "review.stop" /></button>
|
||||
<button class="btn btn-review-approve btn-success"><i class="fas fa-thumbs-up"></i> <@spring.message "user.queue.approve" /></button>
|
||||
<button class="btn btn-review-approve-partial btn-success"><i class="fas fa-thumbs-up"></i> <@spring.message "user.queue.approvePartial" /></button>
|
||||
@ -62,8 +62,8 @@
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
<#if mostRecentUnfinishedReview.isDefined>
|
||||
<#if request.headerData.isCurrentUser(mostRecentUnfinishedReview.get.userId)>
|
||||
<#if mostRecentUnfinishedReview??>
|
||||
<#if request.headerData.isCurrentUser(mostRecentUnfinishedReview.userId)>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="input-group" style="width: 100%;
|
||||
@ -93,19 +93,19 @@
|
||||
<tbody>
|
||||
@reviews.reverse.zipWithIndex.map { case (t, index) =>
|
||||
@defining((t._1, t._2)) { case (item, name) =>
|
||||
<#if item.endedAt.isDefined>
|
||||
<#if item.endedAt??>
|
||||
<#if reviews.size > (reviews.size - index)>
|
||||
<#if (item.endedAt?string.long).equalsIgnoreCase(reviews.reverse(reviews.size - index - 1)._1.createdAt?string.long)>
|
||||
<tr>
|
||||
<td>${item.endedAt?string.long}</td>
|
||||
<td>
|
||||
<strong>@name.getOrElse("Unknown")</strong>
|
||||
<strong>${name!"Unknown"}</strong>
|
||||
took over from
|
||||
<strong>@name.getOrElse("Unknown")</strong>
|
||||
<strong>${name!"Unknown"}</strong>
|
||||
<#if !item.decodeMessages.exists(_.isTakeover)>
|
||||
<i>- no message provided -</i>
|
||||
<#else>
|
||||
<i>@item.decodeMessages.filter(_.isTakeover).head.render</i>
|
||||
<i>${item.decodeMessages.filter(_.isTakeover).head.render}</i>
|
||||
</#if>
|
||||
</td>
|
||||
</tr>
|
||||
@ -116,7 +116,7 @@
|
||||
</tr>
|
||||
</#if>
|
||||
<#else>
|
||||
<#if version.approvedAt.isDefined>
|
||||
<#if version.approvedAt??>
|
||||
<tr>
|
||||
<td>${item.endedAt?string.long}</td>
|
||||
<td><strong>${name!"Unknown"}</strong> approved</td>
|
||||
|
@ -83,7 +83,7 @@
|
||||
}
|
||||
<#else>
|
||||
@panel("Members") {
|
||||
@roleTable[Model[User], OrganizationUserRole]("User", "memberRole", withOwner = false, orga.get.members.map(t => (t._2, t._1, null)).toSet, orgRoles) { (user, _) =>
|
||||
@roleTable[Model[User], OrganizationUserRole]("User", "memberRole", withOwner = false, orga.members.map(t => (t._2, t._1, null)).toSet, orgRoles) { (user, _) =>
|
||||
<a href="${routes.getRouteUrl("userAdmin", user.name)}">
|
||||
${user.name}
|
||||
</a>
|
||||
|
@ -49,7 +49,7 @@
|
||||
</td>
|
||||
<td <#if isActiveSort(UserOrdering.Projects)>class="user-sort"</#if> data-list="authors" >
|
||||
Projects
|
||||
<#if isActiveSort(UserOrdering.Projects)><i class="o fas fa-@direction"></i></#if>
|
||||
<#if isActiveSort(UserOrdering.Projects)><i class="o fas fa-${direction}"></i></#if>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -62,19 +62,19 @@
|
||||
</td>
|
||||
<td>
|
||||
@optDonorRole.map { role =>
|
||||
<span class="channel channel-sm" style="background-color: @role.color.hex">
|
||||
<span class="channel channel-sm" style="background-color: ${role.color.hex}">
|
||||
@role.title
|
||||
</span>
|
||||
}
|
||||
@optRole.map { role =>
|
||||
<span class="user-role channel" style="background-color: @role.color.hex">
|
||||
<span class="user-role channel" style="background-color: ${role.color.hex}">
|
||||
@role.title
|
||||
</span>
|
||||
}
|
||||
|
||||
</td>
|
||||
<td>@prettifyDate(joinDate.getOrElse(createdAt))</td>
|
||||
<td>@projectCount</td>
|
||||
<td>@prettifyDate(joinDate!createdAt)</td>
|
||||
<td>${projectCount}</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
|
||||
<ul class="list-group">
|
||||
@notifications.map { case (notification, origin) =>
|
||||
<li class="list-group-item notification" data-action="@notification.action.getOrElse("none")"
|
||||
<li class="list-group-item notification" data-action="${notification.action!"none"}"
|
||||
data-id="@notification.id">
|
||||
@origin.map { origin =>
|
||||
@userAvatar(Some(origin.name), origin.avatarUrl, clazz = "user-avatar-s")
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
<#macro scripts>
|
||||
<script type="text/javascript" src="<@hangar.url "build/user-profile.js" />"></script>
|
||||
<#if u.isOrga && o.isDefined && canEditOrgMembers>
|
||||
<#if u.isOrga && o?? && canEditOrgMembers>
|
||||
<script type="text/javascript" src="<@hangar.url "javascripts/orgInvites.js" />"></script>
|
||||
</#if>
|
||||
<script type="text/javascript" src="<@hangar.url "javascripts/userSearch.js" />"></script>
|
||||
@ -35,14 +35,14 @@
|
||||
<div id="user-profile"></div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<#if u.isOrga && o.isDefined && canEditOrgMembers>
|
||||
<#if u.isOrga && o?? && canEditOrgMembers>
|
||||
<div class="panel-user-info panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><@spring.message "project.manager" /></h3>
|
||||
</div>
|
||||
<table class="table panel-body">
|
||||
<tbody>
|
||||
@o.get._1.projectRoles.map { case (role, project) =>
|
||||
@o._1.projectRoles.map { case (role, project) =>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="${routes.getRouteUrl("projects.show", project.ownerName, project.slug)}">${project.ownerName}/${project.slug}</a>
|
||||
|
@ -53,7 +53,7 @@
|
||||
${user.role.title}
|
||||
</span>
|
||||
</td>
|
||||
<td>@prettifyDate(joinDate.getOrElse(createdAt))</td>
|
||||
<td>@prettifyDate(joinDate!createdAt)</td>
|
||||
</tr>
|
||||
</#list>
|
||||
|
||||
|
@ -50,7 +50,7 @@ scopedData.permissions.has(Permission.EditOrganizationSettings)
|
||||
<a href="${routes.Organizations.updateAvatar(u.user.name)}"><i class="fas fa-edit"></i> <@spring.message "user.editAvatar" /></a>
|
||||
</div>
|
||||
|
||||
<#if !u.currentUser.get.readPrompts.contains(Prompt.ChangeAvatar)>
|
||||
<#if !u.currentUser.readPrompts.contains(Prompt.ChangeAvatar)>
|
||||
@prompt(Prompt.ChangeAvatar, "popover-avatar")
|
||||
</#if>
|
||||
</#if>
|
||||
@ -94,8 +94,8 @@ scopedData.permissions.has(Permission.EditOrganizationSettings)
|
||||
|
||||
<div class="user-tag">
|
||||
<i class="minor">
|
||||
<#if u.user.tagline.isDefined>
|
||||
@u.user.tagline.get
|
||||
<#if u.user.tagline??>
|
||||
${u.user.tagline.get}
|
||||
<#elseif u.isCurrent || canEditOrgSettings>
|
||||
Add a tagline
|
||||
</#if>
|
||||
@ -114,17 +114,17 @@ scopedData.permissions.has(Permission.EditOrganizationSettings)
|
||||
<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>
|
||||
<li class="user-role channel" style="background-color: ${role.color.hex}">${role.title}</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
|
||||
<div class="user-info">
|
||||
<i class="minor">@u.projectCount <#if u.projectCount == 1>project<#else>projects</#if></i><br/>
|
||||
<i class="minor">${u.projectCount} <#if u.projectCount == 1>project<#else>projects</#if></i><br/>
|
||||
<i class="minor">
|
||||
@messages(
|
||||
"user.memberSince",
|
||||
u.user.joinDate.map(prettifyDate).getOrElse(prettifyDate(u.user.createdAt)))
|
||||
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>
|
||||
@ -169,8 +169,8 @@ scopedData.permissions.has(Permission.EditOrganizationSettings)
|
||||
<h4><@spring.message "user.tagline" /></h4>
|
||||
<p><@spring.message "user.tagline.info" /></p>
|
||||
</div>
|
||||
<input class="form-control" type="text" value="@u.user.tagline.getOrElse("")" id="tagline"
|
||||
name="tagline" maxlength="@config.ore.users.maxTaglineLen" />
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user