Skip to content

Commit

Permalink
Flesh out the Font Downloader code
Browse files Browse the repository at this point in the history
Add REDUX integration into our Core Font functionality

Reorganise components into subfolders

Move the registered field to View_Save_Core_Fonts

Swap old Uglify plugin out for new one

Write PHPUnit tests for our new AJAX functionality

Fix up Mocha tests due to changes to the reducer function

Fix JS tests by processing a node_module that wasn't ES5 friendly

Add unit tests to our Core Fonts React component

Add comments to new React code and tidy up the tests / runners

Change the Core Font tool description

Fix Gulp image reference error

Add Core Font installer prompt and unit tests

Ensure the same item cannot be added to the redux retry list more than once

Fix unit tests due to font removal and new one-time action

Fix up test where the array doesn't have the key
  • Loading branch information
jakejackson1 committed Apr 4, 2018
1 parent e6e3464 commit b38eac6
Show file tree
Hide file tree
Showing 86 changed files with 2,796 additions and 885 deletions.
23 changes: 20 additions & 3 deletions .babelrc
@@ -1,7 +1,24 @@
{
"presets": [
["es2015", { "modules": false }],
"react",
"stage-2"
[
"env",
{
"targets": {
"node": "current",
"browsers": [
"last 2 versions",
"IE >= 10"
],
"modules": false,
"useBuiltIns": "usage"
},
"forceAllTransforms": true
}
],
"react"
],
"plugins": [
"transform-object-rest-spread",
"transform-class-properties"
]
}
3 changes: 1 addition & 2 deletions gulpfile.js
Expand Up @@ -3,13 +3,12 @@ var gulp = require('gulp'),
cleanCSS = require('gulp-clean-css'),
rename = require('gulp-rename'),
wpPot = require('gulp-wp-pot'),
sort = require('gulp-sort'),
watch = require('gulp-watch')

/* Minify our CSS */
gulp.task('minify', function () {
return gulp.src('src/assets/css/*.css')
.pipe(cleanCSS())
.pipe(cleanCSS({ rebaseTo: 'dist/assets/css/'}))
.pipe(rename({
suffix: '.min'
}))
Expand Down
6 changes: 3 additions & 3 deletions karma.conf.js
@@ -1,7 +1,6 @@
var webpack = require("webpack")

var webpackConfig = require('./webpack.config.js')
webpackConfig.devtool = 'inline-source-map'
webpackConfig.entry = undefined
webpackConfig.externals = {
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
Expand All @@ -22,6 +21,7 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'node_modules/babel-polyfill/dist/polyfill.js',
'node_modules/jquery/dist/jquery.min.js',
'tests/mocha/tests.bundle.js'
],
Expand Down Expand Up @@ -65,6 +65,6 @@ module.exports = function (config) {

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
concurrency: Infinity,
})
}
27 changes: 15 additions & 12 deletions package.json
Expand Up @@ -2,13 +2,15 @@
"name": "gravity-pdf",
"private": true,
"dependencies": {
"core-js": "^2.5.1",
"babel-polyfill": "^6.26.0",
"immutable": "^3.8.1",
"lodash.debounce": "^4.0.8",
"promise-queue": "^2.2.3",
"promise-reflect": "^1.1.0",
"prop-types": "^15.5.8",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-dropzone": "^4.0.0",
"react-dropzone": "^4.2.0",
"react-redux": "^5.0",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
Expand All @@ -20,10 +22,10 @@
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.4.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"chai": "^4.0.0",
"cross-env": "^5.0.0",
"enzyme": "^3.1.0",
Expand All @@ -39,27 +41,28 @@
"gulp-wp-pot": "^2.0.4",
"jquery": "^3.1.1",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma": "^1.5",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-ie-launcher": "^1.0.0",
"karma-mocha": "^1.1.1",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sinon": "^1.0.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.3",
"mocha": "^4.0.0",
"react-test-renderer": "^16.0.0",
"redux-mock-store": "^1.2.0",
"sinon": "^2.0.0",
"webpack": "^3.0.0",
"webpack-dev-middleware": "^1.12",
"webpack-uglify-js-plugin": "^1.1.9"
"superagent-mocker": "^0.5.2",
"uglifyjs-webpack-plugin": "^1.0.0-beta.3",
"webpack": "^3.7.1",
"webpack-dev-middleware": "^1.12"
},
"scripts": {
"test": "cross-env NODE_ENV=test karma start",
"test:watch": "cross-env NODE_ENV=test karma start --auto-watch --no-single-run",
"test:watch": "cross-env NODE_ENV=test karma start --auto-watch --no-single-run --log-level error",
"test:all": "cross-env NODE_ENV=test karma start --browsers Firefox,Chrome,IE",
"watch": "cross-env NODE_ENV=development webpack --progress --colors --watch",
"build": "cross-env NODE_ENV=production webpack"
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/gfpdf-admin-styles.css
Expand Up @@ -9,7 +9,7 @@
.notice.gfpdf-alert-mascot {
padding-left: 145px !important;

background-image: url(../../../src/assets/images/paws-with-logo-small.png);
background-image: url(../images/paws-with-logo-small.png);
background-position: 10px 50%;
background-repeat: no-repeat;
background-size: 125px;
Expand Down
35 changes: 33 additions & 2 deletions src/assets/css/gfpdf-styles.css
Expand Up @@ -13,7 +13,7 @@
}

.gfpdf-badge {
background: url("../../../src/assets/images/gravitypdf-globe-black.png") no-repeat 50% 5px;
background: url("../images/gravitypdf-globe-black.png") no-repeat 50% 5px;
color: #333;
display: inline-block;
font-size: 14px;
Expand Down Expand Up @@ -294,6 +294,37 @@ box-shadow: 1px 1px 5px 1px rgba(0,0,0,0.15);
direction: ltr !important;
}

/*
* Core Fonts Download
*/
#gfpdf-install-core-fonts > div,
#gfpdf-install-core-fonts > div > img,
#gfpdf-install-core-fonts > div > span {
vertical-align: middle;
}

