Skip to content

Commit

Permalink
Make branding overridable in signin/login page (#8462)
Browse files Browse the repository at this point in the history
* Move resources from DefaultSimplePageDecorator to SimplePageDecorator to ease implementation.
  • Loading branch information
Vlatombe committed Sep 9, 2023
1 parent 54c79f1 commit 2971155
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 12 deletions.
19 changes: 19 additions & 0 deletions core/src/main/java/jenkins/model/SimplePageDecorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@
* <p>
* This class provides a few hooks to augment the HTML of the login page.
*
* <dl>
* <dt>simple-branding.jelly</dt>
* <dd>
* This view contributes to the branding section, usually located on the left side of the login/register pages.
* </dd>
* <dt>simple-footer.jelly</dt>
* <dd>
* This view contributes to the footer section, located below the login/register form.
* </dd>
* <dt>simple-head.jelly</dt>
* <dd>
* This view contributes to the head section.
* </dd>
* <dt>simple-header.jelly</dt>
* <dd>
* This view contributes to the header section just above the login/register form.
* </dd>
* </dl>
*
* @since 2.128
*/
public class SimplePageDecorator extends Descriptor<SimplePageDecorator> implements ExtensionPoint, Describable<SimplePageDecorator> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,16 @@ THE SOFTWARE.
<!-- mobile friendly layout -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- css styling, will fallback to default implementation -->
<st:include it="${simpleDecorator}" page="simple-head.jelly" optional="true"/>
<st:include it="${simpleDecorator}" page="simple-head.jelly" />
<script src="${resURL}/jsbundles/pages/register.js" type="text/javascript" defer="true" />
</head>
<body class="app-sign-in-register">
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
<st:include it="${simpleDecorator}" page="simple-branding.jelly" />
<main id="main-panel" class="app-sign-in-register__content">
<div class="app-sign-in-register__content-inner">
<h1>${%Register}</h1>

<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />
<st:include it="${simpleDecorator}" page="simple-header.jelly" />

<template id="i18n" data-strength-strong="${%Strong}"
data-strength-moderate="${%Moderate}"
Expand Down
9 changes: 3 additions & 6 deletions core/src/main/resources/jenkins/model/Jenkins/login.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,20 @@ THE SOFTWARE.
<!-- mobile friendly layout -->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- css styling, will fallback to default implementation -->
<st:include it="${simpleDecorator}" page="simple-head.jelly" optional="true"/>
<st:include it="${simpleDecorator}" page="simple-head.jelly" />
</head>
<body class="app-sign-in-register">
<j:choose>
<j:when test="${it.setupWizard.isUsingSecurityToken()}">
<st:include it="${it.setupWizard}" page="authenticate-security-token"/>
</j:when>
<j:otherwise>
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
<st:include it="${simpleDecorator}" page="simple-branding.jelly" />
<main id="main-panel" class="app-sign-in-register__content">
<div class="app-sign-in-register__content-inner">
<h1>Sign in to Jenkins</h1>

<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />
<st:include it="${simpleDecorator}" page="simple-header.jelly" />

<form name="login" action="${it.securityRealm.authenticationGatewayUrl}"
method="post">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
The MIT License
Copyright (c) 2023, CloudBees, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
</j:jelly>

0 comments on commit 2971155

Please sign in to comment.