Skip to content

Commit

Permalink
use header taglib to decouple from core (#101)
Browse files Browse the repository at this point in the history
* use header taglib

since 2.459 core provides the logo, search box and login parts of the header via a taglib for easier reuse in plugins.
This avoids that we have to duplicate the code and do double maintenance.
  • Loading branch information
mawinter69 authored Jul 13, 2024
1 parent 17a60d9 commit fd15b97
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 63 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<properties>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.version>2.440.3</jenkins.version>
<jenkins.version>2.459</jenkins.version>
<gitHubRepo>jenkinsci/customizable-header-plugin</gitHubRepo>
<node.version>20.8.0</node.version>
<yarn.version>1.22.19</yarn.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@
<script src="${resURL}/plugin/customizable-header/js/bundles/app-nav.js" type="text/javascript"></script>
</j:if>
<script src="${resURL}/plugin/customizable-header/js/messages.js" type="text/javascript"></script>
<script src="${resURL}/jsbundles/keyboard-shortcuts.js" type="text/javascript"></script>
</j:if>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<st:include page="headerContent" class="jenkins.views.JenkinsHeader"/>
<j:jelly xmlns:j="jelly:core" xmlns:h="/lib/layout/header" xmlns:st="jelly:stapler">
<header id="page-header" class="page-header">
<h:logo/>
<h:searchbox/>
<h:login/>
</header>
<j:forEach var="systemMessage" items="${it.systemMessages}">
<st:include page="index.jelly" it="${systemMessage}" class="io.jenkins.plugins.customizable_header.SystemMessage"/>
</j:forEach>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:h="/lib/layout/header">
<template id="custom-header-icons">
<l:icon id="external-link" src="symbol-open-outline plugin-ionicons-api" class="icon-xs"/>
</template>
<header id="header" class="page-header custom-header__page">
<header id="page-header" class="page-header custom-header__page">
<j:if test="${it.hasLinks()}">
<div class="custom-header__app-nav">
<button class="custom-header__app-nav-button" data-href="${rootURL}/customizable-header/getLinks">
Expand All @@ -21,63 +21,8 @@
<j:out value="${it.title}"/>
</div>

<div class="searchbox hidden-xs">
<!-- search box -->
<j:set var="searchURL" value="${h.searchURL}"/>
<form action="${searchURL}" method="get" style="position:relative;" class="no-json" name="search" role="search">
<!-- this div is used to calculate the width of the text box -->
<div id="search-box-sizer"/>
<div id="searchform">
<input name="q" placeholder="${searchPlaceholder}" id="search-box" class="main-search__input" value="${request.getParameter('q')}"
role="searchbox"/>

<span class="main-search__icon-leading">
<l:icon src="symbol-search"/>
</span>
<a href="${searchHelpUrl}" class="main-search__icon-trailing">
<l:icon src="symbol-help-circle"/>
</a>

<div id="search-box-completion" data-search-url="${searchURL}"/>
<st:adjunct includes="jenkins.views.JenkinsHeader.search-box"/>
</div>
</form>
</div>

<div class="login page-header__hyperlinks">
<div id="visible-am-insertion" class="page-header__am-wrapper"/>
<div id="visible-sec-am-insertion" class="page-header__am-wrapper"/>

<!-- login field -->
<j:if test="${app.useSecurity}">
<j:choose>
<j:when test="${!h.isAnonymous()}">
<j:invokeStatic var="user" className="hudson.model.User" method="current"/>
<j:choose>
<j:when test="${user.fullName == null || user.fullName.trim().isEmpty()}">
<j:set var="userName" value="${user.id}"/>
</j:when>
<j:otherwise>
<j:set var="userName" value="${user.fullName}"/>
</j:otherwise>
</j:choose>
<a href="${rootURL}/${user.url}" class="model-link">
<l:icon src="symbol-person-circle" class="icon-md"/>
<span class="hidden-xs hidden-sm">${userName}</span>
</a>
<j:if test="${app.securityRealm.canLogOut()}">
<a href="${rootURL}/logout">
<l:icon src="symbol-log-out" class="icon-md"/>
<span class="hidden-xs hidden-sm">${logout}</span>
</a>
</j:if>
</j:when>
<j:otherwise>
<st:include it="${app.securityRealm}" page="loginLink.jelly"/>
</j:otherwise>
</j:choose>
</j:if>
</div>
<h:searchbox/>
<h:login/>
</header>
<j:forEach var="systemMessage" items="${it.systemMessages}">
<st:include page="index.jelly" it="${systemMessage}" class="io.jenkins.plugins.customizable_header.SystemMessage"/>
Expand Down

0 comments on commit fd15b97

Please sign in to comment.