From ad125327c040830596736f9ac48f97763836318d Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Fri, 14 Apr 2017 18:47:33 +0100 Subject: [PATCH] Migrated to custom gulp setup and conintue search interface --- .gitignore | 1 - gulpfile.js | 63 ++++++++++ package.json | 45 ++++--- .../fonts/roboto-mono-v4-latin-regular.woff | Bin .../fonts/roboto-mono-v4-latin-regular.woff2 | Bin .../fonts/roboto-v15-cyrillic_latin-100.woff | Bin .../fonts/roboto-v15-cyrillic_latin-100.woff2 | Bin .../roboto-v15-cyrillic_latin-100italic.woff | Bin .../roboto-v15-cyrillic_latin-100italic.woff2 | Bin .../fonts/roboto-v15-cyrillic_latin-300.woff | Bin .../fonts/roboto-v15-cyrillic_latin-300.woff2 | Bin .../roboto-v15-cyrillic_latin-300italic.woff | Bin .../roboto-v15-cyrillic_latin-300italic.woff2 | Bin .../fonts/roboto-v15-cyrillic_latin-500.woff | Bin .../fonts/roboto-v15-cyrillic_latin-500.woff2 | Bin .../roboto-v15-cyrillic_latin-500italic.woff | Bin .../roboto-v15-cyrillic_latin-500italic.woff2 | Bin .../fonts/roboto-v15-cyrillic_latin-700.woff | Bin .../fonts/roboto-v15-cyrillic_latin-700.woff2 | Bin .../roboto-v15-cyrillic_latin-700italic.woff | Bin .../roboto-v15-cyrillic_latin-700italic.woff2 | Bin .../roboto-v15-cyrillic_latin-italic.woff | Bin .../roboto-v15-cyrillic_latin-italic.woff2 | Bin .../roboto-v15-cyrillic_latin-regular.woff | Bin .../roboto-v15-cyrillic_latin-regular.woff2 | Bin public/mix-manifest.json | 7 -- resources/assets/js/controllers.js | 8 +- resources/assets/js/directives.js | 6 +- resources/assets/js/global.js | 32 ++--- resources/assets/js/pages/page-form.js | 4 +- resources/assets/js/pages/page-show.js | 6 +- resources/assets/js/translations.js | 2 +- resources/assets/js/vues/search.js | 116 ++++++++++++++++-- resources/assets/js/vues/vues.js | 1 + resources/assets/sass/_fonts.scss | 44 +++---- resources/views/base.blade.php | 1 - resources/views/search/all.blade.php | 93 ++++++++++++-- webpack.mix.js | 18 --- 38 files changed, 337 insertions(+), 110 deletions(-) create mode 100644 gulpfile.js rename {resources/assets => public}/fonts/roboto-mono-v4-latin-regular.woff (100%) rename {resources/assets => public}/fonts/roboto-mono-v4-latin-regular.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-100.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-100.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-100italic.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-100italic.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-300.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-300.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-300italic.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-300italic.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-500.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-500.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-500italic.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-500italic.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-700.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-700.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-700italic.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-700italic.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-italic.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-italic.woff2 (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-regular.woff (100%) rename {resources/assets => public}/fonts/roboto-v15-cyrillic_latin-regular.woff2 (100%) delete mode 100644 public/mix-manifest.json delete mode 100644 webpack.mix.js diff --git a/.gitignore b/.gitignore index 856cf3722..5f41a864e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ Homestead.yaml /public/plugins /public/css /public/js -/public/fonts /public/bower /storage/images _ide_helper.php diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 000000000..b72bb366d --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,63 @@ +const argv = require('yargs').argv; +const gulp = require('gulp'), + plumber = require('gulp-plumber'); +const autoprefixer = require('gulp-autoprefixer'); +const uglify = require('gulp-uglify'); +const minifycss = require('gulp-clean-css'); +const sass = require('gulp-sass'); +const browserify = require("browserify"); +const source = require('vinyl-source-stream'); +const buffer = require('vinyl-buffer'); +const babelify = require("babelify"); +const watchify = require("watchify"); +const envify = require("envify"); +const gutil = require("gulp-util"); + +if (argv.production) process.env.NODE_ENV = 'production'; + +gulp.task('styles', () => { + let chain = gulp.src(['resources/assets/sass/**/*.scss']) + .pipe(plumber({ + errorHandler: function (error) { + console.log(error.message); + this.emit('end'); + }})) + .pipe(sass()) + .pipe(autoprefixer('last 2 versions')); + if (argv.production) chain = chain.pipe(minifycss()); + return chain.pipe(gulp.dest('public/css/')); +}); + + +function scriptTask(watch=false) { + + let props = { + basedir: 'resources/assets/js', + debug: true, + entries: ['global.js'] + }; + + let bundler = watch ? watchify(browserify(props), { poll: true }) : browserify(props); + bundler.transform(envify, {global: true}).transform(babelify, {presets: ['es2015']}); + function rebundle() { + let stream = bundler.bundle(); + stream = stream.pipe(source('common.js')); + if (argv.production) stream = stream.pipe(buffer()).pipe(uglify()); + return stream.pipe(gulp.dest('public/js/')); + } + bundler.on('update', function() { + rebundle(); + gutil.log('Rebundle...'); + }); + bundler.on('log', gutil.log); + return rebundle(); +} + +gulp.task('scripts', () => {scriptTask(false)}); +gulp.task('scripts-watch', () => {scriptTask(true)}); + +gulp.task('default', ['styles', 'scripts-watch'], () => { + gulp.watch("resources/assets/sass/**/*.scss", ['styles']); +}); + +gulp.task('build', ['styles', 'scripts']); \ No newline at end of file diff --git a/package.json b/package.json index 1d7e8e268..9f2ce4c1a 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,43 @@ { "private": true, "scripts": { - "dev": "npm run development", - "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch-poll": "npm run watch -- --watch-poll", - "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", - "prod": "npm run production", - "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + "build": "gulp build", + "production": "gulp build --production", + "dev": "gulp", + "watch": "gulp" }, "devDependencies": { + "babelify": "^7.3.0", + "browserify": "^14.3.0", + "envify": "^4.0.0", + "gulp": "3.9.1", + "gulp-autoprefixer": "3.1.1", + "gulp-clean-css": "^3.0.4", + "gulp-minify-css": "1.2.4", + "gulp-plumber": "1.1.0", + "gulp-sass": "3.1.0", + "gulp-uglify": "2.1.2", + "vinyl-buffer": "^1.0.0", + "vinyl-source-stream": "^1.1.0", + "watchify": "^3.9.0", + "yargs": "^7.1.0" + }, + "dependencies": { "angular": "^1.5.5", "angular-animate": "^1.5.5", "angular-resource": "^1.5.5", "angular-sanitize": "^1.5.5", - "angular-ui-sortable": "^0.15.0", - "cross-env": "^3.2.3", - "dropzone": "^4.0.1", - "gulp": "^3.9.0", - "laravel-mix": "0.*", - "marked": "^0.3.5", - "moment": "^2.12.0" - }, - "dependencies": { + "angular-ui-sortable": "^0.17.0", "axios": "^0.16.1", + "babel-preset-es2015": "^6.24.1", "clipboard": "^1.5.16", + "dropzone": "^4.0.1", + "gulp-util": "^3.0.8", + "marked": "^0.3.5", + "moment": "^2.12.0", "vue": "^2.2.6" + }, + "browser": { + "vue": "vue/dist/vue.common.js" } } diff --git a/resources/assets/fonts/roboto-mono-v4-latin-regular.woff b/public/fonts/roboto-mono-v4-latin-regular.woff similarity index 100% rename from resources/assets/fonts/roboto-mono-v4-latin-regular.woff rename to public/fonts/roboto-mono-v4-latin-regular.woff diff --git a/resources/assets/fonts/roboto-mono-v4-latin-regular.woff2 b/public/fonts/roboto-mono-v4-latin-regular.woff2 similarity index 100% rename from resources/assets/fonts/roboto-mono-v4-latin-regular.woff2 rename to public/fonts/roboto-mono-v4-latin-regular.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-100.woff b/public/fonts/roboto-v15-cyrillic_latin-100.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-100.woff rename to public/fonts/roboto-v15-cyrillic_latin-100.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-100.woff2 b/public/fonts/roboto-v15-cyrillic_latin-100.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-100.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-100.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-100italic.woff b/public/fonts/roboto-v15-cyrillic_latin-100italic.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-100italic.woff rename to public/fonts/roboto-v15-cyrillic_latin-100italic.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-100italic.woff2 b/public/fonts/roboto-v15-cyrillic_latin-100italic.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-100italic.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-100italic.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-300.woff b/public/fonts/roboto-v15-cyrillic_latin-300.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-300.woff rename to public/fonts/roboto-v15-cyrillic_latin-300.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-300.woff2 b/public/fonts/roboto-v15-cyrillic_latin-300.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-300.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-300.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-300italic.woff b/public/fonts/roboto-v15-cyrillic_latin-300italic.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-300italic.woff rename to public/fonts/roboto-v15-cyrillic_latin-300italic.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-300italic.woff2 b/public/fonts/roboto-v15-cyrillic_latin-300italic.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-300italic.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-300italic.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-500.woff b/public/fonts/roboto-v15-cyrillic_latin-500.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-500.woff rename to public/fonts/roboto-v15-cyrillic_latin-500.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-500.woff2 b/public/fonts/roboto-v15-cyrillic_latin-500.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-500.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-500.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-500italic.woff b/public/fonts/roboto-v15-cyrillic_latin-500italic.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-500italic.woff rename to public/fonts/roboto-v15-cyrillic_latin-500italic.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-500italic.woff2 b/public/fonts/roboto-v15-cyrillic_latin-500italic.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-500italic.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-500italic.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-700.woff b/public/fonts/roboto-v15-cyrillic_latin-700.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-700.woff rename to public/fonts/roboto-v15-cyrillic_latin-700.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-700.woff2 b/public/fonts/roboto-v15-cyrillic_latin-700.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-700.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-700.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-700italic.woff b/public/fonts/roboto-v15-cyrillic_latin-700italic.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-700italic.woff rename to public/fonts/roboto-v15-cyrillic_latin-700italic.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-700italic.woff2 b/public/fonts/roboto-v15-cyrillic_latin-700italic.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-700italic.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-700italic.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-italic.woff b/public/fonts/roboto-v15-cyrillic_latin-italic.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-italic.woff rename to public/fonts/roboto-v15-cyrillic_latin-italic.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-italic.woff2 b/public/fonts/roboto-v15-cyrillic_latin-italic.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-italic.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-italic.woff2 diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-regular.woff b/public/fonts/roboto-v15-cyrillic_latin-regular.woff similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-regular.woff rename to public/fonts/roboto-v15-cyrillic_latin-regular.woff diff --git a/resources/assets/fonts/roboto-v15-cyrillic_latin-regular.woff2 b/public/fonts/roboto-v15-cyrillic_latin-regular.woff2 similarity index 100% rename from resources/assets/fonts/roboto-v15-cyrillic_latin-regular.woff2 rename to public/fonts/roboto-v15-cyrillic_latin-regular.woff2 diff --git a/public/mix-manifest.json b/public/mix-manifest.json deleted file mode 100644 index 3885bcd54..000000000 --- a/public/mix-manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "/js/common.js": "/js/common.js", - "/css/styles.css": "/css/styles.css", - "/css/print-styles.css": "/css/print-styles.css", - "/css/export-styles.css": "/css/export-styles.css", - "/js/vues.js": "/js/vues.js" -} \ No newline at end of file diff --git a/resources/assets/js/controllers.js b/resources/assets/js/controllers.js index 0d57b09ad..c5baecf16 100644 --- a/resources/assets/js/controllers.js +++ b/resources/assets/js/controllers.js @@ -1,12 +1,12 @@ "use strict"; -import moment from 'moment'; -import 'moment/locale/en-gb'; -import editorOptions from "./pages/page-form"; +const moment = require('moment'); +require('moment/locale/en-gb'); +const editorOptions = require("./pages/page-form"); moment.locale('en-gb'); -export default function (ngApp, events) { +module.exports = function (ngApp, events) { ngApp.controller('ImageManagerController', ['$scope', '$attrs', '$http', '$timeout', 'imageManagerService', function ($scope, $attrs, $http, $timeout, imageManagerService) { diff --git a/resources/assets/js/directives.js b/resources/assets/js/directives.js index 10458e753..19badcac8 100644 --- a/resources/assets/js/directives.js +++ b/resources/assets/js/directives.js @@ -1,8 +1,8 @@ "use strict"; -import DropZone from "dropzone"; -import markdown from "marked"; +const DropZone = require("dropzone"); +const markdown = require("marked"); -export default function (ngApp, events) { +module.exports = function (ngApp, events) { /** * Common tab controls using simple jQuery functions. diff --git a/resources/assets/js/global.js b/resources/assets/js/global.js index 7c980f6e9..dc6802e12 100644 --- a/resources/assets/js/global.js +++ b/resources/assets/js/global.js @@ -8,33 +8,33 @@ window.baseUrl = function(path) { return basePath + '/' + path; }; -// Vue and axios setup -import vue from "vue/dist/vue.common"; -import axios from "axios"; +const Vue = require("vue"); +const axios = require("axios"); let axiosInstance = axios.create({ headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name=token]').getAttribute('content'), - 'baseURL': baseUrl('') + 'baseURL': window.baseUrl('') } }); -window.Vue = vue; -window.axios = axiosInstance; Vue.prototype.$http = axiosInstance; +require("./vues/vues"); + + // AngularJS - Create application and load components -import angular from "angular"; -import "angular-resource"; -import "angular-animate"; -import "angular-sanitize"; -import "angular-ui-sortable"; +const angular = require("angular"); +require("angular-resource"); +require("angular-animate"); +require("angular-sanitize"); +require("angular-ui-sortable"); let ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize', 'ui.sortable']); // Translation setup // Creates a global function with name 'trans' to be used in the same way as Laravel's translation system -import Translations from "./translations" +const Translations = require("./translations"); let translator = new Translations(window.translations); window.trans = translator.get.bind(translator); @@ -65,9 +65,9 @@ window.Events = new EventManager(); Vue.prototype.$events = window.Events; // Load in angular specific items -import Services from './services'; -import Directives from './directives'; -import Controllers from './controllers'; +const Services = require('./services'); +const Directives = require('./directives'); +const Controllers = require('./controllers'); Services(ngApp, window.Events); Directives(ngApp, window.Events); Controllers(ngApp, window.Events); @@ -170,4 +170,4 @@ if(navigator.userAgent.indexOf('MSIE')!==-1 } // Page specific items -import "./pages/page-show"; +require("./pages/page-show"); diff --git a/resources/assets/js/pages/page-form.js b/resources/assets/js/pages/page-form.js index 0f44b3d09..b5a0a2998 100644 --- a/resources/assets/js/pages/page-form.js +++ b/resources/assets/js/pages/page-form.js @@ -60,7 +60,7 @@ function registerEditorShortcuts(editor) { editor.addShortcut('meta+shift+E', '', ['FormatBlock', false, 'code']); } -export default function() { +module.exports = function() { let settings = { selector: '#html-editor', content_css: [ @@ -213,4 +213,4 @@ export default function() { } }; return settings; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/resources/assets/js/pages/page-show.js b/resources/assets/js/pages/page-show.js index 0f45e1987..cc6296434 100644 --- a/resources/assets/js/pages/page-show.js +++ b/resources/assets/js/pages/page-show.js @@ -1,8 +1,8 @@ "use strict"; // Configure ZeroClipboard -import Clipboard from "clipboard"; +const Clipboard = require("clipboard"); -export default window.setupPageShow = function (pageId) { +let setupPageShow = window.setupPageShow = function (pageId) { // Set up pointer let $pointer = $('#pointer').detach(); @@ -151,3 +151,5 @@ export default window.setupPageShow = function (pageId) { }); }; + +module.exports = setupPageShow; \ No newline at end of file diff --git a/resources/assets/js/translations.js b/resources/assets/js/translations.js index 306c696b6..ca6a7bd29 100644 --- a/resources/assets/js/translations.js +++ b/resources/assets/js/translations.js @@ -44,4 +44,4 @@ class Translator { } -export default Translator +module.exports = Translator; diff --git a/resources/assets/js/vues/search.js b/resources/assets/js/vues/search.js index 708418271..710f4b214 100644 --- a/resources/assets/js/vues/search.js +++ b/resources/assets/js/vues/search.js @@ -1,16 +1,18 @@ - -let termString = document.querySelector('[name=searchTerm]').value; -let terms = termString.split(' '); +const moment = require('moment'); let data = { - terms: terms, - termString : termString, - search: { + terms: '', + termString : '', + search: { type: { page: true, chapter: true, book: true - } + }, + exactTerms: [], + tagTerms: [], + option: {}, + dates: {} } }; @@ -21,8 +23,76 @@ let computed = { let methods = { appendTerm(term) { - if (this.termString.slice(-1) !== " ") this.termString += ' '; - this.termString += term; + this.termString += ' ' + term; + this.termString = this.termString.replace(/\s{2,}/g, ' '); + this.termString = this.termString.replace(/^\s+/, ''); + this.termString = this.termString.replace(/\s+$/, ''); + }, + + exactParse(searchString) { + this.search.exactTerms = []; + let exactFilter = /"(.+?)"/g; + let matches; + while ((matches = exactFilter.exec(searchString)) !== null) { + this.search.exactTerms.push(matches[1]); + } + }, + + exactChange() { + let exactFilter = /"(.+?)"/g; + this.termString = this.termString.replace(exactFilter, ''); + let matchesTerm = this.search.exactTerms.filter(term => { + return term.trim() !== ''; + }).map(term => { + return `"${term}"` + }).join(' '); + this.appendTerm(matchesTerm); + }, + + addExact() { + this.search.exactTerms.push(''); + setTimeout(() => { + let exactInputs = document.querySelectorAll('.exact-input'); + exactInputs[exactInputs.length - 1].focus(); + }, 100); + }, + + removeExact(index) { + this.search.exactTerms.splice(index, 1); + this.exactChange(); + }, + + tagParse(searchString) { + this.search.tagTerms = []; + let tagFilter = /\[(.+?)\]/g; + let matches; + while ((matches = tagFilter.exec(searchString)) !== null) { + this.search.tagTerms.push(matches[1]); + } + }, + + tagChange() { + let tagFilter = /\[(.+?)\]/g; + this.termString = this.termString.replace(tagFilter, ''); + let matchesTerm = this.search.tagTerms.filter(term => { + return term.trim() !== ''; + }).map(term => { + return `[${term}]` + }).join(' '); + this.appendTerm(matchesTerm); + }, + + addTag() { + this.search.tagTerms.push(''); + setTimeout(() => { + let tagInputs = document.querySelectorAll('.tag-input'); + tagInputs[tagInputs.length - 1].focus(); + }, 100); + }, + + removeTag(index) { + this.search.tagTerms.splice(index, 1); + this.tagChange(); }, typeParse(searchString) { @@ -55,14 +125,40 @@ let methods = { this.appendTerm(typeTerm); }, - updateSearch() { + optionParse(searchString) { + let optionFilter = /{([a-z_-]+?)}/gi; + let matches; + while ((matches = optionFilter.exec(searchString)) !== null) { + this.search.option[matches[1].toLowerCase()] = true; + } + }, + + optionChange(optionName) { + let isChecked = this.search.option[optionName]; + if (isChecked) { + this.appendTerm(`{${optionName}}`); + } else { + this.termString = this.termString.replace(`{${optionName}}`, ''); + } + }, + + updateSearch(e) { + e.preventDefault(); window.location = '/search?term=' + encodeURIComponent(this.termString); + }, + + enableDate(optionName) { + this.search.dates[optionName] = moment().format('YYYY-MM-DD'); } }; function created() { + this.termString = document.querySelector('[name=searchTerm]').value; this.typeParse(this.termString); + this.exactParse(this.termString); + this.tagParse(this.termString); + this.optionParse(this.termString); } module.exports = { diff --git a/resources/assets/js/vues/vues.js b/resources/assets/js/vues/vues.js index d50018598..832a5415d 100644 --- a/resources/assets/js/vues/vues.js +++ b/resources/assets/js/vues/vues.js @@ -1,3 +1,4 @@ +const Vue = require("vue"); function exists(id) { return document.getElementById(id) !== null; diff --git a/resources/assets/sass/_fonts.scss b/resources/assets/sass/_fonts.scss index 7d19f051c..c8e8ea833 100644 --- a/resources/assets/sass/_fonts.scss +++ b/resources/assets/sass/_fonts.scss @@ -6,8 +6,8 @@ font-style: normal; font-weight: 100; src: local('Roboto Thin'), local('Roboto-Thin'), - url('assets/fonts/roboto-v15-cyrillic_latin-100.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-100.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-100.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-100.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-100italic - cyrillic_latin */ @font-face { @@ -15,8 +15,8 @@ font-style: italic; font-weight: 100; src: local('Roboto Thin Italic'), local('Roboto-ThinItalic'), - url('assets/fonts/roboto-v15-cyrillic_latin-100italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-100italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-100italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-100italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-300 - cyrillic_latin */ @font-face { @@ -24,8 +24,8 @@ font-style: normal; font-weight: 300; src: local('Roboto Light'), local('Roboto-Light'), - url('assets/fonts/roboto-v15-cyrillic_latin-300.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-300.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-300.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-300.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-300italic - cyrillic_latin */ @font-face { @@ -33,8 +33,8 @@ font-style: italic; font-weight: 300; src: local('Roboto Light Italic'), local('Roboto-LightItalic'), - url('assets/fonts/roboto-v15-cyrillic_latin-300italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-300italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-300italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-300italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-regular - cyrillic_latin */ @font-face { @@ -42,8 +42,8 @@ font-style: normal; font-weight: 400; src: local('Roboto'), local('Roboto-Regular'), - url('assets/fonts/roboto-v15-cyrillic_latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-italic - cyrillic_latin */ @font-face { @@ -51,8 +51,8 @@ font-style: italic; font-weight: 400; src: local('Roboto Italic'), local('Roboto-Italic'), - url('assets/fonts/roboto-v15-cyrillic_latin-italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-500 - cyrillic_latin */ @font-face { @@ -60,8 +60,8 @@ font-style: normal; font-weight: 500; src: local('Roboto Medium'), local('Roboto-Medium'), - url('assets/fonts/roboto-v15-cyrillic_latin-500.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-500.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-500.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-500.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-500italic - cyrillic_latin */ @font-face { @@ -69,8 +69,8 @@ font-style: italic; font-weight: 500; src: local('Roboto Medium Italic'), local('Roboto-MediumItalic'), - url('assets/fonts/roboto-v15-cyrillic_latin-500italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-500italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-500italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-500italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-700 - cyrillic_latin */ @font-face { @@ -78,8 +78,8 @@ font-style: normal; font-weight: 700; src: local('Roboto Bold'), local('Roboto-Bold'), - url('assets/fonts/roboto-v15-cyrillic_latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-700italic - cyrillic_latin */ @font-face { @@ -87,8 +87,8 @@ font-style: italic; font-weight: 700; src: local('Roboto Bold Italic'), local('Roboto-BoldItalic'), - url('assets/fonts/roboto-v15-cyrillic_latin-700italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-v15-cyrillic_latin-700italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-v15-cyrillic_latin-700italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-v15-cyrillic_latin-700italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } /* roboto-mono-regular - latin */ @@ -97,6 +97,6 @@ font-style: normal; font-weight: 400; src: local('Roboto Mono'), local('RobotoMono-Regular'), - url('assets/fonts/roboto-mono-v4-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ - url('assets/fonts/roboto-mono-v4-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ + url('../fonts/roboto-mono-v4-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+ */ + url('../fonts/roboto-mono-v4-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */ } \ No newline at end of file diff --git a/resources/views/base.blade.php b/resources/views/base.blade.php index 2251ed2df..95a9d72b0 100644 --- a/resources/views/base.blade.php +++ b/resources/views/base.blade.php @@ -84,7 +84,6 @@ @yield('bottom') - @yield('scripts') diff --git a/resources/views/search/all.blade.php b/resources/views/search/all.blade.php index ac5cd7db4..d1f928912 100644 --- a/resources/views/search/all.blade.php +++ b/resources/views/search/all.blade.php @@ -33,15 +33,94 @@

Search Filters

-

Content Type

-
- - - -
+
+

Content Type

+
+ + + +
+ +

Exact Matches

+ + + + + + + + +
+ + +
+ +
+ +

Tag Searches

+ + + + + + + + +
+ + +
+ +
+ +

Options

+ + + +

Date Options

+ + + + + + + + + +
Updated After + + + + +
+ +
+ + + +
-
diff --git a/webpack.mix.js b/webpack.mix.js deleted file mode 100644 index 2e691bd50..000000000 --- a/webpack.mix.js +++ /dev/null @@ -1,18 +0,0 @@ -const { mix } = require('laravel-mix'); - -/* - |-------------------------------------------------------------------------- - | Mix Asset Management - |-------------------------------------------------------------------------- - | - | Mix provides a clean, fluent API for defining some Webpack build steps - | for your Laravel application. By default, we are compiling the Sass - | file for the application as well as bundling up all the JS files. - | - */ - -mix.js('resources/assets/js/global.js', './public/js/common.js') - .js('resources/assets/js/vues/vues.js', './public/js/vues.js') - .sass('resources/assets/sass/styles.scss', 'public/css') - .sass('resources/assets/sass/print-styles.scss', 'public/css') - .sass('resources/assets/sass/export-styles.scss', 'public/css');