Skip to content

Commit

Permalink
0.0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Wojtkowiak authored and wojtkowiak committed Oct 27, 2016
0 parents commit f04df1b
Show file tree
Hide file tree
Showing 22 changed files with 774 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["node6"]
}
16 changes: 16 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
engines:
duplication:
enabled: true
config:
languages:
- javascript
eslint:
enabled: true
channel: "eslint-3"
fixme:
enabled: true
ratings:
paths:
- "**.js"
exclude_paths: []
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# Change these settings to your own preference
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
36 changes: 36 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": "airbnb-base",
"env": {
"es6": true,
"browser": true,
"node": true
},
"plugins": [
"import"
],
"settings": {
"import/core-modules": [
"electron"
]
},
"rules": {
"indent": [
2,
4,
{
"SwitchCase": 1
}
],
"comma-dangle": [
0
],
"no-bitwise": [
0
],
"import/no-extraneous-dependencies": ["error",
{
"devDependencies": ["**/*.js"]
}
]
}
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.idea
dist
*.js___jb_tmp___
.testApp
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src
.idea
tests
*.js___jb_tmp___
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
language: node_js

node_js: "6"

os:
- linux
- osx
matrix:
fast_finish: true

branches:
only:
- master
- beta

before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
export DISPLAY=:99.0;
sh -e /etc/init.d/xvfb start;
sleep 8;
fi

cache:
directories:
- node_modules

