From afd4524c3920f8426051e0673b42f022cb3627fe Mon Sep 17 00:00:00 2001 From: taehoon Date: Tue, 3 Dec 2019 10:32:46 -0500 Subject: use another approach for versioning font files --- build/webpack.base.conf.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'build/webpack.base.conf.js') diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index f8968966..9313ec20 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -3,6 +3,7 @@ var config = require('../config') var utils = require('./utils') var projectRoot = path.resolve(__dirname, '../') var ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin') +var FontelloPlugin = require("fontello-webpack-plugin") var env = process.env.NODE_ENV // check env & config/index.js to decide weither to enable CSS Sourcemaps for the @@ -11,6 +12,8 @@ var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap) var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap) var useCssSourceMap = cssSourceMapDev || cssSourceMapProd +var now = Date.now() + module.exports = { entry: { app: './src/main.js' @@ -90,6 +93,14 @@ module.exports = { new ServiceWorkerWebpackPlugin({ entry: path.join(__dirname, '..', 'src/sw.js'), filename: 'sw-pleroma.js' + }), + new FontelloPlugin({ + config: require('../static/fontello.json'), + name: 'fontello', + output: { + css: '[name].' + now + '.css', // [hash] is not supported. Use the current timestamp instead for versioning. + font: 'font/[name].' + now + '.[ext]' + } }) ] } -- cgit v1.2.3-70-g09d2 From 9aac873d6b50e6576578c0aac131971f6af4e4c4 Mon Sep 17 00:00:00 2001 From: kPherox Date: Thu, 5 Dec 2019 22:46:05 +0900 Subject: Change output directory of fontello --- build/webpack.base.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'build/webpack.base.conf.js') diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 9313ec20..5cc0135e 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -98,8 +98,8 @@ module.exports = { config: require('../static/fontello.json'), name: 'fontello', output: { - css: '[name].' + now + '.css', // [hash] is not supported. Use the current timestamp instead for versioning. - font: 'font/[name].' + now + '.[ext]' + css: 'static/[name].' + now + '.css', // [hash] is not supported. Use the current timestamp instead for versioning. + font: 'static/font/[name].' + now + '.[ext]' } }) ] -- cgit v1.2.3-70-g09d2 From 7c074b87418602effac03c4bae34afffcfca283f Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 27 Jan 2020 04:20:13 +0200 Subject: fix rgba css generation, add some tests to automatically verify that themes are generated properly --- build/webpack.base.conf.js | 1 + src/services/color_convert/color_convert.js | 2 +- src/services/theme_data/theme_data.service.js | 2 +- static/themes/redmond-xx-se.json | 2 +- static/themes/redmond-xx.json | 2 +- static/themes/redmond-xxi.json | 2 +- .../services/theme_data/sanity_checks.spec.js | 28 ++++ .../specs/services/theme_data/theme_data.spec.js | 147 +++++++++++---------- 8 files changed, 109 insertions(+), 77 deletions(-) create mode 100644 test/unit/specs/services/theme_data/sanity_checks.spec.js (limited to 'build/webpack.base.conf.js') diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 5cc0135e..dfef37a6 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -35,6 +35,7 @@ module.exports = { ], alias: { 'vue$': 'vue/dist/vue.runtime.common', + 'static': path.resolve(__dirname, '../static'), 'src': path.resolve(__dirname, '../src'), 'assets': path.resolve(__dirname, '../src/assets'), 'components': path.resolve(__dirname, '../src/components') diff --git a/src/services/color_convert/color_convert.js b/src/services/color_convert/color_convert.js index 0bf8f646..b5461038 100644 --- a/src/services/color_convert/color_convert.js +++ b/src/services/color_convert/color_convert.js @@ -171,7 +171,7 @@ export const mixrgb = (a, b) => { * @returns {String} CSS rgba() color */ export const rgba2css = function (rgba) { - return `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})` + return `rgba(${Math.floor(rgba.r)}, ${Math.floor(rgba.g)}, ${Math.floor(rgba.b)}, .5)` } /** diff --git a/src/services/theme_data/theme_data.service.js b/src/services/theme_data/theme_data.service.js index 0a6733a9..49b99148 100644 --- a/src/services/theme_data/theme_data.service.js +++ b/src/services/theme_data/theme_data.service.js @@ -353,7 +353,7 @@ export const getColors = (sourceColors, sourceOpacity, mod) => SLOT_ORDERED.redu if (dependencySlot && sourceColors[dependencySlot] === 'transparent') { outputColor.a = 0 } else { - outputColor.a = sourceOpacity[opacitySlot] || OPACITIES[opacitySlot].defaultValue || 1 + outputColor.a = Number(sourceOpacity[opacitySlot]) || OPACITIES[opacitySlot].defaultValue || 1 } } if (opacitySlot) { diff --git a/static/themes/redmond-xx-se.json b/static/themes/redmond-xx-se.json index 1a867fcc..8deab7b7 100644 --- a/static/themes/redmond-xx-se.json +++ b/static/themes/redmond-xx-se.json @@ -1,7 +1,7 @@ { "_pleroma_theme_version": 2, "name": "Redmond XX SE", - "theme": { + "source": { "shadows": { "panel": [ { diff --git a/static/themes/redmond-xx.json b/static/themes/redmond-xx.json index 78c92f10..cdb89fe3 100644 --- a/static/themes/redmond-xx.json +++ b/static/themes/redmond-xx.json @@ -1,7 +1,7 @@ { "_pleroma_theme_version": 2, "name": "Redmond XX", - "theme": { + "source": { "shadows": { "panel": [ { diff --git a/static/themes/redmond-xxi.json b/static/themes/redmond-xxi.json index 28f68351..79a2cb26 100644 --- a/static/themes/redmond-xxi.json +++ b/static/themes/redmond-xxi.json @@ -1,7 +1,7 @@ { "_pleroma_theme_version": 2, "name": "Redmond XXI", - "theme": { + "source": { "shadows": { "panel": [ { diff --git a/test/unit/specs/services/theme_data/sanity_checks.spec.js b/test/unit/specs/services/theme_data/sanity_checks.spec.js new file mode 100644 index 00000000..f0072e7d --- /dev/null +++ b/test/unit/specs/services/theme_data/sanity_checks.spec.js @@ -0,0 +1,28 @@ +import { getColors } from 'src/services/theme_data/theme_data.service.js' + +const checkColors = (output) => { + expect(output).to.have.property('colors') + Object.entries(output.colors).forEach(([key, v]) => { + expect(v, key).to.be.an('object') + expect(v, key).to.include.all.keys('r', 'g', 'b') + 'rgba'.split('').forEach(k => { + if ((k === 'a' && v.hasOwnProperty('a')) || k !== 'a') { + expect(v[k], key + '.' + k).to.be.a('number') + expect(v[k], key + '.' + k).to.be.least(0) + expect(v[k], key + '.' + k).to.be.most(k === 'a' ? 1 : 255) + } + }) + }) +} + +describe('Theme Data utility functions', () => { + const context = require.context('static/themes/', false, /\.json$/) + context.keys().forEach((key) => { + it(`Should render all colors for ${key} properly`, () => { + const { theme, source } = context(key) + const data = source || theme + const colors = getColors(data.colors, data.opacity, 1) + checkColors(colors) + }) + }) +}) diff --git a/test/unit/specs/services/theme_data/theme_data.spec.js b/test/unit/specs/services/theme_data/theme_data.spec.js index d8a04ba7..67f4fd5a 100644 --- a/test/unit/specs/services/theme_data/theme_data.spec.js +++ b/test/unit/specs/services/theme_data/theme_data.spec.js @@ -1,87 +1,90 @@ import { getLayersArray, topoSort } from 'src/services/theme_data/theme_data.service.js' -describe('getLayersArray', () => { - const fixture = { - layer1: null, - layer2: 'layer1', - layer3a: 'layer2', - layer3b: 'layer2' - } +describe('Theme Data utility functions', () => { + describe('getLayersArray', () => { + const fixture = { + layer1: null, + layer2: 'layer1', + layer3a: 'layer2', + layer3b: 'layer2' + } - it('should expand layers properly (3b)', () => { - const out = getLayersArray('layer3b', fixture) - expect(out).to.eql(['layer1', 'layer2', 'layer3b']) - }) + it('should expand layers properly (3b)', () => { + const out = getLayersArray('layer3b', fixture) + expect(out).to.eql(['layer1', 'layer2', 'layer3b']) + }) - it('should expand layers properly (3a)', () => { - const out = getLayersArray('layer3a', fixture) - expect(out).to.eql(['layer1', 'layer2', 'layer3a']) - }) + it('should expand layers properly (3a)', () => { + const out = getLayersArray('layer3a', fixture) + expect(out).to.eql(['layer1', 'layer2', 'layer3a']) + }) - it('should expand layers properly (2)', () => { - const out = getLayersArray('layer2', fixture) - expect(out).to.eql(['layer1', 'layer2']) - }) + it('should expand layers properly (2)', () => { + const out = getLayersArray('layer2', fixture) + expect(out).to.eql(['layer1', 'layer2']) + }) - it('should expand layers properly (1)', () => { - const out = getLayersArray('layer1', fixture) - expect(out).to.eql(['layer1']) + it('should expand layers properly (1)', () => { + const out = getLayersArray('layer1', fixture) + expect(out).to.eql(['layer1']) + }) }) -}) -describe('topoSort', () => { - const fixture1 = { - layerA: [], - layer1A: ['layerA'], - layer2A: ['layer1A'], - layerB: [], - layer1B: ['layerB'], - layer2B: ['layer1B'], - layer3AB: ['layer2B', 'layer2A'] - } + describe('topoSort', () => { + const fixture1 = { + layerA: [], + layer1A: ['layerA'], + layer2A: ['layer1A'], + layerB: [], + layer1B: ['layerB'], + layer2B: ['layer1B'], + layer3AB: ['layer2B', 'layer2A'] + } - // Same thing but messed up order - const fixture2 = { - layer1A: ['layerA'], - layer1B: ['layerB'], - layer2A: ['layer1A'], - layerB: [], - layer3AB: ['layer2B', 'layer2A'], - layer2B: ['layer1B'], - layerA: [] - } + // Same thing but messed up order + const fixture2 = { + layer1A: ['layerA'], + layer1B: ['layerB'], + layer2A: ['layer1A'], + layerB: [], + layer3AB: ['layer2B', 'layer2A'], + layer2B: ['layer1B'], + layerA: [] + } - it('should make a topologically sorted array', () => { - const out = topoSort(fixture1, (node, inheritance) => inheritance[node]) - // This basically checks all ordering that matters - expect(out.indexOf('layerA')).to.be.below(out.indexOf('layer1A')) - expect(out.indexOf('layer1A')).to.be.below(out.indexOf('layer2A')) - expect(out.indexOf('layerB')).to.be.below(out.indexOf('layer1B')) - expect(out.indexOf('layer1B')).to.be.below(out.indexOf('layer2B')) - expect(out.indexOf('layer2A')).to.be.below(out.indexOf('layer3AB')) - expect(out.indexOf('layer2B')).to.be.below(out.indexOf('layer3AB')) - }) + it('should make a topologically sorted array', () => { + const out = topoSort(fixture1, (node, inheritance) => inheritance[node]) + // This basically checks all ordering that matters + expect(out.indexOf('layerA')).to.be.below(out.indexOf('layer1A')) + expect(out.indexOf('layer1A')).to.be.below(out.indexOf('layer2A')) + expect(out.indexOf('layerB')).to.be.below(out.indexOf('layer1B')) + expect(out.indexOf('layer1B')).to.be.below(out.indexOf('layer2B')) + expect(out.indexOf('layer2A')).to.be.below(out.indexOf('layer3AB')) + expect(out.indexOf('layer2B')).to.be.below(out.indexOf('layer3AB')) + }) - it('order in object shouldn\'t matter', () => { - const out = topoSort(fixture2, (node, inheritance) => inheritance[node]) - // This basically checks all ordering that matters - expect(out.indexOf('layerA')).to.be.below(out.indexOf('layer1A')) - expect(out.indexOf('layer1A')).to.be.below(out.indexOf('layer2A')) - expect(out.indexOf('layerB')).to.be.below(out.indexOf('layer1B')) - expect(out.indexOf('layer1B')).to.be.below(out.indexOf('layer2B')) - expect(out.indexOf('layer2A')).to.be.below(out.indexOf('layer3AB')) - expect(out.indexOf('layer2B')).to.be.below(out.indexOf('layer3AB')) - }) + it('order in object shouldn\'t matter', () => { + const out = topoSort(fixture2, (node, inheritance) => inheritance[node]) + // This basically checks all ordering that matters + expect(out.indexOf('layerA')).to.be.below(out.indexOf('layer1A')) + expect(out.indexOf('layer1A')).to.be.below(out.indexOf('layer2A')) + expect(out.indexOf('layerB')).to.be.below(out.indexOf('layer1B')) + expect(out.indexOf('layer1B')).to.be.below(out.indexOf('layer2B')) + expect(out.indexOf('layer2A')).to.be.below(out.indexOf('layer3AB')) + expect(out.indexOf('layer2B')).to.be.below(out.indexOf('layer3AB')) + }) - it('dependentless nodes should be first', () => { - const out = topoSort(fixture2, (node, inheritance) => inheritance[node]) - // This basically checks all ordering that matters - expect(out.indexOf('layerA')).to.eql(0) - expect(out.indexOf('layerB')).to.eql(1) - }) + it('dependentless nodes should be first', () => { + const out = topoSort(fixture2, (node, inheritance) => inheritance[node]) + // This basically checks all ordering that matters + expect(out.indexOf('layerA')).to.eql(0) + expect(out.indexOf('layerB')).to.eql(1) + }) - it('ignores cyclic dependencies', () => { - const out = topoSort({ a: 'b', b: 'a', c: 'a' }, (node, inheritance) => [inheritance[node]]) - expect(out.indexOf('a')).to.be.below(out.indexOf('c')) + it('ignores cyclic dependencies', () => { + const out = topoSort({ a: 'b', b: 'a', c: 'a' }, (node, inheritance) => [inheritance[node]]) + expect(out.indexOf('a')).to.be.below(out.indexOf('c')) + }) }) + }) -- cgit v1.2.3-70-g09d2