Skip to content

Commit

Permalink
Merge branch 'build/1.x' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyaigpetrov committed Jun 9, 2017
2 parents 2333a3b + 46f2a00 commit 336ec6c
Show file tree
Hide file tree
Showing 53 changed files with 8,107 additions and 1,506 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ This repo contains:
[WebStore](https://chrome.google.com/webstore/detail/npgcnondjocldhldegnakemclmfkngch)
| [Sources](https://github.com/ilyaigpetrov/anti-censorship-russia/tree/master/extensions/chromium/minimalistic-pac-setter)
2. Proof of concept PAC-script generator based on https://github.com/zapret-info/z-i
3. PAC-scripts performance analyses of scripts generated
3. ~~PAC-scripts performance analyses of scripts generated~~ (doesn't take parse time into account)
4. Based on the research of step 3 [the final PAC-generator][pac-generator] was written as a Google App Script in JavaScript which is triggered every two hours to generate and publish PAC-script on Google Drive (don't use direct URL without extension, please, URL will be periodically changed to counter abuse).

[pac-generator]: https://script.google.com/d/18EG6_pPuSqzJaCU8ePzt_VfbvBI2maBIr5O8EMfktkBd5NNYKv8VvG4Y/edit?usp=sharing
[pac-generator]: https://script.google.com/d/1iSwFilpiahetZ9hNPUK5SATjrNoZ_4i7aV9TWSp58LBhcyg_TuK_Qb5S/edit?usp=sharing

## Why I do This

Expand Down
4 changes: 3 additions & 1 deletion extensions/chromium/runet-censorship-bypass/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
node_modules_linux
node_modules_win
npm-debug.log
.swp
*.swp
build/
53 changes: 38 additions & 15 deletions extensions/chromium/runet-censorship-bypass/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const gulp = require('gulp');
const del = require('del');
const through = require('through2');
const PluginError = require('gulp-util').PluginError;
const changed = require('gulp-changed');

const PluginName = 'Template literals';

Expand All @@ -21,7 +22,7 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {

const {keys, values} = Object.keys(context).reduce( (acc, key) => {

const value = context[key];
const value = context[key];
acc.keys.push(key);
acc.values.push(value);
return acc;
Expand All @@ -44,39 +45,61 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {

gulp.task('default', ['build']);

gulp.task('clean', function() {
gulp.task('clean', function(cb) {

return del.sync('./build');
//return del.sync('./build');
return cb();

});

const contexts = require('./src/templates-data').contexts;

gulp.task('_cp-common', ['clean'], function() {
const excFolder = (name) => [`!./src/**/${name}`, `!./src/**/${name}/**/*`];
const excluded = [ ...excFolder('test') , ...excFolder('node_modules'), ...excFolder('src') ];
const commonWoTests = ['./src/extension-common/**/*', ...excluded];

gulp.src(['./src/extension-common/**/*'])
const miniDst = './build/extension-mini';
const fullDst = './build/extension-full';

gulp.task('_cp-common', ['clean'], function(cb) {

let fins = 0;
const intheend = () => {
if (++fins === 2) {
cb();
}
};

gulp.src(commonWoTests)
.pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini))
.pipe(gulp.dest('./build/extension-mini'))
.pipe(gulp.dest(miniDst))
.on('end', intheend);

gulp.src(['./src/extension-common/**/*'])
gulp.src(commonWoTests)
.pipe(changed(fullDst))
.pipe(templatePlugin(contexts.full))
.pipe(gulp.dest('./build/extension-full'));
.pipe(gulp.dest(fullDst))
.on('end', intheend);

});

gulp.task('_cp-mini', ['_cp-common'], function() {
gulp.task('_cp-mini', ['_cp-common'], function(cb) {

gulp.src(['./src/extension-mini/**/*'])
gulp.src(['./src/extension-mini/**/*', ...excluded])
.pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini))
.pipe(gulp.dest('./build/extension-mini'));

.pipe(gulp.dest(miniDst))
.on('end', cb);
});

gulp.task('_cp-full', ['_cp-common'], function() {
gulp.task('_cp-full', ['_cp-common'], function(cb) {

gulp.src(['./src/extension-full/**/*'])
gulp.src(['./src/extension-full/**/*', ...excluded])
.pipe(changed(fullDst))
.pipe(templatePlugin(contexts.full))
.pipe(gulp.dest('./build/extension-full'));
.pipe(gulp.dest(fullDst))
.on('end', cb);

});

Expand Down
11 changes: 9 additions & 2 deletions extensions/chromium/runet-censorship-bypass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
"version": "0.0.19",
"description": "Development tools for chromium extension",
"scripts": {
"postinstall": "node --use_strict -e \"const fs = require('fs'), path = 'node_modules/_project-root'; fs.unlink(path, ()=> fs.symlinkSync('..', path, 'dir'));\"",
"lint": "eslint ./src/**/*.js --ignore-pattern vendor",
"gulp": "gulp"
"gulp": "gulp",
"test": "mocha --recursive ./src/**/test/*",
"start": "cd ./src/extension-common/pages/options/ && npm run build && cd - && npm run gulp"
},
"author": "Ilya Ig. Petrov",
"license": "GPLv3",
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^3.15.0",
"eslint-config-google": "^0.7.1"
"eslint-config-google": "^0.7.1",
"gulp-changed": "^3.1.0",
"mocha": "^3.3.0",
"sinon-chrome": "^2.2.1"
},
"dependencies": {
"del": "^2.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,16 @@

key = prefix + key;
if (value === null) {
return localStorage.removeItem(key);
return window.localStorage.removeItem(key);
}
if (value === undefined) {
const item = localStorage.getItem(key);
const item = window.localStorage.getItem(key);
return item && JSON.parse(item);
}
if (value instanceof Date) {
throw new TypeError('Converting Date format to JSON is not supported.');
}
localStorage.setItem(key, JSON.stringify(value));
window.localStorage.setItem(key, JSON.stringify(value));

};

Expand Down Expand Up @@ -188,6 +188,7 @@
window.apis = {
version: {
ifMini: false,
build: chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, ''),
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

const ifPrefix = 'if-on-';
const extName = chrome.runtime.getManifest().name;
const extVersion = chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, '');
const extVersion = window.apis.version.build;

window.apis.errorHandlers = {

Expand Down
Loading

0 comments on commit 336ec6c

Please sign in to comment.