Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-73805] #9788

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/src/main/java/hudson/AboutJenkins.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hudson.model.ManagementLink;
import hudson.security.Permission;
import java.net.URL;
import java.util.List;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
Expand Down Expand Up @@ -52,4 +53,12 @@ public Permission getRequiredPermission() {
public Category getCategory() {
return Category.STATUS;
}

public static AboutPageDecorator getAboutPageDecorator() {
return AboutPageDecorator.first();
}

public static List<AboutPageDecorator> getAboutPageDecorators() {
return AboutPageDecorator.all();
}
}
94 changes: 94 additions & 0 deletions core/src/main/java/hudson/AboutPageDecorator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* The MIT License
*
* Copyright 2018, 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.
*/

package hudson;

import java.util.List;

import hudson.model.Describable;
import hudson.model.Descriptor;
import jenkins.model.Jenkins;

/**
* Participates in the rendering of the about page
*
* <p>
* This class provides a few hooks to augment the HTML of the about page.
*
* <dl>
* <dt>about-branding.jelly</dt>
* <dd>
* This view contributes to the branding section.
* </dd>
* <dt>about-involved.jelly</dt>
* <dd>
* This view contributes the get involved box/icon.
* </dd>
* <dt>about-static.jelly</dt>
* <dd>
* This view contributes to the static listing of dependencies.
* </dd>
* </dl>
*
* @since 2.478
*/
public class AboutPageDecorator extends Descriptor<AboutPageDecorator> implements ExtensionPoint, Describable<AboutPageDecorator> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Descriptor/Describable? Seems entirely unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lack of knowledge, I used #8462 for inspiration I will look into StaplerOverridable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daniel-beck I have refactored the code, does that look better?


protected AboutPageDecorator() {
super(self());
}

@Override
public final Descriptor<AboutPageDecorator> getDescriptor() {
return this;
}
/**
* Obtains the URL of this object, excluding the context path.
*
* <p>
* Every {@link AboutPageDecorator} is bound to URL via {@link Jenkins#getDescriptor()}.
* This method returns such an URL.
*/

public final String getUrl() {
return "descriptor/" + clazz.getName();
}

/**
* Returns all about page decorators.
*/
public static List<AboutPageDecorator> all() {
return Jenkins.get().getDescriptorList(AboutPageDecorator.class);
}

/**
* The first found AboutDecorator, there can only be one.
* @return the first found {@link AboutPageDecorator}
*/
public static AboutPageDecorator first() {
List<AboutPageDecorator> decorators = all();
return decorators.isEmpty() ? null : decorators.get(0);
}

}
30 changes: 30 additions & 0 deletions core/src/main/resources/hudson/AboutJenkins/about-branding.jelly
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">
<div class="app-about-branding">
<div class="app-about-branding__aurora"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}" />
</div>
</j:jelly>
32 changes: 32 additions & 0 deletions core/src/main/resources/hudson/AboutJenkins/about-involved.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
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" xmlns:l="/lib/layout">
<div class="jenkins-app-bar__controls">
<a href="https://www.jenkins.io/participate/" class="jenkins-button" target="_blank">
<l:icon src="symbol-heart" />
${%Get involved}
</a>
</div>
</j:jelly>
52 changes: 52 additions & 0 deletions core/src/main/resources/hudson/AboutJenkins/about-static.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
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" xmlns:l="/lib/layout">
<tr>
<td>
<a class="jenkins-table__link" href="https://github.com/jenkins-contrib-themes/jenkins-core-theme">
Jenkins Contrib Themes
</a>
</td>
<td>
<a class="jenkins-table__link" href="https://github.com/afonsof">Afonso Franca</a>
</td>
<td>
<a class="jenkins-table__link" href="https://opensource.org/licenses/MIT">MIT License</a>
</td>
</tr>
<tr>
<td>
<a class="jenkins-table__link" href="https://ionic.io/ionicons">Ionicons</a>
</td>
<td>
<a class="jenkins-table__link" href="https://github.com/ionic-team">Ionic</a>
</td>
<td>
<a class="jenkins-table__link" href="https://github.com/ionic-team/ionicons/blob/master/LICENSE">MIT
License
</a>
</td>
</tr>
</j:jelly>
46 changes: 7 additions & 39 deletions core/src/main/resources/hudson/AboutJenkins/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,24 @@ THE SOFTWARE.

<!-- About Jenkins page -->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:t="/lib/hudson">
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:st="jelly:stapler">

<j:set var="aboutDecorator" value="${h.aboutPageDecorator}"/>
<l:layout type="one-column" permissions="${app.MANAGE_AND_SYSTEM_READ}" title="${%about(app.VERSION)}">
<l:header>
<script src="${resURL}/jsbundles/section-to-tabs.js" type="text/javascript" defer="true" />
</l:header>

<l:main-panel>
<div class="app-about-branding">
<div class="app-about-branding__aurora"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}" />
</div>

<st:include it="${it.getAboutPageDecorator}" page="about-branding.jelly" />
<div class="jenkins-app-bar">
<div class="jenkins-app-bar__content">
<h1 class="app-about-heading">Jenkins</h1>
<h1 class="app-about-heading">${%jenkins.name}</h1>
<p class="app-about-version">
${%Version} ${app.VERSION}
</p>
</div>
<div class="jenkins-app-bar__controls">
<a href="https://www.jenkins.io/participate/" class="jenkins-button" target="_blank">
<l:icon src="symbol-heart" />
${%Get involved}
</a>
</div>
<st:include it="${it.getAboutPageDecorator}" page="about-involved.jelly" />
</div>

<p class="app-about-paragraph">${%blurb}</p>
Expand Down Expand Up @@ -79,32 +72,7 @@ THE SOFTWARE.
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="jenkins-table__link" href="https://github.com/jenkins-contrib-themes/jenkins-core-theme">
Jenkins Contrib Themes
</a>
</td>
<td>
<a class="jenkins-table__link" href="https://github.com/afonsof">Afonso Franca</a>
</td>
<td>
<a class="jenkins-table__link" href="https://opensource.org/licenses/MIT">MIT License</a>
</td>
</tr>
<tr>
<td>
<a class="jenkins-table__link" href="https://ionic.io/ionicons">Ionicons</a>
</td>
<td>
<a class="jenkins-table__link" href="https://github.com/ionic-team">Ionic</a>
</td>
<td>
<a class="jenkins-table__link" href="https://github.com/ionic-team/ionicons/blob/master/LICENSE">MIT
License
</a>
</td>
</tr>
<st:include it="${it.getAboutPageDecorator}" page="about-static.jelly" />
</tbody>
</table>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

jenkins.name=Jenkins
about=About Jenkins {0}
blurb=The leading open source automation server which enables developers around the world to reliably build, test, and deploy their software.

Expand Down