Skip to content

Commit f45b6a1

Browse files
authored
Merge pull request #3896 from camptocamp/theme
Add theme support
2 parents ebef710 + 89e8802 commit f45b6a1

File tree

8 files changed

+101
-59
lines changed

8 files changed

+101
-59
lines changed

Makefile

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,29 @@ help:
9393
@echo
9494
@echo "Main targets:"
9595
@echo
96-
@echo "- help Display this help message"
97-
@echo "- serve-ngeo Run a development web server for running the ngeo examples"
98-
@echo "- serve-gmf Run a development web server for running the gmf examples"
99-
@echo "- serve-gmf-apps Run a development web server for running the gmf apps"
100-
@echo "- check Perform a number of checks on the code"
101-
@echo "- test Run the test suite"
102-
@echo "- test-debug Run the test suite in the browser"
103-
@echo "- clean Remove generated files"
104-
@echo "- cleanall Remove all the build artefacts"
105-
@echo "- cleanallcache Remove all the build artefacts and the extra caches (npm and pip)"
96+
@echo "- help Display this help message"
97+
@echo "- serve-ngeo Run a development web server for running the ngeo examples"
98+
@echo "- serve-gmf Run a development web server for running the gmf examples"
99+
@echo "- serve-gmf-apps-desktop Run a development web server for running the gmf app desktop"
100+
@echo "- serve-gmf-apps-desktopalti Run a development web server for running the gmf app desktop_alt"
101+
@echo "- serve-gmf-apps-mobile Run a development web server for running the gmf app mobile"
102+
@echo "- serve-gmf-apps-mobilealt Run a development web server for running the gmf app mobile_alt"
103+
@echo "- serve-gmf-apps-oeedit Run a development web server for running the gmf app oeedit"
104+
@echo "- serve-gmf-apps-oeview Run a development web server for running the gmf app oeview"
105+
@echo "- examples-hosted Build the hosted examples"
106+
@echo "- examples-hosted-ngeo Build the ngeo hosted examples"
107+
@echo "- examples-hosted-gmf Build the gmf hosted examples"
108+
@echo "- examples-hosted-apps Build the gmf apps hosted examples"
109+
@echo "- check Perform a number of checks on the code"
110+
@echo "- test Run the test suite"
111+
@echo "- test-debug Run the test suite in the browser"
112+
@echo "- clean Remove generated files"
113+
@echo "- cleanall Remove all the build artefacts"
114+
@echo "- cleanallcache Remove all the build artefacts and the extra caches (npm and pip)"
106115
@echo
107116
@echo "Secondary targets:"
108117
@echo
109118
@echo "- apidoc Build the API documentation using JSDoc"
110-
@echo "- examples-hosted Build the hosted examples"
111119
@echo "- lint Check the code with the linter"
112120
@echo "- gh-pages Update the GitHub pages"
113121
@echo
@@ -116,13 +124,7 @@ help:
116124
apidoc: .build/apidoc
117125

118126
.PHONY: check
119-
check: lint check-examples-checker check-examples test build-gmf-apps
120-
121-
.PHONY: build-gmf-apps
122-
build-gmf-apps: \
123-
$(addprefix contribs/gmf/build/gmf-,$(addsuffix .json, $(LANGUAGES))) \
124-
$(ANGULAR_LOCALES_FILES)
125-
# TODO: call webpack to build the gmf apps (in contribs/gmf/build)
127+
check: lint check-examples-checker check-examples test examples-hosted-apps
126128

127129
.PHONY: check-examples-checker
128130
check-example-checker: $(CHECK_EXAMPLE_CHECKER)
@@ -171,9 +173,29 @@ serve-ngeo: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCAL
171173
serve-gmf: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
172174
npm run serve-gmf-examples
173175