.gfpdf-core-font-container {
border: 1px solid #CCC;
margin-top: 10px;
padding: 5px 10px;
height: 150px;
overflow: auto;
font-family: "Courier New", Courier, monospace;
}

.gfpdf-core-font-status-success {
color: #008000;
}

.gfpdf-core-font-status-error {
color: #d10b0b;
}

.gfpdf-core-font-counter {
display: inline-block;
padding-left: 5px;
}

/**
* Help Settings Page
*/
Expand Down Expand Up @@ -881,7 +912,7 @@ box-shadow: 1px 1px 5px 1px rgba(0,0,0,0.15);
* Add out mascot on larger displays only
*/
.gfpdf-mascot-sitting {
background: url("../../../src/assets/images/cap-paws-sitting.png") no-repeat 0 0;
background: url("../images/cap-paws-sitting.png") no-repeat 0 0;
width: 181px;
height: 193px;
display: inline-block;
Expand Down
33 changes: 33 additions & 0 deletions src/assets/js/react/actionTypes/coreFonts.js
@@ -0,0 +1,33 @@
/**
* Our Redux Action Type Constants
*
* @package Gravity PDF
* @copyright Copyright (c) 2017, Blue Liquid Designs
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 4.4
*/

/*
This file is part of Gravity PDF.
Gravity PDF – Copyright (C) 2017, Blue Liquid Designs
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Found
*/

export const ADD_TO_CONSOLE = 'ADD_TO_CONSOLE'
export const CLEAR_CONSOLE = 'CLEAR_CONSOLE'
export const ADD_TO_RETRY_LIST = 'ADD_TO_RETRY_LIST'
export const CLEAR_RETRY_LIST = 'CLEAR_RETRY_LIST'
96 changes: 96 additions & 0 deletions src/assets/js/react/actions/coreFonts.js
@@ -0,0 +1,96 @@
import {
ADD_TO_CONSOLE,
ADD_TO_RETRY_LIST,
CLEAR_CONSOLE,
CLEAR_RETRY_LIST
} from '../actionTypes/coreFonts'

/**
* Redux Actions - payloads of information that send data from your application to your store
*
* @package Gravity PDF
* @copyright Copyright (c) 2017, Blue Liquid Designs
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 4.4
*/

/*
This file is part of Gravity PDF.
Gravity PDF – Copyright (C) 2017, Blue Liquid Designs
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

/**
* Adds a message to our buffer for display to the user
*
* @param key
* @param status
* @param message
*
* @returns {{type, key: *, status: *, message: *}}
*
* @since 4.4
*/
export const addToConsole = (key, status, message) => {
return {
type: ADD_TO_CONSOLE,
key,
status,
message
}
}

/**
* Clears the message buffer
*
* @returns {{type}}
*
* @since 4.4
*/
export const clearConsole = () => {
return {
type: CLEAR_CONSOLE,
}
}

/**
* Adds a font to our retry list
*
* @param name
* @returns {{type, name: *}}
*
* @since 4.4
*/
export const addToRetryList = (name) => {
return {
type: ADD_TO_RETRY_LIST,
name
}
}

/**
* Clears our retry list
*
* @returns {{type}}
*
* @since 4.4
*/
export const clearRetryList = () => {
return {
type: CLEAR_RETRY_LIST,
}
}
53 changes: 53 additions & 0 deletions src/assets/js/react/bootstrap/coreFontBootstrap.js
@@ -0,0 +1,53 @@
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'

import { getStore } from '../store'
import Routes from '../router/coreFontRouter'

/**
* Core Font Downloader Bootstrap
*
* @package Gravity PDF
* @copyright Copyright (c) 2017, Blue Liquid Designs
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 4.4
*/

/*
This file is part of Gravity PDF.
Gravity PDF – Copyright (C) 2017, Blue Liquid Designs
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Found
*/

/**
* Mount our Core Font UI on the DOM
*
* @since 4.4
*/
export default function coreFontBootstrap () {
const container = document.getElementById('gfpdf-install-core-fonts')
const button = container.getElementsByTagName('button')[0]
const store = getStore()

render(
<Provider store={store}>
<Routes button={button}/>
</Provider>,
container
)
}

0 comments on commit b38eac6

Please sign in to comment.