Skip to content

Commit dbbd3c1

Browse files
authored
Convert to plugin (#77)
1 parent 3681758 commit dbbd3c1

File tree

22 files changed

+429
-8
lines changed

22 files changed

+429
-8
lines changed

.github/release-drafter.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_extends: .github
2+
name-template: v$NEXT_PATCH_VERSION 🌈
3+
version-template: $MAJOR.$MINOR.$PATCH

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target/
2+
work/
3+
*.iml
4+
.idea/

.mvn/maven.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Pconsume-incrementals

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@ We are also looking for early adopters and testers who are interested to try out
1212
We have a demo with a pre-configured Docker image you can use for trying out the Dark theme.
1313
You can find it [here](./demo/README.md).
1414

15+
## Developing
16+
17+
Start the theme plugin with `mvn hpi:run`
18+
19+
You will get a development instance of Jenkins running on port 8080
20+
21+
Any changes you make to the theme CSS file will be reflected after refreshing the page, no need to restart Jenkins.
22+
1523
### Manual setup
1624

1725
1. Run Jenkins from a pull request
1826
* ```docker run --rm -ti -p 8080:8080 -e ID=4752 jenkins/core-pr-tester```
1927
2. Install the Simple Theme Plugin
2028
3. Add the theme CSS from this repository to the instance
21-
* You can use the jsdeliver CDN to pull it directly from GitHub: https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@master/theme.css
29+
* You can use the jsdeliver CDN to pull it directly from GitHub: https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@master/src/main/resources/io/jenkins/plugins/darktheme/theme.css
2230

2331
More detailed testing guidelines are coming soon!
2432

Jenkinsfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
See the documentation for more options:
3+
https://github.com/jenkins-infra/pipeline-library/
4+
*/
5+
6+
buildPlugin(useAci: true, configurations: [
7+
[ platform: "linux", jdk: "8", jenkins: null ],
8+
[ platform: "linux", jdk: "11", jenkins: null, javaLevel: "8" ]
9+
])

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,27 @@ This repository contains a dark theme for Jenkins.
99

1010
## Usage
1111

12-
To install this theme use the [Simple Theme Plugin](https://plugins.jenkins.io/simple-theme-plugin/).
12+
### Installing via Jenkins update center
13+
14+
To install this theme search for 'Dark theme' in your Jenkins update center.
15+
16+
Then go to the "Configure System" page, search for 'Built-in Themes' and select 'Dark (Respect OS/Browser system setting)'
17+
18+
or with the [configuration-as-code](https://github.com/jenkinsci/configuration-as-code-plugin) plugin:
19+
20+
```yaml
21+
unclassified:
22+
themeManager:
23+
disableUserThemes: true
24+
theme: "darkSystem" # use 'dark' for forcing the dark theme regardless of OS settings
25+
```
26+
27+
Users can configure the theme from their user profile page, see the [theme-manager documentation](https://github.com/jenkinsci/theme-manager-plugin#configuring-the-plugin),
28+
for more information.
29+
30+
### Simple theme plugin
31+
32+
If you can't install this plugin for some reason you can use the [Simple Theme Plugin](https://plugins.jenkins.io/simple-theme-plugin/).
1333
1434
See the plugin documentation for theme installation guidelines.
1535
@@ -19,8 +39,8 @@ _Note: replace 'tag-name' with the latest released version:_
1939
The CSS URLs are:
2040
2141
```text
22-
https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@<tag-name>/theme.css
23-
https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@<tag-name>/theme-system.css
42+
https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@<tag-name>/src/main/resources/io/jenkins/plugins/dark/theme/theme.css
43+
https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@<tag-name>/src/main/resources/io/jenkins/plugins/dark/theme/theme-system.css
2444
```
2545

2646
* theme.css - forces dark theme for all users
@@ -55,7 +75,7 @@ No version of IE will be supported.
5575

5676
## Jenkins compatibility
5777

58-
This project is in active development and needs a recent version of Jenkins, at least v2.239.
78+
This project is in active development and needs a recent version of Jenkins, at least v2.240.
5979

6080
We will do our best to not break new versions of the theme against older supported versions of Jenkins.
6181

demo/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
DEMO_IMAGE=jenkins4eval/dark-theme
2-
DEVEL_VOLUMES=-v $(CURDIR)/../theme.css:/usr/share/jenkins/ref/userContent/theme.css
2+
DEVEL_VOLUMES=-v $(CURDIR)/../src/main/resources/io/jenkins/plugins/darktheme/theme.css:/usr/share/jenkins/ref/userContent/theme.css
33
# TODO: Override by your local path if needed
44
LOCAL_THEME=../../../core/jenkins/war/src/main/webapp/css
55
LOGIN_THEME_VOLUME=-v $(CURDIR)/${LOCAL_THEME}:/usr/share/jenkins/ref/userContent/login-theme

demo/enable-theme.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ boolean darkLogin = Boolean.getBoolean("io.jenkins.themes.dark.login")
1313
if (!disabled) {
1414
String themeUrl = developerMode
1515
? "http://localhost:8081/theme.css"
16-
: "https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@master/theme.css"
16+
: "https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@master/src/main/resources/io/jenkins/plugins/darktheme/theme.css"
1717
def simpleThemeConfig = Jenkins.instance.getExtensionList(PageDecorator.class).get(SimpleThemeDecorator.class)
1818
simpleThemeConfig.getElements().add(new CssUrlThemeElement(themeUrl))
1919
}
@@ -49,6 +49,6 @@ if (!disabled) {
4949
if (developerMode) {
5050
loginThemeConfig.head += '<link rel="stylesheet" href="http://localhost:8081/theme.css" type="text/css" />'
5151
} else {
52-
loginThemeConfig.head += '<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@master/theme.css" type="text/css" />'
52+
loginThemeConfig.head += '<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jenkinsci/dark-theme@master/src/main/resources/io/jenkins/plugins/darktheme/theme.css" type="text/css" />'
5353
}
5454
}

pom.xml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.jenkins-ci.plugins</groupId>
7+
<artifactId>plugin</artifactId>
8+
<version>4.2</version>
9+
<relativePath/>
10+
</parent>
11+
<groupId>io.jenkins.plugins</groupId>
12+
<artifactId>dark-theme</artifactId>
13+
<version>${revision}${changelist}</version>
14+
<packaging>hpi</packaging>
15+
<properties>
16+
<revision>0.0.3</revision>
17+
<changelist>-SNAPSHOT</changelist>
18+
<jenkins.version>2.240</jenkins.version>
19+
<java.level>8</java.level>
20+
<tagNameFormat>@{project.version}</tagNameFormat>
21+
<useBeta>true</useBeta>
22+
</properties>
23+
<name>Dark Theme</name>
24+
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
25+
<dependencyManagement>
26+
<dependencies>
27+
<dependency>
28+
<groupId>io.jenkins.tools.bom</groupId>
29+
<artifactId>bom-2.222.x</artifactId>
30+
<version>10</version>
31+
<scope>import</scope>
32+
<type>pom</type>
33+
</dependency>
34+
</dependencies>
35+
</dependencyManagement>
36+
37+
<dependencies>
38+
<dependency>
39+
<groupId>io.jenkins.plugins</groupId>
40+
<artifactId>theme-manager</artifactId>
41+
<version>1.0-rc18.6e3cdcafbda5</version>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>io.jenkins</groupId>
46+
<artifactId>configuration-as-code</artifactId>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.jenkins.configuration-as-code</groupId>
51+
<artifactId>test-harness</artifactId>
52+
<scope>test</scope>
53+
</dependency>
54+
</dependencies>
55+
56+
<licenses>
57+
<license>
58+
<name>MIT License</name>
59+
<url>https://opensource.org/licenses/MIT</url>
60+
</license>
61+
</licenses>
62+
63+
<developers>
64+
<developer>
65+
<id>timja</id>
66+
<name>Tim Jacomb</name>
67+
</developer>
68+
</developers>
69+
70+
<scm>
71+
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
72+
<developerConnection>scm:git:[email protected]:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
73+
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
74+
<tag>${scmTag}</tag>
75+
</scm>
76+
77+
<repositories>
78+
<repository>
79+
<id>repo.jenkins-ci.org</id>
80+
<url>https://repo.jenkins-ci.org/public/</url>
81+
</repository>
82+
</repositories>
83+
<pluginRepositories>
84+
<pluginRepository>
85+
<id>repo.jenkins-ci.org</id>
86+
<url>https://repo.jenkins-ci.org/public/</url>
87+
</pluginRepository>
88+
</pluginRepositories>
89+
</project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package io.jenkins.plugins.darktheme;
2+
3+
import edu.umd.cs.findbugs.annotations.NonNull;
4+
import hudson.Extension;
5+
import io.jenkins.plugins.thememanager.Theme;
6+
import io.jenkins.plugins.thememanager.ThemeManagerFactory;
7+
import io.jenkins.plugins.thememanager.ThemeManagerFactoryDescriptor;
8+
import org.jenkinsci.Symbol;
9+
import org.kohsuke.stapler.DataBoundConstructor;
10+
11+
public class DarkThemeManagerFactory extends ThemeManagerFactory {
12+
13+
public static final String THEME_CSS = "theme.css";
14+
public static final String THEME_URL_NAME = "theme-dark";
15+
16+
@DataBoundConstructor
17+
public DarkThemeManagerFactory() {
18+
}
19+
20+
@Override
21+
public Theme getTheme() {
22+
return Theme.builder()
23+
.withCssUrl(getCssUrl())
24+
.build();
25+
}
26+
27+
@Extension
28+
@Symbol("dark")
29+
public static class DarkThemeManagerFactoryDescriptor extends ThemeManagerFactoryDescriptor {
30+
31+
@NonNull
32+
@Override
33+
public String getDisplayName() {
34+
return "Dark";
35+
}
36+
37+
@Override
38+
public ThemeManagerFactory getInstance() {
39+
return new DarkThemeManagerFactory();
40+
}
41+
42+
@NonNull
43+
@Override
44+
public String getThemeId() {
45+
return "dark";
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)