174-
.PHONY: serve-gmf-apps
175-
serve-gmf-apps: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
176-
npm run serve-gmf-apps
176+
.PHONY: serve-gmf-apps-desktop
177+
serve-gmf-apps-desktop: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
178+
APP=desktop THEME=desktop npm run serve-gmf-apps
179+
180+
.PHONY: serve-gmf-apps-desktopalt
181+
serve-gmf-apps-desktopalt: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
182+
APP=desktop_alt THEME=desktop_alt npm run serve-gmf-apps
183+
184+
.PHONY: serve-gmf-apps-mobile
185+
serve-gmf-apps-mobile: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
186+
APP=mobile npm run serve-gmf-apps
187+
188+
.PHONY: serve-gmf-apps-mobilealt
189+
serve-gmf-apps-mobilealt: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
190+
APP=mobile_alt npm run serve-gmf-apps
191+
192+
.PHONY: serve-gmf-apps-oeedit
193+
serve-gmf-apps-oeedit: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
194+
APP=oeedit THEME=desktop npm run serve-gmf-apps
195+
196+
.PHONY: serve-gmf-apps-oeview
197+
serve-gmf-apps-oeview: .build/node_modules.timestamp $(FONTAWESOME_WEBFONT) $(ANGULAR_LOCALES_FILES)
198+
APP=oeview THEME=desktop npm run serve-gmf-apps
177199

178200
.PHONY: examples-hosted
179201
examples-hosted: \
@@ -199,7 +221,12 @@ examples-hosted-gmf: .build/examples-gmf.timestamp .build/examples-hosted/contri
199221
examples-hosted-apps: .build/gmf-apps.timestamp .build/examples-hosted-gmf-apps-deps.timestamp
200222

201223
.build/gmf-apps.timestamp: $(GMF_APPS_ALL_SRC_FILES) $(WEBPACK_CONFIG_FILES) .build/node_modules.timestamp
202-
npm run build-gmf-apps
224+
APP=desktop THEME=desktop npm run build-gmf-apps
225+
APP=desktop_alt THEME=desktop_alt npm run build-gmf-apps
226+
APP=mobile npm run build-gmf-apps
227+
APP=mobile_alt npm run build-gmf-apps
228+
APP=oeedit THEME=desktop npm run build-gmf-apps
229+
APP=oeview THEME=desktop npm run build-gmf-apps
203230
touch $@
204231

205232
.PHONY: gh-pages

buildtools/webpack.commons.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ const LessPluginAutoprefix = require('less-plugin-autoprefix');
66

77
const devMode = process.env.NODE_ENV !== 'production'
88

