Skip to content

Commit

Permalink
Merge pull request #15 from lyonx/popup
Browse files Browse the repository at this point in the history
switch to in-app popup, add bundling
  • Loading branch information
bkalaldeh authored Apr 1, 2019
2 parents de837e7 + 2e4e06e commit 964a20d
Show file tree
Hide file tree
Showing 9 changed files with 8,682 additions and 190 deletions.
18 changes: 5 additions & 13 deletions control/content/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

(function (angular, buildfire) {
angular.module('googleAppsDocPluginContent', ['ui.bootstrap'])
.controller('ContentHomeCtrl', ['$scope', 'Buildfire', 'STATUS_CODE', 'TAG_NAMES', 'DataStore', 'Utils', '$timeout',
function ($scope, Buildfire, STATUS_CODE, TAG_NAMES, DataStore, Utils, $timeout) {
.controller('ContentHomeCtrl', ['TAG_NAMES', 'DataStore', 'Utils', '$timeout',
function (TAG_NAMES, DataStore, Utils, $timeout) {
var ContentHome = this;
ContentHome.validUrl = false;
ContentHome.inValidUrl = false;
ContentHome.MODE_TYPE = {};
ContentHome.MODE_TYPE.PREVIEW = 'preview';
ContentHome.MODE_TYPE.EDITABLE = 'editable';
ContentHome.mode = ContentHome.MODE_TYPE.PREVIEW;

ContentHome.data = {
content: {
"docUrl": "",
"mode": ""
"mode": "preview"
}
};

Expand All @@ -34,7 +30,6 @@

ContentHome.validateUrl = function () {
ContentHome.data.content.docUrl = ContentHome.docUrl;
ContentHome.data.content.mode = ContentHome.mode;
if (Utils.validateUrl(ContentHome.docUrl)) {
ContentHome.validUrl = true;
$timeout(function () {
Expand Down Expand Up @@ -87,20 +82,17 @@
ContentHome.data.content = {};
if (ContentHome.data.content.docUrl)
ContentHome.docUrl = ContentHome.data.content.docUrl;
if (ContentHome.data.content.mode)
ContentHome.mode = ContentHome.data.content.mode;
}
}else {
var dummyData = {url: "https://docs.google.com/document/d/1SqWeU4ewzXQBpR98TYGiBZ_iPdQH92wOb7jT0y-_Cbc/pub"};
ContentHome.docUrl = ContentHome.data.content.url = dummyData.url;
ContentHome.mode = ContentHome.MODE_TYPE.PREVIEW;
}
};
ContentHome.error = function (err) {
if (err && err.code !== STATUS_CODE.NOT_FOUND) {
if (err && err.code !== 'NOTFOUND') {
console.error('Error while getting data', err);
}
else if (err && err.code === STATUS_CODE.NOT_FOUND) {
else if (err && err.code === 'NOTFOUND') {
ContentHome.saveData(JSON.parse(angular.toJson(ContentHome.data)), TAG_NAMES.GOOGLE_DOC_INFO);
}
};
Expand Down
23 changes: 2 additions & 21 deletions control/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,15 @@
<script src="../../../../scripts/buildfire.js"></script>
<script src="../../../../scripts/angular/angular.min.js"></script>
<script src="../../../../scripts/angular/ui-bootstrap.min.js"></script>
<!-- build:bundleJSFiles -->
<script src="app.js"></script>
<script src="app.services.js"></script>
<script src="enums.js"></script>
<!-- endbuild -->
</head>
<body>
<div ng-controller="ContentHomeCtrl as ContentHome">
<div class="content">
<div class="item clearfix row">
<div class="labels col-md-3 padding-right-zero pull-left">
<span>Choose Mode</span>
</div>
<div class="main pull-right col-md-9 padding-left-zero row">
<div class="radio radio-primary radio-inline">
<input id="preview" type="radio" ng-model="ContentHome.mode"
ng-value='ContentHome.MODE_TYPE.PREVIEW' ng-se=""
name="mode"
ng-change="ContentHome.changeMode(ContentHome.MODE_TYPE.PREVIEW)">
<label for="preview">Preview Mode</label>
</div>
<div class="radio radio-primary radio-inline">
<input id="edit" type="radio" ng-model="ContentHome.mode"
ng-value='ContentHome.MODE_TYPE.EDITABLE'
name="mode"
ng-change="ContentHome.changeMode(ContentHome.MODE_TYPE.EDITABLE)">
<label for="edit">Editable Mode</label>
</div>
</div>
</div>
<hr class="none">
<div class="item clearfix row">
<div class="labels col-md-3 padding-right-zero pull-left">
Expand Down
169 changes: 169 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
const gulp = require('gulp');
const del = require('del');
const minHTML = require('gulp-htmlmin');
const minifyCSS = require('gulp-csso');
const concat = require('gulp-concat');
const strip = require('gulp-strip-comments');
let babel = require('gulp-babel');
const htmlReplace = require('gulp-html-replace');
const uglify = require('gulp-uglify');
const eslint = require('gulp-eslint');
const gulpSequence = require('gulp-sequence');
const minifyInline = require('gulp-minify-inline');
const gutil = require('gulp-util');

const destinationFolder= releaseFolder();

function releaseFolder() {
var arr = __dirname.split("/");
var fldr = arr.pop();
arr.push(fldr + "_release");
return arr.join("/");
}

console.log(">> Building to " , destinationFolder);

const cssTasks=[
{name:"widgetCSS", src: 'widget/**/*.css', dest:"/widget"}
,{name:"controlContentCSS",src:"control/content/**/*.css",dest:"/control/content"}
,{name:"controlDesignCSS",src:"control/design/**/*.css",dest:"/control/design"}
,{name:"controlSettingsCSS",src:"control/settings/**/*.css",dest:"/control/settings"}
];

cssTasks.forEach(function(task){
/*
Define a task called 'css' the recursively loops through
the widget and control folders, processes each CSS file and puts
a processes copy in the 'build' folder
note if the order matters you can import each css separately in the array
*/
gulp.task(task.name, function(){
return gulp.src(task.src,{base: '.'})

/// minify the CSS contents
.pipe(minifyCSS())

///merge
.pipe(concat('styles.min.css'))

/// write result to the 'build' folder
.pipe(gulp.dest(destinationFolder + task.dest))
});
});


const jsTasks = [
{ name: "widgetJS", src: "widget/**/*.js", dest: "/widget" },
{ name: "controlContentJS", src: "control/content/**/*.js", dest: "/control/content" },
{ name: "controlDesignJS", src: "control/design/**/*.js", dest: "/control/design" },
{ name: "controlSettingsJS", src: "control/settings/**/*.js", dest: "/control/settings" }
];



gulp.task('lint', () => {
// ESLint ignores files with "node_modules" paths.
// So, it's best to have gulp ignore the directory as well.
// Also, Be sure to return the stream from the task;
// Otherwise, the task may end before the stream has finished.
return gulp.src(['widget/**/*.js','control/**/*.js'])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint({
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"semi": [
"warn",
"always"
],
"no-console":[
"off"
]
}
}))
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
});

jsTasks.forEach(function(task){
gulp.task(task.name, function() {
return gulp.src(task.src,{base: '.'})


.pipe(babel({
presets: ['babel-preset-env']
}))
/// obfuscate and minify the JS files
.pipe(uglify())
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })

/// merge all the JS files together. If the
/// order matters you can pass each file to the function
/// in an array in the order you like
.pipe(concat('scripts.min.js'))
///output here
.pipe(gulp.dest(destinationFolder + task.dest));

});

});

gulp.task('clean',function(){
return del([destinationFolder],{force: true});
});

/*
Define a task called 'html' the recursively loops through
the widget and control folders, processes each html file and puts
a processes copy in the 'build' folder
*/
gulp.task('html', function(){
return gulp.src(['widget/**/*.html','widget/**/*.htm','control/**/*.html','control/**/*.htm'],{base: '.'})
/// replace all the <!-- build:bundleJSFiles --> comment bodies
/// with scripts.min.js with cache buster
.pipe(htmlReplace({
bundleJSFiles:"scripts.min.js?v=" + (new Date().getTime())
,bundleCSSFiles:"styles.min.css?v=" + (new Date().getTime())
}))

/// then strip the html from any comments
.pipe(minHTML({removeComments:true,collapseWhitespace:true}))

.pipe(minifyInline())

/// write results to the 'build' folder
.pipe(gulp.dest(destinationFolder));
});



gulp.task('resources', function(){
return gulp.src(['resources/*','widget/fonticons/**','plugin.json'],{base: '.'})
.pipe(gulp.dest(destinationFolder ));
});


gulp.task('images', function(){
return gulp.src(['**/.images/**','control/design/icons/**','control/design/layouts/**'],{base: '.'})
.pipe(gulp.dest(destinationFolder ));
});


var buildTasksToRun=['html','resources','images'];

cssTasks.forEach(function(task){ buildTasksToRun.push(task.name)});
jsTasks.forEach(function(task){ buildTasksToRun.push(task.name)});

gulp.task('build', gulpSequence('lint','clean',buildTasksToRun) );
Loading

0 comments on commit 964a20d

Please sign in to comment.