notifications:
email:
on_success: never
on_failure: change
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2016 Bartosz Wojtkowiak <bartosz@wojtkowiak.it>

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.
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Meteor Desktop Splash Screen [![npm version](https://img.shields.io/npm/v/meteor-desktop-splash-screen.svg)](https://npmjs.org/package/meteor-desktop-splash-screen)

<sup>Travis</sup> [![Travis Build Status](https://travis-ci.org/wojtkowiak/meteor-desktop-splash-screen.svg?branch=master)](https://travis-ci.org/wojtkowiak/meteor-desktop-splash-screen) <sup>AppVeyor</sup> [![Build status](https://ci.appveyor.com/api/projects/status/f52xvrra1gouyg1t?svg=true)](https://ci.appveyor.com/project/wojtkowiak/meteor-desktop-splash-screen) <sup>CircleCI</sup> [![CircleCI](https://circleci.com/gh/wojtkowiak/meteor-desktop-splash-screen.svg?style=svg)](https://circleci.com/gh/wojtkowiak/meteor-desktop-splash-screen)

---
A nice splash screen for you Meteor app on desktop!

### Usage

In your `.desktop/settings.json` add this package to your plugins list:
```json
{
"plugins": {
"meteor-desktop-splash-screen": {
"version": "0.0.26"
}
}
}
```
Now place your logo in `.desktop/assets/splashScreen.png`. It should be a png with transparency.
__On Linux this does not look so nice because transparency is not supported in Electron [out of the box](https://github.com/electron/electron/blob/master/docs/api/frameless-window.md#limitations).__

### Settings

You can pass custom settings to the plugin, for example:
```json
{
"plugins": {
"meteor-desktop-splash-screen": {
"version": "0.0.26",
"style": {
"box-sizing": "border-box",
"border": "5px solid black",
"border-radius": "5px"
},
"imagePath": "mySplashLogo.png",
"windowSettings": { "width": 640, "height": 480 }
}
}
}
```
Note that `imagePath` should be relative to `assets` directory in your `.desktop`.

Here is a definition of what can be set:
```javascript
/**
* @typedef {Object} PluginSettings
* @property {boolean} enabled - is splash screen enabled
* @property {string} windowTitle - title of the window that shows splash screen - it defaults
* to the `name` from settings.json
* @property {string} imagePath - path to the image relative to the .desktop dir
* @property {Object} style - style of the html body that displays the image
* @property {Object} windowSettings - settings passed to BrowserWindow
* @property {Object} module - the Module class from Meteor Desktop
*/
```

If you have an icon set for the window in your settings.json it will be automatically used for splash screen's window - no need to set it here.

If you want to disable the splash screen temporarily for any reason you can use the `METEOR_DESKTOP_NO_SPLASH_SCREEN` env var.

### Contribution

PRs are always welcome. Be sure to update the tests.

For smooth developing process you need to open two terminals. In the first one type `npm run build-watch` and in the second `npm run test-watch`.

Tests are run by [AVA](https://github.com/avajs).

### Roadmap

- [ ] support different settings for different platforms

26 changes: 26 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
build: off

os: unstable

branches:
only:
- master
- beta

skip_tags: true

environment:
nodejs_version: "6.7.0"

cache:
- node_modules -> package.json

install:
- ps: Install-Product node $env:nodejs_version
- npm install npm
- .\node_modules\.bin\npm install

test_script:
- node --version
- .\node_modules\.bin\npm --version
- .\node_modules\.bin\npm test
11 changes: 11 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
machine:
node:
version: 6.7.0

dependencies:
override:
- npm install

test:
override:
- npm test
51 changes: 51 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "meteor-desktop-splash-screen",
"version": "0.0.27",
"engines": {
"node": ">=6.0.0"
},
"description": "Meteor Desktop splash screen plugin.",
"main": "dist/index.js",
"scripts": {
"test": "ava tests/functional/**/*.js --source dist/**/* -s",
"test-watch": "ava tests/functional/**/*.js --source src --watch --verbose -s",
"prepublish": "npm run build",
"lint": "eslint src tests",
"build": "babel src --out-dir dist --source-maps inline --copy-files",
"build-watch": "babel src --watch --out-dir dist --source-maps inline --copy-files",
"version": "node dist/scripts/propagateVersion.js && git add README.md"
},
"author": "Bartosz Wojtkowiak <bartosz@wojtkowiak.it>",
"license": "MIT",
"devDependencies": {
"ava": "^0.16.0",
"babel-cli": "^6.16.0",
"babel-preset-node6": "^11.0.0",
"eslint": "^3.8.1",
"eslint-config-airbnb-base": "^9.0.0",
"eslint-plugin-import": "^2.0.1",
"spectron": "^3.4.0",
"shelljs": "^0.7.5",
"electron": "^1.4.4",
"node-resemble-js": "^0.1.1",
"meteor-desktop-plugin-test-suite": "0.0.15"
},
"dependencies": {
},
"repository": {
"type": "git",
"url": "https://github.com/wojtkowiak/meteor-desktop-splash-screen"
},
"keywords": [
"electron",
"meteor",
"packager",
"desktop",
"splash",
"splashscreen"
],
"bugs": {
"url": "https://github.com/wojtkowiak/meteor-desktop-splash-screen/issues"
},
"homepage": "https://github.com/wojtkowiak/meteor-desktop-splash-screen"
}
81 changes: 81 additions & 0 deletions src/htmlBody.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import fs from 'fs';
import path from 'path';

/**
* Represents the HTML body of the window that should display the splash screen.
* @class
*/
export default class HtmlBody {
/**
* @param {Object} log - logger instance
* @param {string} templatePath - path to the template
* @param {string} installPath - installation path
* @param {string} title - title of the html
* @param {string} imagePath - path to the image
* @param {Object} style - styles to use instead of the defaults
*/
constructor(log, templatePath, installPath, title = '', imagePath = 'splashScreen.png',
style = {}) {
this.log = log;
this.templatePath = templatePath;
this.installPath = path.join(installPath, 'splash.html');
this.title = title;
this.imagePath = imagePath;
this.style = style;

let backgroundImageUrl = encodeURI(
path.join(installPath, 'desktop.asar', 'assets', this.imagePath).replace(/\\/gm, '/'));

if (process.env.ELECTRON_ENV === 'test' && process.env.SPLASH_SCREEN_TEST) {
backgroundImageUrl = encodeURI(
path.join(installPath, 'assets', this.imagePath).replace(/\\/gm, '/'));
}

this.defaultStyle = {
'background-image': `url(file:///${backgroundImageUrl})`,
'background-size': 'contain',
'background-repeat': 'no-repeat',
'background-attachment': 'fixed',
'background-position': 'center center',
'background-color': 'rgba(0, 0, 0, 0)'
};

// Apply custom style.
Object.keys(this.style).forEach((rule) => {
this.defaultStyle[rule] = this.style[rule];
});
}

/**
* Returns the css string from the style object.
* @returns {string}
*/
getStylesAsString() {
return Object.keys(this.defaultStyle).reduce(
(str, rule) => `${str}\n${rule}: ${this.defaultStyle[rule]};`, ''
);
}

/**
* Prepares the splash screen html.
*/
prepare() {
let splashHTML;
this.log.info('preparing splash screen.');

splashHTML = fs.readFileSync(this.templatePath, 'UTF-8');
splashHTML = splashHTML.replace('{title}', this.title);
splashHTML = splashHTML.replace('{style}', this.getStylesAsString());
fs.writeFileSync(this.installPath, splashHTML);

this.log.info('splash screen prepared.');
}

/**
* Install path getter.
* @returns {string}
*/
getInstallPath() {
return this.installPath;
}
}
Loading

0 comments on commit f04df1b

Please sign in to comment.