9+
const themes = {
10+
'desktop': '"~gmf/controllers/desktop-theme.less"',
11+
'desktop_alt': '"' + path.resolve('contribs/gmf/apps/desktop_alt/less/theme.less') + '"',
12+
}
13+
14+
const theme = process.env.THEME
15+
16+
917
const providePlugin = new webpack.ProvidePlugin({
1018
// Make sure that Angular finds jQuery and does not fall back to jqLite
1119
// See https://github.com/webpack/webpack/issues/582
@@ -107,15 +115,20 @@ const cssRule = {
107115
const cssLessLoaderConfigs = [
108116
{
109117
loader: 'css-loader',
110-
options: {importLoaders: 1}
118+
options: {
119+
importLoaders: 1
120+
}
111121
},
112122
{
113123
loader: 'less-loader',
114124
options: {
115125
lessPlugins: [
116126
new LessPluginCleanCSS(),
117127
new LessPluginAutoprefix()
118-
]
128+
],
129+
modifyVars: {
130+
'THEME': themes[theme],
131+
}
119132
}
120133
}
121134
];
@@ -161,7 +174,10 @@ const config = {
161174
},
162175
plugins: [
163176
providePlugin,
164-
new ExtractTextPlugin(devMode ? '[name].css' : '[name].[chunkhash:6].css'),
177+
new ExtractTextPlugin({
178+
ignoreOrder: true,
179+
filename: devMode ? '[name].css' : '[name].[chunkhash:6].css'
180+
}),
165181
new webpack.IgnorePlugin(/^\.\/locale$/, /node_modules\/moment\/src\/lib\/locale$/),
166182
],
167183
resolve: {

buildtools/webpack.gmfapps.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const path = require('path');
2-
const ls = require('ls');
32
const webpack = require('webpack');
43
const HtmlWebpackPlugin = require('html-webpack-plugin');
54
const CopyWebpackPlugin = require('copy-webpack-plugin');
@@ -8,20 +7,19 @@ const plugins = [];
87
const entry = {};
98

109
const filenamePrefix = process.env.DEV_SERVER ? 'contribs/gmf/apps/' : '';
10+
const name = process.env.APP
1111

12-
for (const filename of ls('contribs/gmf/apps/*/index.html.ejs')) {
13-
const name = path.basename(filename.path);
14-
entry[name] = `./${filename.path}/Controller.js`;
15-
plugins.push(
16-
new HtmlWebpackPlugin({
17-
template: filename.full,
18-
inject: false,
19-
chunksSortMode: 'manual',
20-
filename: filenamePrefix + name + '.html',
21-
chunks: ['commons', name]
22-
})
23-
);
24-
}
12+
const folder = `contribs/gmf/apps/${name}`;
13+
entry[name] = `./${folder}/Controller.js`;
14+
plugins.push(
15+
new HtmlWebpackPlugin({
16+
template: `${folder}/index.html.ejs`,
17+
inject: false,
18+
chunksSortMode: 'manual',
19+
filename: filenamePrefix + name + '.html',
20+
chunks: ['commons', name]
21+
})
22+
);
2523

2624

2725
module.exports = {

contribs/gmf/apps/desktop_alt/less/main.less

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@import '~gmf/controllers/desktop.less';
22

3-
@brand-primary: #9FB6CC;
4-
@brand-secondary: #D3DBE3;
5-
63
.gmf-theme-selector li {
74
flex-direction: column;
85
}
@@ -12,8 +9,6 @@
129
background-color: transparent;
1310
}
1411

15-
@theme-selector-columns: 3;
16-
1712
div .ngeo-displaywindow {
1813
@displaywindow-min-height: 24rem;
1914
left: @app-margin + @left-panel-width + @displaywindow-min-height / 2;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import '~gmf/controllers/desktop-theme.less';
2+
3+
@brand-primary: #9FB6CC;
4+
@brand-secondary: #D3DBE3;
5+
6+
@theme-selector-columns: 3;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@map-tools-size: 3rem;
2+
@button-size: 4rem;
3+
@left-panel-width: 32rem;
4+
@right-panel-width: 28rem;
5+
@topbar-height: 4.5rem;
6+
@border-color: darken(@brand-primary, @standard-variation);
7+
@search-width: 8 * @map-tools-size;
8+
@font-size-base: 13px;
9+
@padding-base-vertical: 5px;
10+
@padding-base-horizontal: 10px;
11+
@form-group-margin-bottom: 10px;
12+
@search-results-max-height: calc(~"100vh -" @topbar-height + @map-tools-size + (2 * @app-margin));

contribs/gmf/src/controllers/desktop.less

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Entry point for all styles required for the desktop application.
33
*/
4+
@import '~gmf/less/vars.less';
45
@import '~gmf/less/font.less';
56
@import '~gmf/less/base.less';
67
@import '~gmf/less/map.less';
@@ -11,21 +12,6 @@
1112
@import '~gmf/less/fullscreenpopup.less';
1213

1314
@import '~gmf/layertree/desktop.less';
14-
@import '~gmf/search/search.less';
15-
16-
@map-tools-size: 3rem;
17-
@button-size: 4rem;
18-
@left-panel-width: 32rem;
19-
@right-panel-width: 28rem;
20-
@topbar-height: 4.5rem;
21-
@border-color: darken(@brand-primary, @standard-variation);
22-
@search-width: 8 * @map-tools-size;
23-
@font-size-base: 13px;
24-
@padding-base-vertical: 5px;
25-
@padding-base-horizontal: 10px;
26-
@form-group-margin-bottom: 10px;
27-
@search-results-max-height: calc(~"100vh -" @topbar-height + @map-tools-size + (2 * @app-margin));
28-
2915

3016
html, body {
3117
position: relative;

contribs/gmf/src/less/vars.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@
3535
@brand-primary: #94ac9a;
3636
@brand-secondary: #d3e5d7;
3737
@font-size-small: 0.9em;
38+
39+
@import (optional) "@{THEME}";

0 commit comments

Comments
 (0)