文件
halo-theme/templates/modules/activity-bar.html
T
admin 4a06992715
Theme CD / Package Theme (release) Successful in 30s
Theme CD / Release (release) Successful in 8s
refactor(theme): enhance link resolution logic for archives, categories, and tags
2026-06-16 18:12:06 +08:00

227 行
13 KiB
HTML

<aside class="devcm-activity" th:fragment="activity-bar (pageType)" th:aria-label="#{devcm.activity.aria}">
<span class="devcm-activity__icon-bank" aria-hidden="true">
<i class="i-pixelarticons-folder"></i>
<i class="i-pixelarticons-search"></i>
<i class="i-pixelarticons-archive"></i>
<i class="i-pixelarticons-script-text"></i>
<i class="i-pixelarticons-label"></i>
<i class="i-pixelarticons-user"></i>
<i class="i-radix-icons-gear"></i>
<i class="i-pixelarticons-git-branch"></i>
<i class="i-pixelarticons-git-commit"></i>
<i class="i-pixelarticons-git-merge"></i>
<i class="i-pixelarticons-git-pull-request"></i>
<i class="i-pixelarticons-github"></i>
</span>
<th:block
th:with="items=${theme.config.activity.activity_items},
archiveActivityItem=${items != null and !#lists.isEmpty(items) ? items.^[type == 'archive' or key == 'archive'] : null},
categoriesActivityItem=${items != null and !#lists.isEmpty(items) ? items.^[type == 'categories' or key == 'categories'] : null},
tagsActivityItem=${items != null and !#lists.isEmpty(items) ? items.^[type == 'tags' or key == 'tags'] : null},
activityArchiveHref=${!#strings.isEmpty(site.routes.archivesUri) ? site.routes.archivesUri : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.url) ? archiveActivityItem.url : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.href) ? archiveActivityItem.href : '/archives'))},
activityCategoriesHref=${!#strings.isEmpty(site.routes.categoriesUri) ? site.routes.categoriesUri : (categoriesActivityItem != null and !#strings.isEmpty(categoriesActivityItem.url) ? categoriesActivityItem.url : (categoriesActivityItem != null and !#strings.isEmpty(categoriesActivityItem.href) ? categoriesActivityItem.href : '/categories'))},
activityTagsHref=${!#strings.isEmpty(site.routes.tagsUri) ? site.routes.tagsUri : (tagsActivityItem != null and !#strings.isEmpty(tagsActivityItem.url) ? tagsActivityItem.url : (tagsActivityItem != null and !#strings.isEmpty(tagsActivityItem.href) ? tagsActivityItem.href : '/tags'))}"
>
<div class="devcm-activity__group devcm-activity__group--up">
<th:block th:if="${items != null and !#lists.isEmpty(items)}">
<th:block
th:each="item : ${items}"
th:with="placement=${#strings.isEmpty(item.position) ? 'up' : item.position},
itemType=${!#strings.isEmpty(item.type) ? item.type : (!#strings.isEmpty(item.key) ? item.key : 'custom')},
entryAction=${itemType == 'search' or item.action == 'search' ? 'search' : 'link'},
entryConfiguredHref=${!#strings.isEmpty(item.url) ? item.url : (!#strings.isEmpty(item.href) ? item.href : '#')},
entryHref=${entryAction == 'search' ? '#' : (itemType == 'archive' ? activityArchiveHref : (itemType == 'categories' ? activityCategoriesHref : (itemType == 'tags' ? activityTagsHref : entryConfiguredHref)))},
entryLabel=${!#strings.isEmpty(item.label) ? item.label : (!#strings.isEmpty(item.labelKey) ? #messages.msg(item.labelKey) : #messages.msg('devcm.activity.link'))}"
>
<a
class="devcm-activity__button"
th:if="${placement != 'down' and itemType != 'login' and itemType != 'git' and (item.enabled == null or item.enabled == true or item.enabled == 'true') and (entryAction != 'search' or pluginFinder.available('PluginSearchWidget'))}"
th:classappend="${(!#strings.isEmpty(item.activeTypes) and #strings.contains(',' + item.activeTypes + ',', ',' + pageType + ',')) or (itemType == 'home' and pageType == 'home') or (itemType == 'archive' and (pageType == 'archive' or pageType == 'post')) or (itemType == 'categories' and (pageType == 'categories' or pageType == 'category')) or (itemType == 'tags' and (pageType == 'tags' or pageType == 'tag'))} ? ' devcm-activity__button--active' : ''"
th:href="${entryHref}"
th:target="${item.external == true or item.external == 'true'} ? '_blank' : null"
th:rel="${item.external == true or item.external == 'true'} ? 'noopener noreferrer' : null"
th:title="${entryLabel}"
th:attr="data-label=${entryLabel},aria-label=${entryLabel},data-devcm-action=${entryAction}"
>
<i th:class="|i-pixelarticons-${!#strings.isEmpty(item.icon) ? item.icon : 'file'}|"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAnonymous()"
th:if="${placement != 'down' and itemType == 'login' and (item.enabled == null or item.enabled == true or item.enabled == 'true')}"
th:href="${entryHref}"
th:target="${item.external == true or item.external == 'true'} ? '_blank' : null"
th:rel="${item.external == true or item.external == 'true'} ? 'noopener noreferrer' : null"
th:title="${entryLabel}"
th:attr="data-label=${entryLabel},aria-label=${entryLabel},data-devcm-action=${entryAction}"
>
<i class="i-pixelarticons-user"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAuthenticated()"
th:if="${placement != 'down' and itemType == 'login' and (item.enabled == null or item.enabled == true or item.enabled == 'true')}"
href="/console"
th:title="#{devcm.activity.console}"
th:attr="data-label=#{devcm.activity.console},aria-label=#{devcm.activity.console},data-devcm-action='link'"
>
<i class="i-radix-icons-gear"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAuthenticated()"
th:if="${placement != 'down' and itemType == 'login' and (item.enabled == null or item.enabled == true or item.enabled == 'true')}"
href="/logout"
th:title="#{devcm.activity.logout}"
th:attr="data-label=#{devcm.activity.logout},aria-label=#{devcm.activity.logout},data-devcm-action='link'"
>
<i class="i-pixelarticons-user"></i>
</a>
</th:block>
</th:block>
<th:block th:if="${items == null or #lists.isEmpty(items)}">
<a
class="devcm-activity__button"
th:classappend="${pageType == 'home'} ? ' devcm-activity__button--active' : ''"
href="/"
th:title="#{devcm.activity.explorer}"
th:attr="data-label=#{devcm.activity.explorer},aria-label=#{devcm.activity.explorer}"
>
<i class="i-pixelarticons-folder"></i>
</a>
<a
class="devcm-activity__button"
th:if="${pluginFinder.available('PluginSearchWidget')}"
href="#"
data-devcm-action="search"
th:title="#{devcm.activity.search}"
th:attr="data-label=#{devcm.activity.search},aria-label=#{devcm.activity.search}"
>
<i class="i-pixelarticons-search"></i>
</a>
<a
class="devcm-activity__button"
th:classappend="${pageType == 'archive' or pageType == 'post'} ? ' devcm-activity__button--active' : ''"
href="#"
th:href="${activityArchiveHref}"
th:title="#{devcm.activity.archive}"
th:attr="data-label=#{devcm.activity.archive},aria-label=#{devcm.activity.archive}"
>
<i class="i-pixelarticons-archive"></i>
</a>
<a
class="devcm-activity__button"
th:classappend="${pageType == 'categories' or pageType == 'category'} ? ' devcm-activity__button--active' : ''"
href="#"
th:href="${activityCategoriesHref}"
th:title="#{devcm.activity.categories}"
th:attr="data-label=#{devcm.activity.categories},aria-label=#{devcm.activity.categories}"
>
<i class="i-pixelarticons-script-text"></i>
</a>
<a
class="devcm-activity__button"
th:classappend="${pageType == 'tags' or pageType == 'tag'} ? ' devcm-activity__button--active' : ''"
href="#"
th:href="${activityTagsHref}"
th:title="#{devcm.activity.tags}"
th:attr="data-label=#{devcm.activity.tags},aria-label=#{devcm.activity.tags}"
>
<i class="i-pixelarticons-label"></i>
</a>
</th:block>
</div>
<div class="devcm-activity__group devcm-activity__group--down">
<th:block th:if="${items != null and !#lists.isEmpty(items)}">
<th:block
th:each="item : ${items}"
th:with="placement=${#strings.isEmpty(item.position) ? 'up' : item.position},
itemType=${!#strings.isEmpty(item.type) ? item.type : (!#strings.isEmpty(item.key) ? item.key : 'custom')},
entryAction=${itemType == 'search' or item.action == 'search' ? 'search' : 'link'},
entryConfiguredHref=${!#strings.isEmpty(item.url) ? item.url : (!#strings.isEmpty(item.href) ? item.href : '#')},
entryHref=${entryAction == 'search' ? '#' : (itemType == 'archive' ? activityArchiveHref : (itemType == 'categories' ? activityCategoriesHref : (itemType == 'tags' ? activityTagsHref : entryConfiguredHref)))},
entryLabel=${!#strings.isEmpty(item.label) ? item.label : (!#strings.isEmpty(item.labelKey) ? #messages.msg(item.labelKey) : #messages.msg('devcm.activity.link'))}"
>
<a
class="devcm-activity__button"
th:if="${placement == 'down' and itemType != 'login' and itemType != 'git' and (item.enabled == null or item.enabled == true or item.enabled == 'true') and (entryAction != 'search' or pluginFinder.available('PluginSearchWidget'))}"
th:classappend="${(!#strings.isEmpty(item.activeTypes) and #strings.contains(',' + item.activeTypes + ',', ',' + pageType + ',')) or (itemType == 'home' and pageType == 'home') or (itemType == 'archive' and (pageType == 'archive' or pageType == 'post')) or (itemType == 'categories' and (pageType == 'categories' or pageType == 'category')) or (itemType == 'tags' and (pageType == 'tags' or pageType == 'tag'))} ? ' devcm-activity__button--active' : ''"
th:href="${entryHref}"
th:target="${item.external == true or item.external == 'true'} ? '_blank' : null"
th:rel="${item.external == true or item.external == 'true'} ? 'noopener noreferrer' : null"
th:title="${entryLabel}"
th:attr="data-label=${entryLabel},aria-label=${entryLabel},data-devcm-action=${entryAction}"
>
<i th:class="|i-pixelarticons-${!#strings.isEmpty(item.icon) ? item.icon : 'file'}|"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAnonymous()"
th:if="${placement == 'down' and itemType == 'login' and (item.enabled == null or item.enabled == true or item.enabled == 'true')}"
th:href="${entryHref}"
th:target="${item.external == true or item.external == 'true'} ? '_blank' : null"
th:rel="${item.external == true or item.external == 'true'} ? 'noopener noreferrer' : null"
th:title="${entryLabel}"
th:attr="data-label=${entryLabel},aria-label=${entryLabel},data-devcm-action=${entryAction}"
>
<i class="i-pixelarticons-user"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAuthenticated()"
th:if="${placement == 'down' and itemType == 'login' and (item.enabled == null or item.enabled == true or item.enabled == 'true')}"
href="/console"
th:title="#{devcm.activity.console}"
th:attr="data-label=#{devcm.activity.console},aria-label=#{devcm.activity.console},data-devcm-action='link'"
>
<i class="i-radix-icons-gear"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAuthenticated()"
th:if="${placement == 'down' and itemType == 'login' and (item.enabled == null or item.enabled == true or item.enabled == 'true')}"
href="/logout"
th:title="#{devcm.activity.logout}"
th:attr="data-label=#{devcm.activity.logout},aria-label=#{devcm.activity.logout},data-devcm-action='link'"
>
<i class="i-pixelarticons-user"></i>
</a>
</th:block>
</th:block>
<th:block th:if="${items == null or #lists.isEmpty(items)}">
<a
class="devcm-activity__button"
sec:authorize="isAnonymous()"
href="/console"
th:title="#{devcm.activity.login}"
th:attr="data-label=#{devcm.activity.login},aria-label=#{devcm.activity.login}"
>
<i class="i-pixelarticons-user"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAuthenticated()"
href="/console"
th:title="#{devcm.activity.console}"
th:attr="data-label=#{devcm.activity.console},aria-label=#{devcm.activity.console}"
>
<i class="i-radix-icons-gear"></i>
</a>
<a
class="devcm-activity__button"
sec:authorize="isAuthenticated()"
href="/logout"
th:title="#{devcm.activity.logout}"
th:attr="data-label=#{devcm.activity.logout},aria-label=#{devcm.activity.logout}"
>
<i class="i-pixelarticons-user"></i>
</a>
</th:block>
</div>
</th:block>
</aside>