From 714ceb2ac84504468d45615213f1855124de8f8b Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Fri, 11 Nov 2016 21:28:00 +0300 Subject: [PATCH 001/368] [sync] + pages support --- utils/Sync/settings.py | 2 + utils/Sync/sync.py | 2 + utils/Sync/sync/__init__.py | 10 ++ utils/Sync/sync/core/__init__.py | 3 + utils/Sync/sync/page.py | 148 +++++++++++++++++++++++++++++ utils/Sync/utils/text/transform.py | 15 ++- 6 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 utils/Sync/sync/page.py diff --git a/utils/Sync/settings.py b/utils/Sync/settings.py index a77ffb29..73ceac37 100644 --- a/utils/Sync/settings.py +++ b/utils/Sync/settings.py @@ -97,6 +97,7 @@ collection_events = 'events' collection_news = 'timeline' collection_collective = 'collective' collection_albums = 'albums' +collection_pages = 'pages' sync_provider_type = env('SYNC_PROVIDER', 'fs') @@ -112,6 +113,7 @@ dir_events = f('Hudozka/Site/Events') dir_news = f('Hudozka/Site/News') dir_collective = f('Hudozka/Site/Collective') dir_gallery = f('Hudozka/Site/Gallery') +dir_pages = f('Hudozka/Site/Pages') dir_static = env('SYNC_STATIC', '~/Hudozka Static') dir_static_uploads = absolute(dir_static + '/uploads') diff --git a/utils/Sync/sync.py b/utils/Sync/sync.py index 263da35e..533a4359 100644 --- a/utils/Sync/sync.py +++ b/utils/Sync/sync.py @@ -4,6 +4,7 @@ from sync.album import sync_albums from sync.data.fs import FSProvider from sync.data.yandexdisk import YDProvider from sync.document import sync_documents +from sync.page import sync_pages from sync.person import sync_persons from sync.post import sync_posts from sync.schedule import sync_schedules @@ -42,3 +43,4 @@ if __name__ == '__main__': main(io(settings.dir_news), sync_posts, settings.collection_news) main(io(settings.dir_collective), sync_persons, settings.collection_collective) main(io(settings.dir_gallery), sync_albums, settings.collection_albums) + main(io(settings.dir_pages), sync_pages, settings.collection_pages) diff --git a/utils/Sync/sync/__init__.py b/utils/Sync/sync/__init__.py index d2a37c33..879a2b4b 100644 --- a/utils/Sync/sync/__init__.py +++ b/utils/Sync/sync/__init__.py @@ -93,6 +93,16 @@ def images_from_html(md): return images +def title_from_html(md): + if not md: + return None + + doc = lxml.html.fromstring(md) + ts = doc.cssselect('h1') + if len(ts): + return ts[0].text + + create_post_from_image_list = lambda images: markdown( '\n'.join(map( lambda i: '![]({img})'.format(img=i), diff --git a/utils/Sync/sync/core/__init__.py b/utils/Sync/sync/core/__init__.py index 483d75f5..14e73d43 100644 --- a/utils/Sync/sync/core/__init__.py +++ b/utils/Sync/sync/core/__init__.py @@ -49,3 +49,6 @@ class Sync: def create_hash(self, document): return None + + def create_remove_query(self, query): + return query diff --git a/utils/Sync/sync/page.py b/utils/Sync/sync/page.py new file mode 100644 index 00000000..3c0217a8 --- /dev/null +++ b/utils/Sync/sync/page.py @@ -0,0 +1,148 @@ +import os + +import settings +from sync.core import Sync +from sync.data import list_images +from sync import create_date_and_title_from_folder_name, create_post_from_image_list, create_date, images_from_html, \ + synced_images_ids, untouched, title_from_html +from sync.core.post import SyncPost +from utils.fn import lmap, map_cases, first, key_mapper, lmapfn, constant +from utils.hash import hash_str +from utils.io import read_yaml_md +from utils.text.transform import url_encode_text + + +def create_document_from_folder(provider, path): + document = { + 'file': os.path.basename(path), + 'folder': os.path.dirname(path), + 'title': os.path.basename(path), + } + + manifest = get_manifest(provider, path) + document = { + **document, + **manifest, + } + + if 'url' not in document: + return None + + document = create_id(document) + document = create_hash(provider, document) + return document + + +def get_manifest(provider, path): + data = provider.read(path).read().decode('utf-8') + y, m = read_yaml_md(data) + y = y if y else {} + + if 'date' in y: + y['date'] = create_date(y['date'], settings.date_formats) + + if 'until' in y: + y['until'] = create_date(y['until'], settings.date_formats) + + if 'id' in y: + y['id'] = str(y['id']) + + return { + **y, + 'data': m, + 'title': title_from_html(m), + 'images': images_from_html(m) + } + + +def create_id(document): + new_id = url_encode_text(document['url']) + return { + **document, + 'id': document['id'] if 'id' in document else new_id + } + + +def create_hash(provider, document): + files = sorted([document['file']] + document['images']) + hashes = lmap( + provider.hash, + lmap( + lambda x: os.path.join(document['folder'], x), + files + ) + ) + + return { + **document, + 'hash':hash_str(''.join(hashes)) + } + + +def sync_pages(provider, collection, update=True, delete=True, skip_unchanged=True): + sync = Sync() + sync.collection = collection + + documents = list(filter( + lambda x: provider.is_dir(x), + provider.scan('.') + )) + + documents = lmap( + lambda x: provider.type_filter(x, '.md'), + documents + ) + + documents = list(filter( + lambda x: len(x), + documents + )) + + documents = lmap( + lambda x: create_document_from_folder(provider, x[0]), + documents + ) + + documents = list(filter(None, documents)) + + # CREATE SCOPE OF CURRENT SESSION + documents_ids = lmapfn(documents)( + lambda i: i['id'] + ) + + # SKIP UNTOUCHED DOCUMENTS + if skip_unchanged: + documents = untouched(documents, sync) + + # # MAP EVENT MANIFEST -> EVENT_OBJECT + # documents = lmap( + # sync.create, + # documents + # ) + + # REPLACE IMAGES OBJECTS WITH IT _ID IN MONGODB + documents = lmap( + key_mapper('images', synced_images_ids), + documents + ) + + # SYNC EVENT_OBJECT WITH DB + if update: + documents = lmap( + sync.update, + documents + ) + + documents_to_delete = [] + if delete: + remove_query = sync.create_remove_query({'id': {'$nin': documents_ids}}) + documents_to_delete = sync.query(remove_query) + documents_to_delete = lmap( + sync.delete, + map( + lambda i: {'_id': i['_id']}, + documents_to_delete + ) + ) + + return documents, documents_to_delete diff --git a/utils/Sync/utils/text/transform.py b/utils/Sync/utils/text/transform.py index dc56c219..8aaaed59 100644 --- a/utils/Sync/utils/text/transform.py +++ b/utils/Sync/utils/text/transform.py @@ -5,7 +5,10 @@ from unidecode import unidecode from utils.fn import iterate_over_fns remove_pattr = re.compile('[«»<>,!&"\']') -reduce_dash_pattr = re.compile('[-]+') +reduce_dash_patterns = [ + (re.compile('[-]+'), '-'), + (re.compile('^-'), '') +] def translit(text): @@ -32,7 +35,10 @@ def remove_punctuation(i): def reduce_dashes(i): - return reduce_dash_pattr.sub('-', i) + value = i + for reg_exp, replace in reduce_dash_patterns: + value = reg_exp.sub(replace, value) + return value def space_to_dash(i): @@ -53,6 +59,10 @@ def dot_to_dash(i): return i.replace('.', '-') +def slash_to_dash(i): + return i.replace('/', '-') + + def remove_underscores(i): return i.replace('_', '') @@ -76,6 +86,7 @@ url_encode_text = iterate_over_fns([ space_to_dash, dot_to_dash, short_dash, + slash_to_dash, remove_underscores, remove_punctuation, reduce_dashes, From d36fe4b3421dcc222a34db2db07fc63636096ddd Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Fri, 11 Nov 2016 21:28:18 +0300 Subject: [PATCH 002/368] [sync] sync post fix --- utils/Sync/sync/core/post.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/Sync/sync/core/post.py b/utils/Sync/sync/core/post.py index e440451f..f5bdaed5 100644 --- a/utils/Sync/sync/core/post.py +++ b/utils/Sync/sync/core/post.py @@ -86,6 +86,6 @@ class SyncPost(Sync): query = { **query, 'type': self.type, - 'orogin': self.origin + 'origin': self.origin } return query From 3951cd2edfa15f3cb5f2cd2de5719ac946bfa07d Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Fri, 11 Nov 2016 21:28:39 +0300 Subject: [PATCH 003/368] package.json + run gulp --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index bfb584e9..c2ac254b 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "start": "babel-node src/index.js", "out": "babel src/ -d out/", + "gulp": "gulp", "test": "mocha --compilers js:babel-register", "coverage": "istanbul cover mocha -- --compilers js:babel-register" }, From dad12f52f46183060eb83825a0099f125c6d8024 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 05:15:40 +0300 Subject: [PATCH 004/368] node-version revert to 4.6.1 (next LTS is not working) --- .node-version | 2 +- src/style/home.scss | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 src/style/home.scss diff --git a/.node-version b/.node-version index e029aa99..8ac28bf9 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -6.8.0 +4.6.1 diff --git a/src/style/home.scss b/src/style/home.scss deleted file mode 100644 index fee1db82..00000000 --- a/src/style/home.scss +++ /dev/null @@ -1,9 +0,0 @@ -.main-block { - h1 { - font-size: 18pt; - text-align: center; - font-weight: normal; - margin: 1.2em 0 0; - padding: 0; - } -} From edf5fbf4bddb9db824a013210d8908076f49ad2d Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 05:17:10 +0300 Subject: [PATCH 005/368] + CLOUD PAGES; style updated; other changes --- package.json | 6 +- src/client/api/API.js | 2 + src/client/api/APIPage.js | 7 ++ src/client/app.js | 19 ++++ src/client/components/CloudPage.js | 15 +++ src/client/config.js | 32 ------ src/client/core/init.js | 3 + src/config.js | 4 +- src/core/pages.js | 19 ++++ src/models/menu.js | 9 +- src/routes/index.js | 121 ++++++++++++---------- src/routes/pages.js | 24 +++++ src/server.js | 80 +++++++------- src/style/body-wrapper.scss | 3 + src/style/components/album.scss | 2 +- src/style/components/article.scss | 13 ++- src/style/components/cloud-page.scss | 79 ++++++++++++++ src/style/components/main-menu.scss | 2 +- src/style/components/timeline-record.scss | 2 - src/style/components/timeline.scss | 8 +- src/style/footer.scss | 2 + src/style/hudozka-title.scss | 7 +- src/style/main.scss | 1 - src/style/style.scss | 1 + src/style/variables.scss | 27 +++-- src/templates/components/cloud-page.html | 3 + src/templates/main.html | 9 +- 27 files changed, 339 insertions(+), 161 deletions(-) create mode 100644 src/client/api/APIPage.js create mode 100644 src/client/components/CloudPage.js create mode 100644 src/client/core/init.js create mode 100644 src/core/pages.js create mode 100644 src/routes/pages.js create mode 100644 src/style/components/cloud-page.scss create mode 100644 src/templates/components/cloud-page.html diff --git a/package.json b/package.json index c2ac254b..95c268bc 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,16 @@ "angular": "^1.5.3", "angular-route": "^1.5.3", "angular-spinner": "^0.8.1", - "angulartics": "^1.2.1", - "angulartics-google-analytics": "^0.1.4", + "angulartics": "^1.0.0", + "angulartics-google-analytics": "^0.3.0", + "async-file": "^2.0.2", "babel-core": "^6.7.4", "babel-polyfill": "^6.7.4", "babel-preset-es2015": "^6.5.0", "babel-preset-stage-0": "^6.5.0", "co": "^4.4.0", "ejson": "^2.1.2", + "handlebars": "^4.0.5", "hudozka-api-v1": "file:modules/hudozka-api-v1", "hudozka-data": "file:modules/hudozka-data", "hudozka-middlewares": "file:modules/hudozka-middlewares", diff --git a/src/client/api/API.js b/src/client/api/API.js index d6f79aae..0f8fdee8 100644 --- a/src/client/api/API.js +++ b/src/client/api/API.js @@ -5,6 +5,7 @@ import APITeacher from './APITeacher'; import APISchedule from './APISchedule'; import APIEvent from './APIEvent'; import APIArticle from './APIArticle'; +import APIPage from './APIPage'; export default class API { constructor(request) { @@ -15,5 +16,6 @@ export default class API { this.schedule = new APISchedule(request); this.event = new APIEvent(request); this.article = new APIArticle(request); + this.page = new APIPage(request); } } diff --git a/src/client/api/APIPage.js b/src/client/api/APIPage.js new file mode 100644 index 00000000..200e54aa --- /dev/null +++ b/src/client/api/APIPage.js @@ -0,0 +1,7 @@ +import EndPoint from './EndPoint'; + +export default class APIPage extends EndPoint { + url(url) { + return this.get(url); + } +} diff --git a/src/client/app.js b/src/client/app.js index 61a291c9..6412f4c8 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -1,3 +1,4 @@ +import {getInitialData} from './core/init'; import Navigation from './components/Navigation'; import MainMenu from './components/MainMenu'; import Breadcrumbs from './components/Breadcrumbs'; @@ -20,6 +21,7 @@ import ArticlePageControl from './components/ArticlePageControl'; import Album from './components/Album'; import Parallax from './components/Parallax'; +import Page from './components/CloudPage'; import PageSchool from './components/PageSchool'; import PageEvents from './components/PageEvents'; import PageArticle from './components/PageArticle'; @@ -61,6 +63,21 @@ app.config(($locationProvider, $routeProvider) => { $locationProvider.hashPrefix('!'); $locationProvider.html5Mode(true); + const pages = getInitialData().pages + .map(i => i.url) + .map(i => ({ + name: i, + template: '', + resolveAs: '$', + resolve: { + data: (api) => { + return api.page + .url(location.pathname) + .then(i => i.data) + } + } + })); + let routers = [ { name: '/', @@ -191,6 +208,7 @@ app.config(($locationProvider, $routeProvider) => { } } ] + .concat(pages) .map(i => { let path = i.name; delete i.name; @@ -264,6 +282,7 @@ app.run(($location, $rootScope, $http) => { GalleryItem, AlbumCollection, TeacherProfile, + Page, PageSchool, PageArticle, PageEvents, diff --git a/src/client/components/CloudPage.js b/src/client/components/CloudPage.js new file mode 100644 index 00000000..1b434b80 --- /dev/null +++ b/src/client/components/CloudPage.js @@ -0,0 +1,15 @@ +import template from '../../templates/components/cloud-page.html'; + +export default function (app) { + app.component('cloudPage', { + bindings: { + page: ' route.get('/', index()); -export function routes(){ - return compose([ - main(), - sitemap(), - schedule(), - news(), - gallery(), - documents(), - teachers(), - events(), - articles(), - error404() - ]); +export function routes() { + return compose([ + main(), + sitemap(), + schedule(), + news(), + gallery(), + documents(), + teachers(), + events(), + articles(), + pages(), + error404() + ]); } export function queryObject() { - let toTrue = map(true, i => i === 'true'); - let toFalse = map(false, i => i === 'false'); - const processors = [toTrue, toFalse]; + let toTrue = map(true, i => i === 'true'); + let toFalse = map(false, i => i === 'false'); + const processors = [toTrue, toFalse]; - return async (ctx, next) => { - let query = ctx.query; - ctx.query = Object.keys(query) - .reduce((query, key) => assign( - query, - key, - processors - .reduce((value, fn) => fn(value), query[key]) - ), query); + return async(ctx, next) => { + let query = ctx.query; + ctx.query = Object + .keys(query) + .reduce((query, key) => assign( + query, + key, + processors + .reduce((value, fn) => fn(value), query[key]) + ), query); - await next(); - } + await next(); + } } export function accepts(routes) { - return async function (ctx) { - let request = ctx.request; - let types = Object.keys(routes) - .filter(type => request.accepts(type)); + return async function (ctx) { + let request = ctx.request; + let types = Object.keys(routes) + .filter(type => request.accepts(type)); - if (types.length) { - let fn = routes[types[0]]; + if (types.length) { + let fn = routes[types[0]]; - await fn.apply(ctx, arguments); - } else { - ctx.status = 406; - } - }; + await fn.apply(ctx, arguments); + } else { + ctx.status = 406; + } + }; } export function index(fn) { - let filename = config['defaultIndex']; + return async function (ctx) { + let test = true; + if (fn) test = await fn.apply(ctx, arguments); + if (!test) ctx.status = 404; - return async function (ctx){ - let test = true; - if (fn) test = await fn.apply(ctx, arguments); + const data = await getInitialData(); + const source = await readFile(indexFile, 'utf-8'); + const template = handlebars.compile(source); - if (!test) ctx.status = 404; - - ctx.type = 'text/html'; - ctx.body = fs.createReadStream(filename); - } + ctx.type = 'text/html'; + ctx.body = template({data: JSON.stringify(data)}); + } } -export function json(fn){ - return accepts({ - 'text/html': index(), - 'text/plain': index(), - 'application/json': fn - }); +export function json(fn) { + return accepts({ + 'text/html': index(), + 'text/plain': index(), + 'application/json': fn + }); +} + +async function getInitialData() { + const pages = await getPageUrls(); + return {pages: pages}; } diff --git a/src/routes/pages.js b/src/routes/pages.js new file mode 100644 index 00000000..f6cec2fc --- /dev/null +++ b/src/routes/pages.js @@ -0,0 +1,24 @@ +import route from 'koa-route'; +import {c} from '../core/db'; +import {accepts, index} from './'; + +async function exists(ctx) { + const page = await getPage(ctx.path); + return Boolean(page); +} + +async function getPage(path) { + return await c('pages').findOne({url: path}); +} + +export default function () { + return route.get('*', accepts({ + 'text/html': index(exists), + 'text/plain': index(exists), + 'application/json': async(ctx) => { + const page = await getPage(ctx.path); + if (!page) ctx.status = 404; + else ctx.body = page; + } + })) +}; diff --git a/src/server.js b/src/server.js index 09066327..568b4661 100644 --- a/src/server.js +++ b/src/server.js @@ -6,61 +6,63 @@ import logger from 'koa-logger'; import convert from 'koa-convert'; import conditional from 'koa-conditional-get'; import etag from 'koa-etag'; -// import prerender from 'koa-prerender'; +import prerender from 'koa-prerender'; import helmet from 'koa-helmet'; import mount from 'koa-mount'; import bodyParser from 'koa-bodyparser'; -import api_v1 from 'hudozka-api-v1'; -import config from './config'; -import {redirectionTable} from './config'; +import apiV1 from 'hudozka-api-v1'; +import config, {redirectionTable} from './config'; import {routes, queryObject} from './routes'; import {redirect} from './routes/redirect'; import {services as serviceKeys, authChecker} from './core/service'; +import handlebars from 'handlebars'; const dirPublic = path.join(__dirname, '../public'); const dirTemplates = path.join(__dirname, 'templates'); -export default function(store){ - const $ = convert; - - const app = new Koa(); - app.proxy = true; +handlebars.registerHelper('raw-helper', options => options.fn()); - app.use(bodyParser({ - extendTypes: { - json: 'application/ejson' - } - })); - app.use(logger()); - app.use(apis(store)); - app.use($(conditional())); - app.use($(etag())); - // app.use(prerenderRmFragment()); - // app.use($(prerender(config.prerender))); - app.use(serve(dirPublic)); - app.use(serve(dirTemplates)); - app.use($(redirect(redirectionTable))); - app.use($(helmet())); - app.use(queryObject()); - app.use(routes()); +export default function (store) { + const $ = convert; - return Server(app.callback()); + const app = new Koa(); + app.proxy = true; + + app.use(bodyParser({ + extendTypes: { + json: 'application/ejson' + } + })); + app.use(logger()); + app.use(apis(store)); + app.use($(conditional())); + app.use($(etag())); + app.use(prerenderRmFragment()); + app.use($(prerender(config.prerender))); + app.use(serve(dirPublic)); + app.use(serve(dirTemplates)); + app.use($(redirect(redirectionTable))); + app.use($(helmet())); + app.use(queryObject()); + app.use(routes()); + + return Server(app.callback()); } -function apis(store){ - let checkAuth = authChecker(serviceKeys); - return mount('/api/v1', api_v1(checkAuth, store)); +function apis(store) { + let checkAuth = authChecker(serviceKeys); + return mount('/api/v1', apiV1(checkAuth, store)); } -function prerenderRmFragment(){ - return async (ctx, next) => { - await next(); +function prerenderRmFragment() { + return async(ctx, next) => { + await next(); - try { - let xp = ctx.response.header['x-prerender'] == 'true'; - if (xp) ctx.body = ctx.body.replace('', ''); - } catch (e) { - } - } + try { + let xp = ctx.response.header['x-prerender'] === 'true'; + if (xp) ctx.body = ctx.body.replace('', ''); + } catch (e) { + } + } } diff --git a/src/style/body-wrapper.scss b/src/style/body-wrapper.scss index 9e1bcacf..a61f0073 100644 --- a/src/style/body-wrapper.scss +++ b/src/style/body-wrapper.scss @@ -2,6 +2,9 @@ .body-wrapper { background-color: white; + + font-family: $text-font; + font-size: $default-font-size; } .body-wrapper__content { diff --git a/src/style/components/album.scss b/src/style/components/album.scss index fc4313c9..6a1458c0 100644 --- a/src/style/components/album.scss +++ b/src/style/components/album.scss @@ -7,7 +7,7 @@ margin-bottom: 1.25em; h3 { - font-size: $big-font-size; + font-size: $biggest-font-size; text-align: center; } diff --git a/src/style/components/article.scss b/src/style/components/article.scss index 90593fb9..a64a730b 100644 --- a/src/style/components/article.scss +++ b/src/style/components/article.scss @@ -7,7 +7,7 @@ margin-bottom: 1.25em; h3 { - font-size: $big-font-size; + font-size: $biggest-font-size; text-align: center; } @@ -33,13 +33,16 @@ margin: 1.25em auto $small-margin; } - ul{ - margin-bottom: 1.25em; - - list-style: none; + ul, ol{ + margin-left: $half-margin; + margin-bottom: $single-margin; padding-left: $single-margin; } + ul{ + list-style: disc; + } + p{ margin-bottom: 1.25em; } diff --git a/src/style/components/cloud-page.scss b/src/style/components/cloud-page.scss new file mode 100644 index 00000000..e3b49649 --- /dev/null +++ b/src/style/components/cloud-page.scss @@ -0,0 +1,79 @@ +@import "../variables"; + +.cloud-page { + margin-bottom: $post-margin; + + &__body{ + + a { + color: $dark-color; + text-decoration: none; + border-bottom: 1px solid lighten($dark-color, 10%); + + &:hover { + border-bottom: 1px solid lighten($dark-color, 25%); + } + + &:active { + border-bottom: 1px solid $dark-color; + } + } + + h1{ + text-align: center; + margin-bottom: $single-margin; + + font-size: $biggest-font-size; + } + + h2 { + text-align: left; + margin-top: $double-margin; + font-family: $text-font; + } + + ul, ol{ + margin-left: $half-margin; + margin-bottom: $single-margin; + padding-left: $single-margin; + } + + ul{ + list-style: disc; + } + + p{ + margin-bottom: 1.25em; + } + + blockquote { + background-color: hsl(215, 10%, 96%); + padding: 1em 1em .5em; + margin: $single-margin 0; + font-family: $title-font; + font-style: italic; + font-weight: normal; + font-size: 1.25em; + + cite { + margin-top: $single-margin; + display: block; + color: #aaa; + font-size: initial; + font-family: $text-font; + text-align: right; + margin-right: $single-margin; + } + } + } +} + +@media (max-width: $mobile-width) { + .cloud-page { + &__body { + img { + max-height: 20em; + } + } + } +} diff --git a/src/style/components/main-menu.scss b/src/style/components/main-menu.scss index b6ebcdee..87b71925 100644 --- a/src/style/components/main-menu.scss +++ b/src/style/components/main-menu.scss @@ -3,7 +3,7 @@ .main-menu { white-space: nowrap; - font-size: 1.1em; + font-size: $normal-font-size; color: $menu-inactive-item-color; list-style: none; diff --git a/src/style/components/timeline-record.scss b/src/style/components/timeline-record.scss index 42ad514a..6d64a020 100644 --- a/src/style/components/timeline-record.scss +++ b/src/style/components/timeline-record.scss @@ -4,8 +4,6 @@ margin: 0 0 $post-margin; .date { - //margin: 0 0 0.45em; - //font-size: 0.75em; color: $light-color; } } diff --git a/src/style/components/timeline.scss b/src/style/components/timeline.scss index c3b60b5a..f3012069 100644 --- a/src/style/components/timeline.scss +++ b/src/style/components/timeline.scss @@ -10,7 +10,7 @@ display: flex; justify-content: center; - button.more{ + button.more { position: relative; top: -2px; @@ -20,13 +20,13 @@ padding: 0 10px; background: none; - font-size: 14pt; + font-size: $normal-font-size; - &:hover{ + &:hover { background: gainsboro; } - &:active{ + &:active { top: 0; } } diff --git a/src/style/footer.scss b/src/style/footer.scss index cfcbca51..cf234f8e 100644 --- a/src/style/footer.scss +++ b/src/style/footer.scss @@ -9,6 +9,8 @@ footer { position: relative; background-color: $darker-color; + font-size: $smaller-font-size; + &:before { $s: 3px; diff --git a/src/style/hudozka-title.scss b/src/style/hudozka-title.scss index 365f7d27..4cf365bb 100644 --- a/src/style/hudozka-title.scss +++ b/src/style/hudozka-title.scss @@ -8,20 +8,19 @@ p { color: $light-color; margin-bottom: $single-margin; + font-size: $smaller-font-size; } h1 { margin-top: $single-margin; - font-size: 2em; + font-size: $biggest-font-size; } } @media (max-width: $mobile-width) { .hudozka-title { - text-align: center; - h1 { - font-size: 1.5em; + font-size: $big-font-size; } } } diff --git a/src/style/main.scss b/src/style/main.scss index e6f6479a..e5bc6ef4 100644 --- a/src/style/main.scss +++ b/src/style/main.scss @@ -10,7 +10,6 @@ html, body { } body { - font-family: $text-font; min-width: 320px; } diff --git a/src/style/style.scss b/src/style/style.scss index 91c6b993..9ded95b8 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -11,6 +11,7 @@ @import "components/timeline-record-instagram"; @import "components/schedule-table"; @import "components/footer-links"; +@import "components/cloud-page"; @import "components/article"; @import "components/article-page-control"; @import "components/album"; diff --git a/src/style/variables.scss b/src/style/variables.scss index f4e7937c..5dfdc202 100644 --- a/src/style/variables.scss +++ b/src/style/variables.scss @@ -16,7 +16,7 @@ $embed-video-ratio: 56.25%; $small-margin: .2em; $half-margin: .5em; $single-margin: 1.0em; -$double-margin: 3.0em; +$double-margin: 2.0em; $post-margin: 5.0em; //COLOR @@ -44,15 +44,28 @@ $white-shadow: 0 .1em 0.3em rgba(0, 0, 0, 0.2); $title-font: "PT Serif", Georgia, serif; $text-font: "PT Sans", Arial, sans-serif; -$normal-font-size: 1em; -$bigger-font-size: 1.2em; -$big-font-size: 1.75em; -$smaller-font-size: .8em; +$default-font-size: 14pt; +$smaller-font-size: 0.9rem; +$normal-font-size: 1.0rem; +$bigger-font-size: 1.2rem; +$big-font-size: 1.5rem; +$biggest-font-size: 2.5rem; //MENU $menu-thickness: 2.5em; -$menu-colored-mark-thickness: 4px; +$menu-colored-mark-thickness: 2px; $menu-inactive-item-color: hsl(0, 0%, 50%); //ANIMATION -$short-duration: 0.3s; \ No newline at end of file +$short-duration: 0.3s; + + +@media (max-width: $mobile-width) { + //FONTS + $default-font-size: 14pt; + $smaller-font-size: 0.9rem; + $normal-font-size: 1.0rem; + $bigger-font-size: 1.1rem; + $big-font-size: 1.3rem; + $biggest-font-size: 2.0rem; +} diff --git a/src/templates/components/cloud-page.html b/src/templates/components/cloud-page.html new file mode 100644 index 00000000..1a162cf5 --- /dev/null +++ b/src/templates/components/cloud-page.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/src/templates/main.html b/src/templates/main.html index ff8cf9d6..23ea8d98 100644 --- a/src/templates/main.html +++ b/src/templates/main.html @@ -48,7 +48,11 @@ //ga('send', 'pageview'); } + + + +{{{{raw-helper}}}}
@@ -62,7 +66,6 @@
@@ -77,7 +80,7 @@
@@ -93,4 +96,6 @@ })(); +{{{{/raw-helper}}}} + From 30dd018589fc0ab33091a98bf5b6c23923792c78 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 05:18:30 +0300 Subject: [PATCH 006/368] deploy updated --- deploy.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deploy.sh b/deploy.sh index 87e880ee..58650b9f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -9,7 +9,7 @@ destpath="~/www/art.shburg.org" echo "Building..." npm run out -NODE_ENV=production gulp deploy +NODE_ENV=production npm run gulp deploy echo "Packing $tarpath" env GZIP=-9 tar -czf ${tarpath} \ @@ -24,8 +24,7 @@ env GZIP=-9 tar -czf ${tarpath} \ . echo "Uploading..." -#ssh h "rm -rf $destpath/*" -ssh h "rm -rf $destpath/public/*" +ssh hoster@${server} "rm -rf $destpath/public/*" scp ${tarpath} hoster@${server}:${destpath} echo "Installing..." From d22c5fa5f7df8bec025f694c5cd7e768ccad3b26 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 05:34:30 +0300 Subject: [PATCH 007/368] fix GA lost --- gulpfile.babel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 45ff42bf..7499d92b 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -20,11 +20,11 @@ gulp.task('compile 3rdparty', () => { './node_modules/angular/angular.min.js', './node_modules/angular-route/angular-route.min.js', './node_modules/angulartics/dist/angulartics.min.js', - './node_modules/angulartics-google-analytics/dist/angulartics-google-analytics.min.js', + './node_modules/angulartics-google-analytics/dist/angulartics-ga.min.js', './node_modules/spin.js/spin.js', './node_modules/angular-spinner/angular-spinner.min.js', './node_modules/socket.io-client/socket.io.js', - + './node_modules/babel-polyfill/dist/polyfill.min.js' ]; From 834ed4df83428979f2d67b3887ea96ea1e997615 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 12:10:31 +0300 Subject: [PATCH 008/368] [install] forever part removed. we are going to systemd based running --- install.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 25e84113..f7acad27 100755 --- a/install.sh +++ b/install.sh @@ -16,10 +16,4 @@ npm install ./modules/hudozka-api-v1/ npm install ./modules/hudozka-data/ npm install ./modules/hudozka-middlewares/ -#starting www -if forever restart ${app}; then - echo App restarted -else - forever start ${script} - echo App started -fi +echo "Deploying finish. Please restart hudozka.service manually" From d749e46c53d9d049c4c10733dee9dfeeea983f2b Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 12:11:40 +0300 Subject: [PATCH 009/368] v3.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 95c268bc..74cc0400 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Hudozka", "private": true, - "version": "3.4.1", + "version": "3.5.0", "description": "", "main": "src/bin/www.js", "scripts": { From da5823ddf74d1efd364083b6ae60e46dd6fb14f8 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 12:19:02 +0300 Subject: [PATCH 010/368] sitemap collects pages --- src/routes/sitemap.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/routes/sitemap.js b/src/routes/sitemap.js index 73d0916d..2fdb65ce 100644 --- a/src/routes/sitemap.js +++ b/src/routes/sitemap.js @@ -1,6 +1,7 @@ import sitemap from 'sitemap'; import route from 'koa-route'; import {c} from '../core/db'; +import {getPageUrls as pages} from '../core/pages'; import {homeUrl, sitemapCacheTime} from '../config'; import menu from '../models/menu'; @@ -9,6 +10,7 @@ export default function () { return route.get('/sitemap.xml', async ctx => { let urls = await Promise.all([ getMenuUrls(), + getPageUrls(), getGalleryUrls(), getTeacherUrls(), getEventsUrls(), @@ -36,6 +38,14 @@ async function getMenuUrls(frequency='daily') { })); } +async function getPageUrls(frequency = 'daily') { + const ps = await pages(); + return ps.map(i => ({ + url: i.url, + changefreq: frequency + })); +} + async function getGalleryUrls() { let docs = await c('albums') .find({}) From a5f95a36c5e348631a3078e0784fa80b0fafe7ca Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 12 Nov 2016 12:21:07 +0300 Subject: [PATCH 011/368] sitemap eslinted --- src/routes/sitemap.js | 130 +++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/src/routes/sitemap.js b/src/routes/sitemap.js index 2fdb65ce..82304805 100644 --- a/src/routes/sitemap.js +++ b/src/routes/sitemap.js @@ -1,41 +1,41 @@ -import sitemap from 'sitemap'; -import route from 'koa-route'; -import {c} from '../core/db'; -import {getPageUrls as pages} from '../core/pages'; +import sitemap from 'sitemap'; +import route from 'koa-route'; +import {c} from '../core/db'; +import {getPageUrls as pages} from '../core/pages'; import {homeUrl, sitemapCacheTime} from '../config'; import menu from '../models/menu'; export default function () { - return route.get('/sitemap.xml', async ctx => { - let urls = await Promise.all([ - getMenuUrls(), - getPageUrls(), - getGalleryUrls(), - getTeacherUrls(), - getEventsUrls(), - getNewsUrls() - ]); - urls = urls.reduce((urls, i) => urls.concat(i)); + return route.get('/sitemap.xml', async ctx => { + let urls = await Promise.all([ + getMenuUrls(), + getPageUrls(), + getGalleryUrls(), + getTeacherUrls(), + getEventsUrls(), + getNewsUrls() + ]); + urls = urls.reduce((urls, i) => urls.concat(i)); - let map = sitemap.createSitemap({ - hostname: homeUrl, - cacheTime: sitemapCacheTime, - urls: urls - }); + let map = sitemap.createSitemap({ + hostname: homeUrl, + cacheTime: sitemapCacheTime, + urls: urls + }); - ctx.set('Content-Type', 'application/xml'); - ctx.body = map.toString(); - }) + ctx.set('Content-Type', 'application/xml'); + ctx.body = map.toString(); + }) }; -async function getMenuUrls(frequency='daily') { - return menu - .filter(i => 'url' in i) - .map(i => ({ - url: i.url, - changefreq: frequency - })); +async function getMenuUrls(frequency = 'daily') { + return menu + .filter(i => 'url' in i) + .map(i => ({ + url: i.url, + changefreq: frequency + })); } async function getPageUrls(frequency = 'daily') { @@ -47,53 +47,53 @@ async function getPageUrls(frequency = 'daily') { } async function getGalleryUrls() { - let docs = await c('albums') - .find({}) - .toArray(); + let docs = await c('albums') + .find({}) + .toArray(); - return docs.map(i => { - return { - url: `/album/${i.id}`, - changefreq: 'monthly' - } - }); + return docs.map(i => { + return { + url: `/album/${i.id}`, + changefreq: 'monthly' + } + }); } async function getTeacherUrls() { - let docs = await c('collective') - .find({}) - .toArray(); + let docs = await c('collective') + .find({}) + .toArray(); - return docs.map(i => { - return { - url: `/teacher/${i.id}`, - changefreq: 'monthly' - } - }); + return docs.map(i => { + return { + url: `/teacher/${i.id}`, + changefreq: 'monthly' + } + }); } async function getEventsUrls() { - let docs = await c('events') - .find({}) - .toArray(); + let docs = await c('events') + .find({}) + .toArray(); - return docs.map(i => { - return { - url: `/article/${i.id}`, - changefreq: 'monthly' - } - }); + return docs.map(i => { + return { + url: `/article/${i.id}`, + changefreq: 'monthly' + } + }); } async function getNewsUrls() { - let docs = await c('timeline') - .find({type: 'post'}) - .toArray(); + let docs = await c('timeline') + .find({type: 'post'}) + .toArray(); - return docs.map(i => { - return { - url: `/article/${i.id}`, - changefreq: 'monthly' - } - }); + return docs.map(i => { + return { + url: `/article/${i.id}`, + changefreq: 'monthly' + } + }); } From 9f58ffca0955c2393ff4fc0b1e4252c71e1078eb Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 13 Nov 2016 21:30:46 +0300 Subject: [PATCH 012/368] [sync] person skip untoched --- utils/Sync/sync/person.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/Sync/sync/person.py b/utils/Sync/sync/person.py index f4a91b81..f42e0b13 100644 --- a/utils/Sync/sync/person.py +++ b/utils/Sync/sync/person.py @@ -79,7 +79,7 @@ def main(sync, update_documents=False, delete_documents=False): ) # SKIP UNTOUCHED DOCUMENTS - # documents = untouched(documents, sync) + documents = untouched(documents, sync) # DO HEAVY PROCESS WITH DOCUMENTS documents = lmap( From a4b4e0768723573c9f3d4ede4d06cc5fcd8c229d Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 23 Nov 2016 02:10:26 +0300 Subject: [PATCH 013/368] [sync] updated; page images --- utils/Sync/sync.py | 12 +++---- utils/Sync/sync/__init__.py | 16 +++++++++ utils/Sync/sync/album.py | 13 ++++--- utils/Sync/sync/core/album.py | 22 +++++------- utils/Sync/sync/page.py | 66 +++++++++++++++++++++++++++++++++-- utils/Sync/utils/fn.py | 3 +- 6 files changed, 104 insertions(+), 28 deletions(-) diff --git a/utils/Sync/sync.py b/utils/Sync/sync.py index 533a4359..8febad88 100644 --- a/utils/Sync/sync.py +++ b/utils/Sync/sync.py @@ -37,10 +37,10 @@ def main(provider, fn, collection_name): if __name__ == '__main__': io = lambda root: get_provider(settings.sync_provider_type, root) - main(io(settings.dir_documents), sync_documents, settings.collection_documents) - main(io(settings.dir_schedules), sync_schedules, settings.collection_schedules) - main(io(settings.dir_events), sync_posts, settings.collection_events) - main(io(settings.dir_news), sync_posts, settings.collection_news) - main(io(settings.dir_collective), sync_persons, settings.collection_collective) - main(io(settings.dir_gallery), sync_albums, settings.collection_albums) + # main(io(settings.dir_documents), sync_documents, settings.collection_documents) + # main(io(settings.dir_schedules), sync_schedules, settings.collection_schedules) + # main(io(settings.dir_events), sync_posts, settings.collection_events) + # main(io(settings.dir_news), sync_posts, settings.collection_news) + # main(io(settings.dir_collective), sync_persons, settings.collection_collective) + # main(io(settings.dir_gallery), sync_albums, settings.collection_albums) main(io(settings.dir_pages), sync_pages, settings.collection_pages) diff --git a/utils/Sync/sync/__init__.py b/utils/Sync/sync/__init__.py index 879a2b4b..2dbfcf55 100644 --- a/utils/Sync/sync/__init__.py +++ b/utils/Sync/sync/__init__.py @@ -2,10 +2,12 @@ import os import re from datetime import datetime from glob import glob +from lxml import etree import lxml.html from markdown import markdown +import settings from sync.image import sync_image from utils.fn import lmap, combine @@ -80,6 +82,20 @@ def create_date_and_title_from_folder_name(folder_name, date_formats=None): return date, title +def create_post(md, image_path_fn): + html = lxml.html.fromstring(md) + + for img in html.cssselect('img'): + src = img.get('src') + path = image_path_fn(src) + + if path: + img.set('src', path) + img.set('class', settings.album_html_img_class) + img.set('data-file', src) + return etree.tounicode(html) + + def images_from_html(md): if not md: return [] diff --git a/utils/Sync/sync/album.py b/utils/Sync/sync/album.py index a924632c..71a97d41 100644 --- a/utils/Sync/sync/album.py +++ b/utils/Sync/sync/album.py @@ -2,7 +2,7 @@ import os import settings from sync import create_date_and_title_from_folder_name, create_post_from_image_list, create_date, untouched, \ - synced_images_ids + synced_images_ids, synced_image_id from sync.core.album import SyncAlbum from sync.data import list_images from utils.fn import lmap, lmapfn, key_mapper @@ -19,10 +19,11 @@ class ImageCreator: def create_image(self, file, sizes, url_fn, output_dir, skip_processing=False): filehash = self.provider.hash(file) cached = self.cached(filehash) - return create_image(self.provider.get_abs(file), sizes, url_fn, output_dir, skip_processing=skip_processing) if not cached else cached + return create_image(self.provider.get_abs(file), sizes, url_fn, output_dir, + skip_processing=skip_processing) if not cached else cached - def cached(self, hash): - return self.cache[hash] if hash in self.cache else None + def cached(self, name): + return self.cache[name] if name in self.cache else None def get_manifest(provider, filepath): @@ -121,6 +122,10 @@ def main(sync, do_update, do_delete): key_mapper('images', synced_images_ids), documents ) + documents = lmap( + key_mapper('preview', synced_image_id), + documents + ) # SYNC OBJECT WITH DB if do_update: diff --git a/utils/Sync/sync/core/album.py b/utils/Sync/sync/core/album.py index d68a571b..7c80a109 100644 --- a/utils/Sync/sync/core/album.py +++ b/utils/Sync/sync/core/album.py @@ -3,6 +3,7 @@ from lxml import etree import lxml.html import settings +from sync import create_post from sync.core import Sync from sync.models.product import create_product from utils.fn import lmap, iterate_iter_over_fns, combine @@ -10,20 +11,6 @@ from utils.hash import hash_file, hash_str from utils.text.transform import url_encode_text -def create_post(md, image_path_fn): - html = lxml.html.fromstring(md) - - for img in html.cssselect('img'): - src = img.get('src') - path = image_path_fn(src) - - if path: - img.set('src', path) - img.set('class', settings.album_html_img_class) - img.set('data-file', src) - return etree.tounicode(html) - - def create_url(a, i, s, e): return 'https://static.shburg.org/art/images/product-{album}-{id}-{size}{ext}'.format( album=a, @@ -120,6 +107,13 @@ class SyncAlbum(Sync): images = [] post_html = create_post(doc['post'], process_post_image) + if 'preview' in doc: + preview = os.path.join(doc['folder'], doc['preview']) + doc['preview'] = self.create_image(preview, url_creator( + doc['id'], + image_id(doc['preview']) + )) + doc['post'] = post_html doc['images'] = images return doc diff --git a/utils/Sync/sync/page.py b/utils/Sync/sync/page.py index 3c0217a8..e8deb5dd 100644 --- a/utils/Sync/sync/page.py +++ b/utils/Sync/sync/page.py @@ -2,16 +2,36 @@ import os import settings from sync.core import Sync -from sync.data import list_images +from sync.data import list_images, Provider from sync import create_date_and_title_from_folder_name, create_post_from_image_list, create_date, images_from_html, \ - synced_images_ids, untouched, title_from_html + synced_images_ids, untouched, title_from_html, create_post from sync.core.post import SyncPost from utils.fn import lmap, map_cases, first, key_mapper, lmapfn, constant from utils.hash import hash_str +from utils.image import create_image from utils.io import read_yaml_md from utils.text.transform import url_encode_text +class ImageCreator: + def __init__(self, provider: Provider, sizes: list, output_dir: str, cache: dict): + super().__init__() + self.provider = provider + self.sizes = sizes + self.output_dir = output_dir + self.cache = cache if cache else set() + + def create(self, file, name_fn): + filehash = self.provider.hash(file) + cached = self.cached(filehash) + if cached: + return cached + return create_image(self.provider.get_abs(file), self.sizes, name_fn, self.output_dir, skip_processing=False) + + def cached(self, name): + return self.cache[name] if name in self.cache else None + + def create_document_from_folder(provider, path): document = { 'file': os.path.basename(path), @@ -75,13 +95,48 @@ def create_hash(provider, document): return { **document, - 'hash':hash_str(''.join(hashes)) + 'hash': hash_str(''.join(hashes)) } +def create_page(provider: Provider, img: ImageCreator, document): + image_path = lambda x: os.path.join(document['folder'], x) + image_id = lambda filename: url_encode_text( + os.path.splitext(filename)[0] + ) + + def process_image(src: str): + path = image_path(src) + + if provider.exists(path): + url = lambda s, e: 'https://static.shburg.org/art/images/page-{page}-{id}-{size}{ext}'.format( + page=document['id'], + id=image_id(src), + size=s, + ext=e + ) + + image = img.create(path, url) + if image: + images.append(image) + return image['data']['big']['url'] + return None + + images = [] + post_html = create_post(document['data'], process_image) + + document['data'] = post_html + document['images'] = images + return document + + def sync_pages(provider, collection, update=True, delete=True, skip_unchanged=True): + img_sizes = settings.album_image_sizes + output_dir = settings.dir_static_images + sync = Sync() sync.collection = collection + image_creator = ImageCreator(provider, img_sizes, output_dir, {}) documents = list(filter( lambda x: provider.is_dir(x), @@ -120,6 +175,11 @@ def sync_pages(provider, collection, update=True, delete=True, skip_unchanged=Tr # documents # ) + documents = lmap( + lambda document: create_page(provider, image_creator, document), + documents + ) + # REPLACE IMAGES OBJECTS WITH IT _ID IN MONGODB documents = lmap( key_mapper('images', synced_images_ids), diff --git a/utils/Sync/utils/fn.py b/utils/Sync/utils/fn.py index 11ad079b..7cd0b53a 100644 --- a/utils/Sync/utils/fn.py +++ b/utils/Sync/utils/fn.py @@ -61,7 +61,8 @@ def map_item_key(item, key, map_fn): :param map_fn: :return: """ - item[key] = map_fn(item[key]) + if key in item: + item[key] = map_fn(item[key]) return item From e7a4eab102e4fe5a5c1f908bb01b2a5c360c1834 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 23 Nov 2016 02:11:21 +0300 Subject: [PATCH 014/368] update --- src/client/components/Article.js | 25 ++++++++++++++++++++++++- src/client/main.js | 6 ++++++ src/routes/gallery.js | 3 ++- src/routes/news.js | 19 ++++++++----------- src/style/body-wrapper.scss | 18 ++++++++++++++++++ src/style/components/cloud-page.scss | 15 --------------- src/style/components/navigation.scss | 1 + src/style/page.scss | 4 ++++ src/style/style.scss | 1 + src/style/vertical-image.scss | 28 ++++++++++++++++++++++++++++ src/templates/main.html | 11 +++++++---- 11 files changed, 99 insertions(+), 32 deletions(-) create mode 100644 src/client/main.js create mode 100644 src/style/vertical-image.scss diff --git a/src/client/components/Article.js b/src/client/components/Article.js index a3748a74..918bc7c6 100644 --- a/src/client/components/Article.js +++ b/src/client/components/Article.js @@ -8,8 +8,31 @@ export default function (app) { template: template, controllerAs: '$', controller: function ($sce) { - this.message = $sce.trustAsHtml(this.post.post); + //this.message = $sce.trustAsHtml(this.post.post); this.url = `/article/${this.post.id}`; + + const isVertical = ({width, height}) => width < height; + + const temp = document.createElement('div'); + temp.innerHTML = this.post.post; + + const vs = [...temp.querySelectorAll('img')] + .filter(isVertical) + .filter(i => i.parentNode) + .map(i => [i.parentNode, i]) + .map(([container, img]) => { + const url = img.src; + + const elem = document.createElement('div'); + elem.innerHTML = `
+
+ +
`; + + return container.replaceChild(elem, img); + }); + + this.message = $sce.trustAsHtml(temp.innerHTML); } }); }; \ No newline at end of file diff --git a/src/client/main.js b/src/client/main.js new file mode 100644 index 00000000..55a77e41 --- /dev/null +++ b/src/client/main.js @@ -0,0 +1,6 @@ +import ReactDOM from 'react-dom' +import {Copyright} from './components/Copyright' + +ReactDOM.render(, document.querySelector('.body-wrapper')) + +// \ No newline at end of file diff --git a/src/routes/gallery.js b/src/routes/gallery.js index 4d44638b..0b8be74c 100644 --- a/src/routes/gallery.js +++ b/src/routes/gallery.js @@ -45,7 +45,8 @@ function album() { const processAlbum = async album => { album.url = `/album/${album.id}`; - const previewImageId = album.images.length ? album.images[0] : null; + const previewFromImage = imgs => imgs.length ? imgs[0] : null; + const previewImageId = album.preview ? album.preview : previewFromImage(album.images); if (previewImageId) { const image = await c('images').findOne({_id: previewImageId}); album.preview = image.data.medium; diff --git a/src/routes/news.js b/src/routes/news.js index ca55852e..0b9045f1 100644 --- a/src/routes/news.js +++ b/src/routes/news.js @@ -26,11 +26,8 @@ function news() { const limit = parseInt(ctx.query['limit']) || 20; const skip = parseInt(ctx.query['skip']) || 0; - const query = {}; - if (ctx.query.type) query.type = ctx.query.type; - const now = new Date(); - const pinned = skip != 0 ? [] : await c('timeline') + const pinned = skip !== 0 ? [] : await c('timeline') .find({until: {$gte: now}}) .toArray(); @@ -38,18 +35,18 @@ function news() { const pinnedIds = pinned.map(id); let posts = await c('timeline') - .find(query) + .find({ + _id: {$nin: pinnedIds} + }) .sort({date: -1}) .skip(skip) .limit(limit) .toArray(); - ctx.body = [ - ...pinned.sort(sortNewsByDate), - ...posts.filter( - i => !pinnedIds.includes(id(i)) - ) - ]; + ctx.body = [ + ...pinned.sort(sortNewsByDate), + ...posts + ]; } })); } diff --git a/src/style/body-wrapper.scss b/src/style/body-wrapper.scss index a61f0073..a3e1de1c 100644 --- a/src/style/body-wrapper.scss +++ b/src/style/body-wrapper.scss @@ -9,6 +9,24 @@ .body-wrapper__content { margin: 0 auto 0; + + a { + color: $dark-color; + text-decoration: none; + border-bottom: 1px solid lighten($dark-color, 10%); + + &:hover { + border-bottom: 1px solid lighten($dark-color, 25%); + } + + &:active { + border-bottom: 1px solid $dark-color; + } + + &.invisible { + border-bottom: none; + } + } } @media (max-width: $mobile-width) { diff --git a/src/style/components/cloud-page.scss b/src/style/components/cloud-page.scss index e3b49649..967b60ad 100644 --- a/src/style/components/cloud-page.scss +++ b/src/style/components/cloud-page.scss @@ -4,21 +4,6 @@ margin-bottom: $post-margin; &__body{ - - a { - color: $dark-color; - text-decoration: none; - border-bottom: 1px solid lighten($dark-color, 10%); - - &:hover { - border-bottom: 1px solid lighten($dark-color, 25%); - } - - &:active { - border-bottom: 1px solid $dark-color; - } - } - h1{ text-align: center; margin-bottom: $single-margin; diff --git a/src/style/components/navigation.scss b/src/style/components/navigation.scss index de320247..246b9354 100644 --- a/src/style/components/navigation.scss +++ b/src/style/components/navigation.scss @@ -19,6 +19,7 @@ .navigation__right { color: $dark-color; + font-size: $smaller-font-size; margin-right: 1em; z-index: 1000; diff --git a/src/style/page.scss b/src/style/page.scss index 8e2fcda6..eb20c68c 100644 --- a/src/style/page.scss +++ b/src/style/page.scss @@ -1,6 +1,10 @@ .page { width: 100%; + & img{ + width: 100%; + } + &.ng-leave {} &.ng-enter {} } \ No newline at end of file diff --git a/src/style/style.scss b/src/style/style.scss index 9ded95b8..11ff318b 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -27,6 +27,7 @@ @import "page-animation"; @import "main-image"; @import "hudozka-title"; +@import "vertical-image"; @import "schedule-selector"; @import "schedule-mobile"; diff --git a/src/style/vertical-image.scss b/src/style/vertical-image.scss new file mode 100644 index 00000000..98c2f10b --- /dev/null +++ b/src/style/vertical-image.scss @@ -0,0 +1,28 @@ +@import "variables"; + +.vertical-image { + position: relative; + width: 100%; + overflow: hidden; + + & > img { + position: relative; + z-index: 1; + width: 100%; + display: block; + margin: 0 auto; + } + + &__back { + position: absolute; + filter: blur(15px) grayscale(0) opacity(.75); + + top: -50%; + + & > img { + width: 105%; + display: block; + margin: 0 auto; + } + } +} \ No newline at end of file diff --git a/src/templates/main.html b/src/templates/main.html index 23ea8d98..3bda62ee 100644 --- a/src/templates/main.html +++ b/src/templates/main.html @@ -23,12 +23,8 @@ - - - - + + + + + + From cfb5118c7567456b3922f5cdc547c3e9a16157ea Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 23 Nov 2016 02:17:44 +0300 Subject: [PATCH 015/368] main.html scripts body -> head --- src/templates/main.html | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/templates/main.html b/src/templates/main.html index 3bda62ee..44ea1032 100644 --- a/src/templates/main.html +++ b/src/templates/main.html @@ -23,9 +23,12 @@ - + + + + - - - - - - From a7b923ef1fbf0fbc480617cd2d6831ad17bccb19 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 23 Nov 2016 22:33:06 +0300 Subject: [PATCH 016/368] style update --- src/style/components/cloud-page.scss | 4 ++++ src/style/page.scss | 4 ---- src/style/style.scss | 2 +- src/templates/main.html | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/style/components/cloud-page.scss b/src/style/components/cloud-page.scss index 967b60ad..5d58f69d 100644 --- a/src/style/components/cloud-page.scss +++ b/src/style/components/cloud-page.scss @@ -31,6 +31,10 @@ margin-bottom: 1.25em; } + img { + width: 100%; + } + blockquote { background-color: hsl(215, 10%, 96%); padding: 1em 1em .5em; diff --git a/src/style/page.scss b/src/style/page.scss index eb20c68c..8e2fcda6 100644 --- a/src/style/page.scss +++ b/src/style/page.scss @@ -1,10 +1,6 @@ .page { width: 100%; - & img{ - width: 100%; - } - &.ng-leave {} &.ng-enter {} } \ No newline at end of file diff --git a/src/style/style.scss b/src/style/style.scss index 11ff318b..81d6982a 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -27,7 +27,7 @@ @import "page-animation"; @import "main-image"; @import "hudozka-title"; -@import "vertical-image"; +//@import "vertical-image"; @import "schedule-selector"; @import "schedule-mobile"; diff --git a/src/templates/main.html b/src/templates/main.html index 44ea1032..50949e26 100644 --- a/src/templates/main.html +++ b/src/templates/main.html @@ -20,7 +20,7 @@ - + From a18abe215c373bd9a6d6d2366386a434aa585ca1 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Thu, 24 Nov 2016 17:49:48 +0300 Subject: [PATCH 017/368] [sync] all --- utils/Sync/sync.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/Sync/sync.py b/utils/Sync/sync.py index 8febad88..533a4359 100644 --- a/utils/Sync/sync.py +++ b/utils/Sync/sync.py @@ -37,10 +37,10 @@ def main(provider, fn, collection_name): if __name__ == '__main__': io = lambda root: get_provider(settings.sync_provider_type, root) - # main(io(settings.dir_documents), sync_documents, settings.collection_documents) - # main(io(settings.dir_schedules), sync_schedules, settings.collection_schedules) - # main(io(settings.dir_events), sync_posts, settings.collection_events) - # main(io(settings.dir_news), sync_posts, settings.collection_news) - # main(io(settings.dir_collective), sync_persons, settings.collection_collective) - # main(io(settings.dir_gallery), sync_albums, settings.collection_albums) + main(io(settings.dir_documents), sync_documents, settings.collection_documents) + main(io(settings.dir_schedules), sync_schedules, settings.collection_schedules) + main(io(settings.dir_events), sync_posts, settings.collection_events) + main(io(settings.dir_news), sync_posts, settings.collection_news) + main(io(settings.dir_collective), sync_persons, settings.collection_collective) + main(io(settings.dir_gallery), sync_albums, settings.collection_albums) main(io(settings.dir_pages), sync_pages, settings.collection_pages) From 4034df5c2d5c0a0a2ed90bdca2292fd78ee0f0b5 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Thu, 24 Nov 2016 17:50:04 +0300 Subject: [PATCH 018/368] pinned news sorting --- src/routes/news.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/news.js b/src/routes/news.js index 0b9045f1..f4f75965 100644 --- a/src/routes/news.js +++ b/src/routes/news.js @@ -29,6 +29,7 @@ function news() { const now = new Date(); const pinned = skip !== 0 ? [] : await c('timeline') .find({until: {$gte: now}}) + .sort({date: -1}) .toArray(); const id = i => i._id; From 90e8918e4ce3fcf84e517a2811bdb6e60993d60e Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 3 Dec 2016 09:57:52 +0300 Subject: [PATCH 019/368] [sync] resize updated --- utils/Sync/utils/image/resize.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/Sync/utils/image/resize.py b/utils/Sync/utils/image/resize.py index 9d5c001b..a85f97f3 100644 --- a/utils/Sync/utils/image/resize.py +++ b/utils/Sync/utils/image/resize.py @@ -91,5 +91,8 @@ def image_magick_resize(ifile, ofile, size, quality=85): def image_magick_pdf_to_img(input_file, output_file): - i = "{image}[0]".format(image=input_file) - call(['convert', i, output_file]) + call([ + '/usr/local/bin/convert', + '{image}[0]'.format(image=input_file), + output_file + ]) From 52d481e0307698ba9a2b6ffaf52baf7f7e1fa69d Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 3 Dec 2016 09:58:46 +0300 Subject: [PATCH 020/368] [site] menu updated --- src/models/menu.js | 7 ++++++- src/style/variables.scss | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/models/menu.js b/src/models/menu.js index af1a892e..c0426d09 100644 --- a/src/models/menu.js +++ b/src/models/menu.js @@ -14,6 +14,11 @@ export default [ "url": "/schedule", "color": "green" }, + { + "text": "Предметы", + "url": "/courses", + "color": "magenta" + }, { "text": "Коллектив", "url": "/collective", @@ -32,6 +37,6 @@ export default [ { "text": "Сведения об образовательной организации", "url": "/info", - "color": "red" + "color": "gray" } ]; diff --git a/src/style/variables.scss b/src/style/variables.scss index 5dfdc202..c2a293e8 100644 --- a/src/style/variables.scss +++ b/src/style/variables.scss @@ -30,7 +30,9 @@ $orange-color: rgb(240, 160, 65); $green-color: rgb(92, 190, 64); $yellow-color: rgb(255, 238, 0); $pink-color: rgb(246, 85, 160); +$magenta-color: rgb(214, 39, 246); $red-color: rgb(246, 27, 20); +$gray-color: rgb(153, 154, 160); $link-color: $blue-color; $inactive-link-color: $light-color; From 9443f6819559d508c255844f512d27e178a7aba2 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 3 Dec 2016 10:35:25 +0300 Subject: [PATCH 021/368] [site] - main (react) --- src/client/main.js | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/client/main.js diff --git a/src/client/main.js b/src/client/main.js deleted file mode 100644 index 55a77e41..00000000 --- a/src/client/main.js +++ /dev/null @@ -1,6 +0,0 @@ -import ReactDOM from 'react-dom' -import {Copyright} from './components/Copyright' - -ReactDOM.render(, document.querySelector('.body-wrapper')) - -// \ No newline at end of file From 6135e57b54a49a90f296574e4d44af773ea0eec1 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 3 Dec 2016 10:39:21 +0300 Subject: [PATCH 022/368] eslint config updated --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 52335391..b0809f32 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,7 +13,7 @@ module.exports = { "DISQUS": true }, "rules": { - "semi": "off", + "semi": ["error", "never"], "space-before-function-paren": "off", "no-tabs": "off", "indent": ["error", "tab"] From 10bf37b094e2675b9e3b9dcb7d9487bb7cda77ed Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 3 Dec 2016 10:39:38 +0300 Subject: [PATCH 023/368] [site] documents router eslinted --- src/routes/documents.js | 105 ++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/src/routes/documents.js b/src/routes/documents.js index b5de9a82..dda6a0c9 100644 --- a/src/routes/documents.js +++ b/src/routes/documents.js @@ -1,73 +1,74 @@ -import compose from 'koa-compose'; -import route from 'koa-route'; -import {index, json, accepts} from './'; -import {c} from '../core/db'; +import compose from 'koa-compose' +import route from 'koa-route' +import {index, json, accepts} from './' +import {c} from '../core/db' async function exists(ctx, id) { - let i = await c('documents').findOne({id: id}); - return i ? true : false; + let i = await c('documents').findOne({id: id}) + return Boolean(i) } export default function () { - return compose([ - documents(), - document(), - type() - ]); -}; + return compose([ + documents(), + document(), + type() + ]) +} function documents() { - return route.get('/documents', json( - async(ctx) => { - let query = {}; - ctx.body = await c('documents') - .find(query) - .toArray(); - } - )); + return route.get('/documents', json( + async(ctx) => { + let query = {} + ctx.body = await c('documents') + .find(query) + .toArray() + } + )) } function document() { - return route.get('/documents/:id', accepts({ - 'text/html': index(exists), - 'text/plain': index(exists), - 'application/json': async(ctx, id) => { - let i = await c('documents').findOne({id: id}); - if (!i) ctx.status = 404; - else { - i = await populateDocPreview(i); - ctx.body = i; - } - } - })); + return route.get('/documents/:id', accepts({ + 'text/html': index(exists), + 'text/plain': index(exists), + 'application/json': async(ctx, id) => { + let i = await c('documents').findOne({id: id}) + if (!i) ctx.status = 404 + else { + i = await populateDocPreview(i) + ctx.body = i + } + } + })) } function type() { - return route.get('/documents/type/:type', async(ctx, type) => { - let types = { - 'document': ['documents', {type: 'document'}, populateDocPreview], - 'award': ['documents', {type: 'award'}, populateDocPreview] - }; + return route.get('/documents/type/:type', async(ctx, type) => { + let types = { + 'document': ['documents', {type: 'document'}, populateDocPreview], + 'award': ['documents', {type: 'award'}, populateDocPreview] + } - if (type in types) { - let [collection, query, mapFn] = types[type]; + if (type in types) { + let [collection, query, mapFn] = types[type] - let docs = await c(collection) - .find(query) - .toArray(); + let docs = await c(collection) + .find(query) + .toArray() - if (mapFn) docs = await Promise.all( - docs.map(mapFn) - ); + if (mapFn) { + docs = await Promise.all( + docs.map(mapFn) + ) } - ctx.body = docs; - } else { - ctx.status = 404; - } - }); + ctx.body = docs + } else { + ctx.status = 404 + } + }) } async function populateDocPreview(doc) { - doc.preview = await c('images').findOne({_id: doc.preview}); - return doc; + doc.preview = await c('images').findOne({_id: doc.preview}) + return doc } From e9cb52d20be9e673dd7f60abc0d37e220e3478b4 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 3 Jan 2017 06:28:33 +0300 Subject: [PATCH 024/368] [site] eslint config updated --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index b0809f32..9e6ae9f1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,6 +15,7 @@ module.exports = { "rules": { "semi": ["error", "never"], "space-before-function-paren": "off", + "comma-dangle": "off", "no-tabs": "off", "indent": ["error", "tab"] } From e9ac51d675953c0390b3401bda10c2ba57dc01af Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 3 Jan 2017 06:30:03 +0300 Subject: [PATCH 025/368] [data] updated 0.0.1 -> 0.0.2 --- modules/hudozka-data/package.json | 9 ++-- modules/hudozka-data/src/Data.js | 53 ++++++++++++------ modules/hudozka-data/src/DataManager.js | 14 ++--- modules/hudozka-data/src/Document.js | 5 ++ modules/hudozka-data/src/Schedule.js | 62 ++++++++++----------- modules/hudozka-data/src/Timeline.js | 72 ++++++++++++++++--------- modules/hudozka-data/test/Data.js | 18 +++++++ 7 files changed, 152 insertions(+), 81 deletions(-) create mode 100644 modules/hudozka-data/src/Document.js create mode 100644 modules/hudozka-data/test/Data.js diff --git a/modules/hudozka-data/package.json b/modules/hudozka-data/package.json index e16e97cf..34c83670 100644 --- a/modules/hudozka-data/package.json +++ b/modules/hudozka-data/package.json @@ -1,18 +1,21 @@ { "name": "hudozka-data", "private": true, - "version": "0.0.1", + "version": "0.0.2", "description": "", "main": "lib/index.js", "scripts": { - "compile": "babel --presets es2015,stage-0 src/ -d lib/", + "compile": "babel --plugins async-to-promises --presets es2015,stage-0 src/ -d lib/", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "devDependencies": { "babel-cli": "^6.6.5", + "babel-plugin-async-to-promises": "^1.0.5", + "babel-polyfill": "^6.16.0", "babel-preset-es2015": "^6.6.0", - "babel-preset-stage-0": "^6.5.0" + "babel-preset-stage-0": "^6.5.0", + "mongodb": "^2.2.12" } } diff --git a/modules/hudozka-data/src/Data.js b/modules/hudozka-data/src/Data.js index 1fb6ee14..991c2062 100644 --- a/modules/hudozka-data/src/Data.js +++ b/modules/hudozka-data/src/Data.js @@ -1,21 +1,44 @@ -import {EventEmitter} from 'events'; +import {EventEmitter} from 'events' export default class Data extends EventEmitter { - constructor(store) { - super(); - this.save = true; - this.store = store; - } + constructor(store) { + super() + this.save = true + this.store = store + } - update(document) { - this.emit('update', document); - } + broadcast(data) { + this.emit('update', data) + } - disableSaving() { - this.save = false; - } + disableSaving() { + this.save = false + } - enableSaving() { - this.save = true; - } + enableSaving() { + this.save = true + } + + async create(data) { + const id = data.id + if (!id) throw new Error('Field `id` not found in Data object') + const query = {id: id} + + await this.store.update(query, data, {upsert: true}) + const result = await this.store.findOne(query) + this.emit('update', result) + return result + } + + async read(id) { + return this.store.findOne({id: id}) + } + + async find(query, skip = 0, limit = 0) { + const cursor = this.store + .find(query) + .skip(skip) + if (limit) cursor.limit(limit) + return await cursor.toArray() + } } diff --git a/modules/hudozka-data/src/DataManager.js b/modules/hudozka-data/src/DataManager.js index 43f9eb06..79fe7f28 100644 --- a/modules/hudozka-data/src/DataManager.js +++ b/modules/hudozka-data/src/DataManager.js @@ -1,9 +1,11 @@ -import Timeline from './Timeline'; -import Schedule from './Schedule'; +import Timeline from './Timeline' +import Schedule from './Schedule' +import Document from './Document' export default class DataManager { - constructor(stores) { - this.timeline = new Timeline(stores.timeline); - this.schedule = new Schedule(stores.schedules); - } + constructor(stores) { + this.timeline = new Timeline(stores.timeline) + this.schedule = new Schedule(stores.schedules) + this.document = new Document(stores.documents) + } } diff --git a/modules/hudozka-data/src/Document.js b/modules/hudozka-data/src/Document.js new file mode 100644 index 00000000..fa7eb0e5 --- /dev/null +++ b/modules/hudozka-data/src/Document.js @@ -0,0 +1,5 @@ +import Data from './Data' + +export default class Document extends Data { + +} diff --git a/modules/hudozka-data/src/Schedule.js b/modules/hudozka-data/src/Schedule.js index 03dfd2a0..d9118eac 100644 --- a/modules/hudozka-data/src/Schedule.js +++ b/modules/hudozka-data/src/Schedule.js @@ -2,47 +2,43 @@ import Data from './Data'; export default class Schedule extends Data { - create(){ + create() { - } + } - read(){ + read() { - } + } - update(){ + delete() { - } + } - delete(){ + find(query) { - } + } - find(query){ + add(post) { + let savePost = async(post) => { + const id = post.id; + const type = post.type; + const query = {id: id, type: type}; - } + await this.store.update(query, post, {upsert: true}); + let document = await this.store.find(query).limit(1).toArray(); + return document[0]; + }; - add(post) { - let savePost = async(post) => { - const id = post.id; - const type = post.type; - const query = {id: id, type: type}; - - await this.store.update(query, post, {upsert: true}); - let document = await this.store.find(query).limit(1).toArray(); - return document[0]; - }; - - let add = async(post) => { - let document = post; - if(this.save){ - document = await savePost(post); - } - - this.update(document); - return document; - }; - - return add(post); - } + let add = async(post) => { + let document = post; + if (this.save) { + document = await savePost(post); + } + + this.broadcast(document); + return document; + }; + + return add(post); + } } diff --git a/modules/hudozka-data/src/Timeline.js b/modules/hudozka-data/src/Timeline.js index 21ab1de0..054a5219 100644 --- a/modules/hudozka-data/src/Timeline.js +++ b/modules/hudozka-data/src/Timeline.js @@ -1,27 +1,51 @@ -import Data from './Data'; +import Data from './Data' export default class Timeline extends Data { - add(post) { - let savePost = async(post) => { - const id = post.id; - const type = post.type; - const query = {id: id, type: type}; - - await this.store.update(query, post, {upsert: true}); - let document = await this.store.find(query).limit(1).toArray(); - return document[0]; - }; - - let add = async(post) => { - let document = post; - if(this.save){ - document = await savePost(post); - } - - this.update(document); - return document; - }; - - return add(post); - } + async create(post) { + let savePost = async(post) => { + const id = post.id + const type = post.type + const query = {id: id, type: type} + + await this.store.update(query, post, {upsert: true}) + let document = await this.store.find(query).limit(1).toArray() + return document[0] + } + + let add = async(post) => { + let document = post + if (this.save) { + document = await savePost(post) + } + + this.broadcast(document) + return document + } + + return add(post) + } + + add(post) { + let savePost = async(post) => { + const id = post.id + const type = post.type + const query = {id: id, type: type} + + await this.store.update(query, post, {upsert: true}) + let document = await this.store.find(query).limit(1).toArray() + return document[0] + } + + let add = async(post) => { + let document = post + if (this.save) { + document = await savePost(post) + } + + this.broadcast(document) + return document + } + + return add(post) + } } diff --git a/modules/hudozka-data/test/Data.js b/modules/hudozka-data/test/Data.js new file mode 100644 index 00000000..4bcff7b0 --- /dev/null +++ b/modules/hudozka-data/test/Data.js @@ -0,0 +1,18 @@ +require('babel-polyfill') + +const Data = require('../lib/Data').default +//const Data = require('../src/Data') +const MongoClient = require('mongodb').MongoClient + +MongoClient + .connect('mongodb://localhost:27017/hudozka') + .then(function (db) { + const store = db.collection('documents') + const data = new Data(store) + + data.find({}) + .then(function(data){ + console.log('data >') + console.log(data) + }) + }) From d5db0ca07e5949c6c13799da5b26c473f89b5ad9 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 3 Jan 2017 06:31:02 +0300 Subject: [PATCH 026/368] [site] updated --- src/index.js | 57 ++++++++++++++++++++--------------------- src/routes/documents.js | 10 +++++++- src/routes/index.js | 4 +-- src/server.js | 2 +- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/src/index.js b/src/index.js index 51d7324b..32693988 100644 --- a/src/index.js +++ b/src/index.js @@ -1,40 +1,39 @@ -import 'babel-polyfill'; +import 'babel-polyfill' -import config from './config'; -import {name} from './config'; -import {connect, collection} from './core/db'; -import io from './io'; -import server from './server'; +import config, {name} from './config' +import {connect, collection} from './core/db' +import io from './io' +import server from './server' -import DataManager from 'hudozka-data'; -// var DataManager = require('hudozka-data').default; +import DataManager from 'hudozka-data' function main() { - async function loop() { - const db = config.db.uri; - await connect(db); + async function loop() { + const db = config.db.uri + await connect(db) - try { - let data = new DataManager({ - timeline: collection('timeline'), - schedules: collection('schedules') - }); + try { + let data = new DataManager({ + timeline: collection('timeline'), + schedules: collection('schedules'), + documents: collection('documents'), + }) - let app = server(data); - io(app, data); + let app = server(data) + io(app, data) - app.listen(config.port); - } catch (e) { - console.error(e.stack); - return; - } + app.listen(config.port) + } catch (e) { + console.error(e.stack) + return + } - console.log(`App ${name} started`); - console.log(`listening ${config.port}`); - console.log(`db address ${db}`); - } + console.log(`App ${name} started`) + console.log(`listening ${config.port}`) + console.log(`db address ${db}`) + } - loop(); + loop() } -main(); +main() diff --git a/src/routes/documents.js b/src/routes/documents.js index dda6a0c9..82a62bb6 100644 --- a/src/routes/documents.js +++ b/src/routes/documents.js @@ -8,14 +8,22 @@ async function exists(ctx, id) { return Boolean(i) } -export default function () { +export default function (store) { return compose([ + docs(store), documents(), document(), type() ]) } +function docs(store) { + return route.get('/docs', async ctx => { + const docs = await store.document.find({}) + ctx.body = docs + }) +} + function documents() { return route.get('/documents', json( async(ctx) => { diff --git a/src/routes/index.js b/src/routes/index.js index f3bc91d6..e6ef31d2 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -20,14 +20,14 @@ import pages from './pages'; let main = () => route.get('/', index()); -export function routes() { +export function routes(store) { return compose([ main(), sitemap(), schedule(), news(), gallery(), - documents(), + documents(store), teachers(), events(), articles(), diff --git a/src/server.js b/src/server.js index 568b4661..255a0cca 100644 --- a/src/server.js +++ b/src/server.js @@ -45,7 +45,7 @@ export default function (store) { app.use($(redirect(redirectionTable))); app.use($(helmet())); app.use(queryObject()); - app.use(routes()); + app.use(routes(store)); return Server(app.callback()); } From ca23ccc75fb376d91f5ed93caad0acb09c90d822 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 22 Jan 2017 06:36:03 +0300 Subject: [PATCH 027/368] + accessibility styles --- gulpfile.babel.js | 19 ++- src/style-accessibility/album.scss | 134 ++++++++++++++++++ src/style-accessibility/body-wrapper.scss | 32 +++++ .../components/album-collection.scss | 15 ++ src/style-accessibility/components/album.scss | 48 +++++++ .../components/article-page-control.scss | 21 +++ .../components/article.scss | 80 +++++++++++ .../components/breadcrumbs.scss | 45 ++++++ .../components/cloud-page.scss | 68 +++++++++ .../components/document.scss | 34 +++++ .../components/documents-container.scss | 13 ++ .../components/footer-links.scss | 21 +++ .../components/gallery-item.scss | 39 +++++ .../components/main-menu.scss | 48 +++++++ .../components/navigation.scss | 44 ++++++ .../components/page-collective.scss | 25 ++++ .../components/page-schedule.scss | 12 ++ .../components/parallax.scss | 24 ++++ .../components/schedule-table.scss | 132 +++++++++++++++++ .../components/teacher-proifile.scss | 75 ++++++++++ .../components/timeline-record-instagram.scss | 53 +++++++ .../components/timeline-record.scss | 9 ++ .../components/timeline.scss | 33 +++++ src/style-accessibility/content.scss | 99 +++++++++++++ src/style-accessibility/error-404.scss | 14 ++ src/style-accessibility/footer.scss | 58 ++++++++ src/style-accessibility/hudozka-title.scss | 26 ++++ src/style-accessibility/kazimir/video.scss | 16 +++ src/style-accessibility/main-image.scss | 24 ++++ src/style-accessibility/main.scss | 61 ++++++++ src/style-accessibility/page-animation.scss | 56 ++++++++ src/style-accessibility/page.scss | 6 + src/style-accessibility/schedule-mobile.scss | 61 ++++++++ .../schedule-selector.scss | 10 ++ src/style-accessibility/style.scss | 39 +++++ src/style-accessibility/tape-viewer.scss | 88 ++++++++++++ src/style-accessibility/variables.scss | 73 ++++++++++ src/style-accessibility/vertical-image.scss | 28 ++++ 38 files changed, 1682 insertions(+), 1 deletion(-) create mode 100644 src/style-accessibility/album.scss create mode 100644 src/style-accessibility/body-wrapper.scss create mode 100644 src/style-accessibility/components/album-collection.scss create mode 100644 src/style-accessibility/components/album.scss create mode 100644 src/style-accessibility/components/article-page-control.scss create mode 100644 src/style-accessibility/components/article.scss create mode 100644 src/style-accessibility/components/breadcrumbs.scss create mode 100644 src/style-accessibility/components/cloud-page.scss create mode 100644 src/style-accessibility/components/document.scss create mode 100644 src/style-accessibility/components/documents-container.scss create mode 100644 src/style-accessibility/components/footer-links.scss create mode 100644 src/style-accessibility/components/gallery-item.scss create mode 100644 src/style-accessibility/components/main-menu.scss create mode 100644 src/style-accessibility/components/navigation.scss create mode 100644 src/style-accessibility/components/page-collective.scss create mode 100644 src/style-accessibility/components/page-schedule.scss create mode 100644 src/style-accessibility/components/parallax.scss create mode 100644 src/style-accessibility/components/schedule-table.scss create mode 100644 src/style-accessibility/components/teacher-proifile.scss create mode 100644 src/style-accessibility/components/timeline-record-instagram.scss create mode 100644 src/style-accessibility/components/timeline-record.scss create mode 100644 src/style-accessibility/components/timeline.scss create mode 100644 src/style-accessibility/content.scss create mode 100644 src/style-accessibility/error-404.scss create mode 100644 src/style-accessibility/footer.scss create mode 100644 src/style-accessibility/hudozka-title.scss create mode 100644 src/style-accessibility/kazimir/video.scss create mode 100644 src/style-accessibility/main-image.scss create mode 100644 src/style-accessibility/main.scss create mode 100644 src/style-accessibility/page-animation.scss create mode 100644 src/style-accessibility/page.scss create mode 100644 src/style-accessibility/schedule-mobile.scss create mode 100644 src/style-accessibility/schedule-selector.scss create mode 100644 src/style-accessibility/style.scss create mode 100644 src/style-accessibility/tape-viewer.scss create mode 100644 src/style-accessibility/variables.scss create mode 100644 src/style-accessibility/vertical-image.scss diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 7499d92b..e3494279 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -51,6 +51,23 @@ gulp.task('style', () => { .pipe(gulp.dest('./public')); }); +gulp.task('style-accessibility', () => { + const processors = [ + autoprefixer({ + browsers: ['last 1 version'] + }), + cssnano({ + zindex: false + }) + ]; + + return gulp.src('./src/style-accessibility/style.scss') + .pipe(sass()) + .pipe(postcss(processors)) + .pipe(concat('style-accessibility.css')) + .pipe(gulp.dest('./public')); +}); + gulp.task('copy fonts', () => { return gulp.src('./src/assets/fonts/*/*') .pipe(gulp.dest('./public/fonts')); @@ -120,7 +137,7 @@ gulp.task('production', () => { isProduction = true; }); -gulp.task('default', ['style', 'compile']); +gulp.task('default', ['style', 'style-accessibility', 'compile']); gulp.task('copy', ['copy templates', 'copy fonts', 'copy graphics', 'copy 3rdparty', 'copy robots.txt']); gulp.task('deploy', ['default', 'copy', 'compile 3rdparty', 'imagemin']); gulp.task('compile production', ['production', 'compile']); diff --git a/src/style-accessibility/album.scss b/src/style-accessibility/album.scss new file mode 100644 index 00000000..93368807 --- /dev/null +++ b/src/style-accessibility/album.scss @@ -0,0 +1,134 @@ +@import "variables"; + +.album-block { + //margin: 1em auto 2em; + + h3 { + text-align: center; + margin: 1.5em 0 1em; + } + + .album { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + } + + .album-info { + width: 80%; + margin: 0 0 3em; + } + + .album-info p { + margin: 0 0 .5em; + } + + .album-item { + width: 80%; + box-sizing: border-box; + margin: 0 0 4em; + position: relative; + background-color: white; + padding: 6em; + box-shadow: 0 4px 14px -10px rgba(0,0,0, .85); + + &.vertical { + width: 47%; + min-width: 30em; + max-width: 35em; + } + + img{ + width: 100%; + box-sizing: border-box; + border: .25em solid #eee; + border-top-color: #bbb; + border-left-color: #ddd; + } + } + + .product-info{ + text-align: center; + position: absolute; + width: 100%; + left: 0; + bottom: 1em; + + & > div { + display: inline-block; + padding: .5em 1em; + background-color: white; + border: 1px solid #f5f5f5; + border-radius: .25em; + box-shadow: 0 5p/x 4px -4px rgba(0,0,0, .5); + } + + p { + font-size: 0.75em; + } + + .title { + font-weight: bold; + } + } +} + +@media screen and (max-width: $mobile-width) { + .album-block { + width: 100%; + margin: 1em auto 2em; + + h3 { + text-align: left; + margin: 1em 0 0.5em; + } + + .album-info{ + width: 100%; + margin: 0 0 2em; + } + + .album-item { + width: 100%; + padding: 1em 1em 5em; + margin: 0 0 2em; + + img{ + border: .1em solid #eee; + border-top-color: #bbb; + border-left-color: #ddd; + } + } + + .product-info { + bottom: .5em; + } + } +} + +@media screen and (min-width: $mobile-width) and (max-width: $desktop-width){ + .album-block { + .album-info{ + width: 100%; + margin: 0 0 2em; + font-size: 0.75em; + } + + .album-item { + width: 100%; + padding: 2em 2em 5em; + margin: 0 0 2em; + + img{ + border: .15em solid #eee; + border-top-color: #bbb; + border-left-color: #ddd; + } + } + + .product-info { + bottom: .5em; + } + } +} \ No newline at end of file diff --git a/src/style-accessibility/body-wrapper.scss b/src/style-accessibility/body-wrapper.scss new file mode 100644 index 00000000..434a5ef5 --- /dev/null +++ b/src/style-accessibility/body-wrapper.scss @@ -0,0 +1,32 @@ +@import "variables"; + +.body-wrapper { + background-color: white; + + font-family: $text-font; + font-size: $default-font-size; +} + +.body-wrapper__content { + margin: 0 auto 0; + + a { + color: $dark-color; + text-decoration: none; + border-bottom: 1px solid $dark-color; + + &:hover { + border-width: 2px; + } + + &.invisible { + border-bottom: none; + } + } +} + +@media (max-width: $mobile-width) { + .body-wrapper__content { + margin: $menu-thickness auto 0; + } +} diff --git a/src/style-accessibility/components/album-collection.scss b/src/style-accessibility/components/album-collection.scss new file mode 100644 index 00000000..92321171 --- /dev/null +++ b/src/style-accessibility/components/album-collection.scss @@ -0,0 +1,15 @@ +@import "../variables"; + +.album-collection{ + &__body{ + display: flex; + flex-wrap: wrap; + position: relative; + justify-content: center; + align-items:flex-start; + } + + &__title{ + + } +} diff --git a/src/style-accessibility/components/album.scss b/src/style-accessibility/components/album.scss new file mode 100644 index 00000000..6a1458c0 --- /dev/null +++ b/src/style-accessibility/components/album.scss @@ -0,0 +1,48 @@ +@import "../variables"; + +.album { + margin-bottom: $double-margin; + + &__head { + margin-bottom: 1.25em; + + h3 { + font-size: $biggest-font-size; + text-align: center; + } + + .date { + text-align: center; + color: #aaa; + } + + a { + color: $dark-color; + border-bottom: none; + } + } + + &__body{ + img { + max-width: 100%; + max-height: 40em; + + display: block; + margin: 1.25em auto $small-margin; + } + + p{ + margin-bottom: 1.25em; + } + } +} + +@media (max-width: $mobile-width) { + .album { + &__body { + img { + max-height: 20em; + } + } + } +} \ No newline at end of file diff --git a/src/style-accessibility/components/article-page-control.scss b/src/style-accessibility/components/article-page-control.scss new file mode 100644 index 00000000..58eddef7 --- /dev/null +++ b/src/style-accessibility/components/article-page-control.scss @@ -0,0 +1,21 @@ +@import "../variables"; + +.article-page-control{ + text-align: center; + + a{ + color: #aaa; + } + + &__top { + //padding: $single-margin 0 0; + //margin: $single-margin 0 0; + padding: 0 0 $single-margin; + margin: 0 0 $single-margin; + } + + &__bottom { + padding: 0 0 $single-margin; + margin: 0 0 $single-margin; + } +} diff --git a/src/style-accessibility/components/article.scss b/src/style-accessibility/components/article.scss new file mode 100644 index 00000000..09d3f0af --- /dev/null +++ b/src/style-accessibility/components/article.scss @@ -0,0 +1,80 @@ +@import "../variables"; + +.article { + margin-bottom: $post-margin; + + &__head { + margin-bottom: 1.25em; + + h3 { + font-size: $biggest-font-size; + text-align: center; + } + + .date { + text-align: center; + color: $dark-color + } + + a { + color: $dark-color; + border-bottom: none; + } + } + + &__body{ + img { + max-width: 100%; + //max-height: 100%; + + max-height: 40em; + + display: block; + margin: 1.25em auto $small-margin; + } + + ul, ol{ + margin-left: $half-margin; + margin-bottom: $single-margin; + padding-left: $single-margin; + } + + ul{ + list-style: disc; + } + + p{ + margin-bottom: 1.25em; + } + + blockquote { + background-color: hsl(215, 10%, 96%); + padding: 1em 1em .5em; + margin: $single-margin 0; + font-family: $title-font; + font-style: italic; + font-weight: normal; + font-size: 1.25em; + + cite { + margin-top: $single-margin; + display: block; + color: #aaa; + font-size: initial; + font-family: $text-font; + text-align: right; + margin-right: $single-margin; + } + } + } +} + +@media (max-width: $mobile-width) { + .article { + &__body { + img { + max-height: 20em; + } + } + } +} diff --git a/src/style-accessibility/components/breadcrumbs.scss b/src/style-accessibility/components/breadcrumbs.scss new file mode 100644 index 00000000..79ca74b9 --- /dev/null +++ b/src/style-accessibility/components/breadcrumbs.scss @@ -0,0 +1,45 @@ +@import "../variables"; + +$font-size: 0.75em; +$item-active-color: $link-color; +$item-inactive-color: $inactive-link-color; +$separator: '⟶'; +$mobile-separator: '>'; + +breadcrumbs{ + padding: .35em 0 0; + color: $item-inactive-color; + + a { + color: $item-active-color; + } + + ul{ + list-style: none; + + li { + display: inline-block; + + &:not(:first-child):before{ + content: $separator; + margin-left: .4em; + } + } + } +} + +@media screen and (max-width: $mobile-width) { + breadcrumbs{ + margin: 0; + font-size: $font-size; + + ul{ + li { + &:not(:first-child):before{ + content: $mobile-separator; + margin-left: .2em; + } + } + } + } +} diff --git a/src/style-accessibility/components/cloud-page.scss b/src/style-accessibility/components/cloud-page.scss new file mode 100644 index 00000000..5d58f69d --- /dev/null +++ b/src/style-accessibility/components/cloud-page.scss @@ -0,0 +1,68 @@ +@import "../variables"; + +.cloud-page { + margin-bottom: $post-margin; + + &__body{ + h1{ + text-align: center; + margin-bottom: $single-margin; + + font-size: $biggest-font-size; + } + + h2 { + text-align: left; + margin-top: $double-margin; + font-family: $text-font; + } + + ul, ol{ + margin-left: $half-margin; + margin-bottom: $single-margin; + padding-left: $single-margin; + } + + ul{ + list-style: disc; + } + + p{ + margin-bottom: 1.25em; + } + + img { + width: 100%; + } + + blockquote { + background-color: hsl(215, 10%, 96%); + padding: 1em 1em .5em; + margin: $single-margin 0; + font-family: $title-font; + font-style: italic; + font-weight: normal; + font-size: 1.25em; + + cite { + margin-top: $single-margin; + display: block; + color: #aaa; + font-size: initial; + font-family: $text-font; + text-align: right; + margin-right: $single-margin; + } + } + } +} + +@media (max-width: $mobile-width) { + .cloud-page { + &__body { + img { + max-height: 20em; + } + } + } +} diff --git a/src/style-accessibility/components/document.scss b/src/style-accessibility/components/document.scss new file mode 100644 index 00000000..30d86a77 --- /dev/null +++ b/src/style-accessibility/components/document.scss @@ -0,0 +1,34 @@ +@import "../variables"; + +.document { + display: flex; + flex-direction: column; + align-items: center; + padding: 0; + margin: 0 $single-margin $double-margin; + + p { + text-align: center; + } +} + +.document__image{ + img { + width: 100%; + box-shadow: $white-shadow; + } +} + +.document__image--medium{ + max-width: 7.5em; +} + +.document__image--big{ + max-width: 20em; +} + +@media (max-width: $mobile-width) { + .document { + margin: 0 $single-margin/2 $single-margin; + } +} diff --git a/src/style-accessibility/components/documents-container.scss b/src/style-accessibility/components/documents-container.scss new file mode 100644 index 00000000..42d1ac73 --- /dev/null +++ b/src/style-accessibility/components/documents-container.scss @@ -0,0 +1,13 @@ +@import "../variables"; + +.documents-container { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: baseline; +} + +@media (max-width: $mobile-width) { + .documents-container { + } +} diff --git a/src/style-accessibility/components/footer-links.scss b/src/style-accessibility/components/footer-links.scss new file mode 100644 index 00000000..60b13ba2 --- /dev/null +++ b/src/style-accessibility/components/footer-links.scss @@ -0,0 +1,21 @@ +@import "../variables"; + +.footer-links { + &__header { + margin-bottom: $single-margin; + font-size: $bigger-font-size; + color: $light-color; + } + + &__link { + margin-bottom: $half-margin; + // + // a { + // border-bottom: 1px solid darken($link-color, 40%); + // } + } + + ul { + list-style: none; + } +} diff --git a/src/style-accessibility/components/gallery-item.scss b/src/style-accessibility/components/gallery-item.scss new file mode 100644 index 00000000..aacb524f --- /dev/null +++ b/src/style-accessibility/components/gallery-item.scss @@ -0,0 +1,39 @@ +@import "../variables"; + +$img-max-width: 500px; +$double-margin-half: $double-margin / 2; +$percentage: 25%; + +.gallery-item { + box-sizing: padding-box; + padding: 0; + + width: 13em; + height: 15em; + margin: 0 $single-margin $double-margin; + overflow: hidden; + + h3 { + text-align: center; + } + + a { + color: $dark-color; + border-bottom: none; + + &:hover { + border-bottom: none; + color: $blue-color; + } + } + + img { + width: 100%; + } +} + +@media screen and (max-width: $mobile-width) { + .gallery-item { + margin: 0 0 $double-margin; + } +} diff --git a/src/style-accessibility/components/main-menu.scss b/src/style-accessibility/components/main-menu.scss new file mode 100644 index 00000000..c9b74c22 --- /dev/null +++ b/src/style-accessibility/components/main-menu.scss @@ -0,0 +1,48 @@ +@import "../variables"; + +.main-menu { + white-space: nowrap; + + font-size: $normal-font-size; + color: $menu-inactive-item-color; + + list-style: none; + + li { + display: inline-block; + padding: 0.3em 0.2em 0.5em; + margin: 0 0.5em; + + &:first-child { + margin-left: 1em; + } + } + + a { + text-decoration: none; + + color: $dark-color; + border-bottom: 1px solid $dark-color; + } + + a:hover { + border-width: 2px; + } + + .selected { + font-weight: bold; + border-top: $menu-colored-mark-thickness solid $dark-color; + + a:link, a:visited { + color: $dark-color; + text-decoration: none; + border-bottom: none; + } + } +} + +@media (max-width: $mobile-width) { + .main-menu{ + font-size: 1em; + } +} diff --git a/src/style-accessibility/components/navigation.scss b/src/style-accessibility/components/navigation.scss new file mode 100644 index 00000000..2bbc13a1 --- /dev/null +++ b/src/style-accessibility/components/navigation.scss @@ -0,0 +1,44 @@ +@import "../variables"; + +.navigation { + -webkit-overflow-scrolling: touch; + + width: 100%; + z-index: 100; + overflow-x: scroll; + position: fixed; + top: 0; + white-space: nowrap; + + background-color: rgb(255, 255, 255); + + display: flex; + justify-content: space-between; + align-items: center; +} + +.navigation__right { + color: $dark-color; + font-size: $normal-font-size; + margin-right: 1em; + + z-index: 1000; +} + +@media (max-width: $mobile-width) { + .navigation { + background-color: white; + } + + .navigation__right { + display: none; + } +} + +@media screen and (min-width: $tablet-min-width) and (max-width: $tablet-max-width) { + @media screen and (orientation: portrait) { + .navigation__right { + display: none; + } + } +} diff --git a/src/style-accessibility/components/page-collective.scss b/src/style-accessibility/components/page-collective.scss new file mode 100644 index 00000000..f7007e75 --- /dev/null +++ b/src/style-accessibility/components/page-collective.scss @@ -0,0 +1,25 @@ +@import "../variables"; + +.page-collective { + &.ng-leave { + animation: slideOutLeft $short-duration both ease-in; + } + + &.ng-enter { + animation: slideInRight $short-duration both ease-in; + } +} + +.page-collective { + &__collective-image { + //min-height: 40em; + } +} + +@media (max-width: $mobile-width) { + .page-collective { + &__collective-image { + display: none; + } + } +} \ No newline at end of file diff --git a/src/style-accessibility/components/page-schedule.scss b/src/style-accessibility/components/page-schedule.scss new file mode 100644 index 00000000..edc51fbe --- /dev/null +++ b/src/style-accessibility/components/page-schedule.scss @@ -0,0 +1,12 @@ +@import "../variables"; + +.page-schedule { + &.ng-leave { + transform-origin: 0% 0%; + animation: rotateFall $short-duration both ease-in; + } + + &.ng-enter { + animation: scaleUp $short-duration both ease-in; + } +} \ No newline at end of file diff --git a/src/style-accessibility/components/parallax.scss b/src/style-accessibility/components/parallax.scss new file mode 100644 index 00000000..67826870 --- /dev/null +++ b/src/style-accessibility/components/parallax.scss @@ -0,0 +1,24 @@ +@import "../variables"; + +.parallax { + min-width: 1280px; + width: 1280px; + height: 1000px; + overflow: hidden; + position: relative; + + //&__container { + // + //} + + &__layer { + position: absolute; + } + + &__end { + position: absolute; + width: 100%; + background-color: white; + bottom: 0; + } +} \ No newline at end of file diff --git a/src/style-accessibility/components/schedule-table.scss b/src/style-accessibility/components/schedule-table.scss new file mode 100644 index 00000000..f99dbd20 --- /dev/null +++ b/src/style-accessibility/components/schedule-table.scss @@ -0,0 +1,132 @@ +@import "../variables"; + +$current-week-day-color: $blue-color; + +$cell-width: 9em; +$cell-tablet-width: 7.5em; + +$group-cell-width: 4em; +$group-cell-tablet-width: 3em; + +$current-week-day-color: $blue-color; +$row-padding: $single-margin 0; +$current-day-column-border-thickness: 3px; + +.schedule-table { + margin-bottom: $double-margin; + + a{ + color: $dark-color; + } + + .lesson { + font-size: 1.1em; + font-weight: bold; + } + + .teacher { + font-style: italic; + } + + .current { + border-left: $current-day-column-border-thickness solid $current-week-day-color; + border-right: $current-day-column-border-thickness solid $current-week-day-color; + } + + &__head{ + display: flex; + + .date { + margin: .5em 0 0; + font-size: 1.5em; + } + + .group { + color: #666; + } + + & > div{ + min-width: $cell-width; + text-align: center; + } + + & > .group{ + min-width: $group-cell-width; + } + } + + &__body { + display: flex; + flex-direction: column; + } + + &__body-row{ + display: flex; + justify-content: space-between; + + &:nth-child(even) { + background-color: $schedule-row-color; + } + } + + &__body-group{ + min-width: $group-cell-width; + padding: $row-padding; + + text-align: center; + + p.name { + font-size: 1.25em; + font-weight: 800; + } + } + + &__record{ + min-width: $cell-width; + padding: $row-padding; + + text-align: center; + } + + &__course{ + margin-bottom: $half-margin; + } +} + +@media screen and (min-width: $tablet-min-width) and (max-width: $tablet-max-width) { + .schedule-table { + min-width: 900px; + + .lesson { + font-size: .9em; + font-weight: normal; + } + + .teacher { + font-size: .9em; + font-weight: normal; + } + + &__head{ + & > div{ + min-width: $cell-tablet-width; + } + + & > .group{ + min-width: $group-cell-tablet-width; + } + } + + &__body-group{ + min-width: $group-cell-tablet-width; + + p.name { + font-size: 1em; + } + } + + &__record{ + min-width: $cell-tablet-width; + } + } +} diff --git a/src/style-accessibility/components/teacher-proifile.scss b/src/style-accessibility/components/teacher-proifile.scss new file mode 100644 index 00000000..54258f7d --- /dev/null +++ b/src/style-accessibility/components/teacher-proifile.scss @@ -0,0 +1,75 @@ +@import "../variables"; + +$picture-width: 30%; +$info-width: 100% - $picture-width; + +.teacher-profile { + margin: 0 auto $double-margin; + + display: flex; + justify-content: space-between; + flex-wrap: wrap; + + &__picture { + width: $picture-width; + max-width: 15em; + min-width: 12em; + + img { + width: 100%; + } + } + + &__info { + width: $info-width; + + padding-left: $single-margin; + box-sizing: border-box; + + h2 { + font-size: $big-font-size; + font-weight: 200; + text-align: left; + + strong { + font-weight: 600; + } + + //a { + // color: $dark-color; + // + // &:hover{ + // border-bottom-color: lighten($dark-color, 40%); + // } + //} + } + } + + &__position { + font-size: $bigger-font-size; + } + + &__biography { + margin-top: $double-margin; + + p { + margin-bottom: $single-margin; + } + } +} + +@media (max-width: $mobile-width) { + .teacher-profile { + margin: 0 auto $double-margin; + + &__picture { + width: 100%; + max-width: $mobile-width; + } + + &__info { + width: 100%; + padding-left: 0; + } + } +} diff --git a/src/style-accessibility/components/timeline-record-instagram.scss b/src/style-accessibility/components/timeline-record-instagram.scss new file mode 100644 index 00000000..6e0954e5 --- /dev/null +++ b/src/style-accessibility/components/timeline-record-instagram.scss @@ -0,0 +1,53 @@ +@import "../variables"; + +$user-size: 40px; +$half-margin: $single-margin/2; +$image-border-radius: .35em; +$image-border-thickness: $half-margin; + +.timeline-record-instagram { +} + +.timeline-record-instagram__head { + margin-bottom: 1.25em; + //margin-bottom: $single-margin; + + .date { + text-align: center; + color: #aaa; + } +} + +.timeline-record-instagram__body { + img { + max-width: 640px; + width: 100%; + height: auto; + box-sizing: border-box; + border: $image-border-thickness solid white; + box-shadow: $white-shadow; + border-radius: $image-border-radius; + margin: 0 auto $single-margin; + display: block; + } +} + +.timeline-record-instagram__user { + padding-top: $half-margin; + + span { + margin-left: $half-margin; + + line-height: $user-size; + vertical-align: top; + } + + img { + display: inline; + width: $user-size; + height: $user-size; + border-radius: 50%; + border: none; + box-shadow: none; + } +} \ No newline at end of file diff --git a/src/style-accessibility/components/timeline-record.scss b/src/style-accessibility/components/timeline-record.scss new file mode 100644 index 00000000..6d64a020 --- /dev/null +++ b/src/style-accessibility/components/timeline-record.scss @@ -0,0 +1,9 @@ +@import "../variables"; + +.timeline__record { + margin: 0 0 $post-margin; + + .date { + color: $light-color; + } +} diff --git a/src/style-accessibility/components/timeline.scss b/src/style-accessibility/components/timeline.scss new file mode 100644 index 00000000..f3012069 --- /dev/null +++ b/src/style-accessibility/components/timeline.scss @@ -0,0 +1,33 @@ +@import "../variables"; + +.timeline{ + display: flex; + flex-direction: column; + margin: $double-margin auto; +} + +.timeline__footer{ + display: flex; + justify-content: center; + + button.more { + position: relative; + top: -2px; + + width: 100px; + height: 40px; + border: 2px solid $dark-color; + padding: 0 10px; + background: none; + + font-size: $normal-font-size; + + &:hover { + background: gainsboro; + } + + &:active { + top: 0; + } + } +} diff --git a/src/style-accessibility/content.scss b/src/style-accessibility/content.scss new file mode 100644 index 00000000..da765cad --- /dev/null +++ b/src/style-accessibility/content.scss @@ -0,0 +1,99 @@ +@import "variables"; + +.content { + margin: 0 auto; + + &.content_full{ + width: $content-full; + } + + &.content_wide{ + width: $content-wide; + } + + &.content_semi-wide{ + width: $content-semi-wide; + } + + &.content_thin{ + width: $content-thin; + } + + &.content--padding-top--double{ + padding-top: $double-margin; + padding-bottom: $single-margin; + } + + &.content--padding-top--menu{ + padding-top: $menu-thickness + $double-margin; + padding-bottom: $single-margin; + } +} + +@media screen and (max-width: $mobile-width) { + $content-mobile: 90%; + + .content { + &.content_wide{ + width: $content-mobile; + } + + &.content_semi-wide{ + width: $content-mobile; + } + + &.content_thin{ + width: $content-mobile; + } + + &.content--padding-top--menu{ + padding-top: $double-margin; + } + } +} + +@media screen and (min-width: $tablet-min-width) and (max-width: $tablet-max-width) { + $thin-value: 70%; + $wide-value: 95%; + $semi-wide-value: 80%; + + .content { + overflow-x: scroll; + + &.content_wide { + width: $wide-value; + } + + &.content_semi-wide { + width: $semi-wide-value; + } + + &.content_thin { + width: $thin-value; + } + + &.content--padding-top--menu { + padding-top: $menu-thickness + $double-margin; + } + } + + @media screen and (orientation: portrait) { + $wide-value: 100%; + $thin-value: 80%; + $semi-wide-value: 95%; + + .content { + &.content_wide { + width: $wide-value; + } + + &.content_semi-wide { + width: $semi-wide-value; + } + + &.content_thin { + width: $thin-value; + } + } + } +} diff --git a/src/style-accessibility/error-404.scss b/src/style-accessibility/error-404.scss new file mode 100644 index 00000000..d4e9caa5 --- /dev/null +++ b/src/style-accessibility/error-404.scss @@ -0,0 +1,14 @@ +.error-404{ + text-align: center; + + h1{ + font-size: 16pt; + font-weight: normal; + } + + img{ + margin: 20px; + width: 40%; + max-width: 800px; + } +} \ No newline at end of file diff --git a/src/style-accessibility/footer.scss b/src/style-accessibility/footer.scss new file mode 100644 index 00000000..a55b7441 --- /dev/null +++ b/src/style-accessibility/footer.scss @@ -0,0 +1,58 @@ +@import "variables"; + +$uri: '/graphics/rawline.png'; + +footer { + //width: 100%; + color: $light-color; + padding: 0 $half-margin $half-margin; + position: relative; + background-color: $darker-color; + + font-size: $normal-font-size; + + a { + color: $light-color; + text-decoration: none; + border-bottom: 1px solid $light-color; + + &:hover { + border-bottom: 2px solid $light-color; + } + + &.invisible { + border-bottom: none; + } + } + + .footer-info { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + + padding: $double-margin $single-margin 0; + margin-bottom: $double-margin; + } + + .contacts { + & > div { + padding: 0 1em; + } + + p { + margin: 0.5em 1em; + } + } + + .copyright { + display: flex; + flex-wrap: wrap; + align-items: baseline; + justify-content: space-between; + + span { + padding: 1.5em 1em 0.25em; + box-sizing: padding-box; + } + } +} \ No newline at end of file diff --git a/src/style-accessibility/hudozka-title.scss b/src/style-accessibility/hudozka-title.scss new file mode 100644 index 00000000..36fbe03f --- /dev/null +++ b/src/style-accessibility/hudozka-title.scss @@ -0,0 +1,26 @@ +@import "variables"; + +.hudozka-title { + padding: $double-margin 0; + + text-align: center; + + p { + color: $dark-color; + margin-bottom: $single-margin; + font-size: $normal-font-size; + } + + h1 { + margin-top: $single-margin; + font-size: $biggest-font-size; + } +} + +@media (max-width: $mobile-width) { + .hudozka-title { + h1 { + font-size: $big-font-size; + } + } +} diff --git a/src/style-accessibility/kazimir/video.scss b/src/style-accessibility/kazimir/video.scss new file mode 100644 index 00000000..205085d9 --- /dev/null +++ b/src/style-accessibility/kazimir/video.scss @@ -0,0 +1,16 @@ +@import "../variables"; + +.kazimir-video { + width: 100%; + height: 0; + position: relative; + padding-bottom: $embed-video-ratio; + + margin-bottom: $single-margin; + + iframe { + width: 100%; + height: 100%; + position: absolute; + } +} diff --git a/src/style-accessibility/main-image.scss b/src/style-accessibility/main-image.scss new file mode 100644 index 00000000..eb6af9b4 --- /dev/null +++ b/src/style-accessibility/main-image.scss @@ -0,0 +1,24 @@ +@import "variables"; + +.main-image{ + width: 100%; + display: flex; + justify-content: center; + overflow: hidden; + + img { + width: 100%; + max-width: 1280px; + } + + &__content { + min-width: 1280px; + width: 1280px; + } +} + +@media (max-width: $mobile-width) { + .main-image { + display: none; + } +} diff --git a/src/style-accessibility/main.scss b/src/style-accessibility/main.scss new file mode 100644 index 00000000..d94eb431 --- /dev/null +++ b/src/style-accessibility/main.scss @@ -0,0 +1,61 @@ +@import "variables"; + +* { + margin: 0; + padding: 0; +} + +html, body { + height: 100%; +} + +body { + min-width: 320px; +} + +h2{ + text-align: center; + margin-bottom: $single-margin; + + //background-color: hsl(0, 0, 95%); +} + +h1, h2{ + font-family: $title-font; +} + +h3{ + margin-bottom: $single-margin / 2; + + a { + color: $dark-color; + text-decoration: none; + border-bottom: 1px solid $dark-color; + + &:hover { + border-width: 2px; + } + + //&:active { + // border-bottom: 1px solid $dark-color; + //} + } +} + +a { + color: $blue-color; + text-decoration: none; + border-bottom: 1px solid lighten($blue-color, 25%); + + &:hover { + border-bottom: 1px solid lighten($blue-color, 10%); + } + + &:active { + border-bottom: 1px solid $blue-color; + } + + &.invisible { + border-bottom: none; + } +} diff --git a/src/style-accessibility/page-animation.scss b/src/style-accessibility/page-animation.scss new file mode 100644 index 00000000..29496bad --- /dev/null +++ b/src/style-accessibility/page-animation.scss @@ -0,0 +1,56 @@ +@keyframes rotateFall { + 0% { + transform: rotateZ(0deg); + } + 20% { + transform: rotateZ(10deg); + animation-timing-function: ease-out; + } + 40% { + transform: rotateZ(17deg); + } + 60% { + transform: rotateZ(16deg); + } + 100% { + transform: translateY(100%) rotateZ(17deg); + } +} + +@keyframes scaleUp { + from { + opacity: 0.0; + transform: scale(0.5); + } +} + +@keyframes slideInRight { + from { + transform: translateX(100%); + } + to { + transform: translateX(0); + } +} + +@keyframes slideInUp { + from { + transform: translateY(100%); + } + to { + transform: translateY(0); + } +} + +@keyframes slideOutLeft { + to { + transform: translateX(-100%); + } +} + +@keyframes rotateOutNewspaper { + to { + transform: translateZ(-3000px) rotateZ(360deg); + opacity: 0; + } +} \ No newline at end of file diff --git a/src/style-accessibility/page.scss b/src/style-accessibility/page.scss new file mode 100644 index 00000000..8e2fcda6 --- /dev/null +++ b/src/style-accessibility/page.scss @@ -0,0 +1,6 @@ +.page { + width: 100%; + + &.ng-leave {} + &.ng-enter {} +} \ No newline at end of file diff --git a/src/style-accessibility/schedule-mobile.scss b/src/style-accessibility/schedule-mobile.scss new file mode 100644 index 00000000..3c18a57f --- /dev/null +++ b/src/style-accessibility/schedule-mobile.scss @@ -0,0 +1,61 @@ +.schedule-slider { + width: 100%; + max-width: 30em; + //width: 90%; + //margin: 0 auto; +} + +.schedule-slider__slide { + height: 100%; + overflow-y: auto; + + &.current { + border-left: .3em solid #4b8ff3; + border-right: .3em solid #4b8ff3; + } +} + +.schedule-slider__body { +} + +.schedule-slider__head { + text-align: center; + font-size: 2em; + margin: 0 0 .5em; +} + +.schedule-record { + min-height: 10em; + text-align: center; + + &.even{ + background-color: #f3f3fd; + } + + &.empty { + .schedule-record__head{ + color: #bbb; + } + } + + p { + margin: .2em 0; + } +} + +.schedule-record__head { + padding: .25em 0; + font-size: 1.2em; +} + +.schedule-record__main { +} + +.schedule-record__name { + font-weight: bold; + font-size: 1.2em; +} + +.schedule-record__group { + position: absolute; +} \ No newline at end of file diff --git a/src/style-accessibility/schedule-selector.scss b/src/style-accessibility/schedule-selector.scss new file mode 100644 index 00000000..777d4987 --- /dev/null +++ b/src/style-accessibility/schedule-selector.scss @@ -0,0 +1,10 @@ +@import "variables"; + +.schedule-selector { + text-align: center; + margin-bottom: $single-margin; + + label{ + margin: 0 .5em; + } +} \ No newline at end of file diff --git a/src/style-accessibility/style.scss b/src/style-accessibility/style.scss new file mode 100644 index 00000000..81d6982a --- /dev/null +++ b/src/style-accessibility/style.scss @@ -0,0 +1,39 @@ +@import "components/album-collection"; +@import "components/gallery-item"; +@import "components/document"; +@import "components/documents-container"; +@import "components/teacher-proifile"; +@import "components/main-menu"; +@import "components/navigation"; +@import "components/breadcrumbs"; +@import "components/timeline"; +@import "components/timeline-record"; +@import "components/timeline-record-instagram"; +@import "components/schedule-table"; +@import "components/footer-links"; +@import "components/cloud-page"; +@import "components/article"; +@import "components/article-page-control"; +@import "components/album"; +@import "components/parallax"; + +@import "components/page-schedule"; +@import "components/page-collective"; + +@import "main"; +@import "body-wrapper"; +@import "page"; +@import "content"; +@import "page-animation"; +@import "main-image"; +@import "hudozka-title"; +//@import "vertical-image"; + +@import "schedule-selector"; +@import "schedule-mobile"; +@import "error-404"; + +@import "tape-viewer"; +@import "footer"; + +@import "kazimir/video"; diff --git a/src/style-accessibility/tape-viewer.scss b/src/style-accessibility/tape-viewer.scss new file mode 100644 index 00000000..f1b1dc11 --- /dev/null +++ b/src/style-accessibility/tape-viewer.scss @@ -0,0 +1,88 @@ +.tape-block{ + max-width: 1000px; + + margin: 2em auto; + + &.simplified{ + .tape{ + display: none; + } + } +} + +.tape-block__body{ + position: relative; + width: 100%; + + .tape { + width: 98px; + height: 98px; + position: absolute; + z-index: 10; + } + + .tape-tl { + top: -25px; + left: -25px; + background-image: url(/graphics/tape-tl.png); + } + + .tape-tr { + top: -25px; + right: -25px; + background-image: url(/graphics/tape-tr.png); + } + + .tape-bl { + bottom: 0; + left: -25px; + background-image: url(/graphics/tape-lb.png); + } + + .tape-br { + bottom: 0; + right: -25px; + background-image: url(/graphics/tape-rb.png); + } +} + +@media screen and (max-device-width: 31.25em) { + .tape-block { + width: 90%; + margin: 1.5em auto; + } + + .tape-block__body { + .tape { + width: 62px; + height: 62px; + position: absolute; + z-index: 10; + } + + .tape-tl { + top: -20px; + left: -20px; + background-image: url(/graphics/m-tape-tl.png); + background-size: 100%; + } + + .tape-tr { + top: -20px; + right: -20px; + background-image: url(/graphics/m-tape-tr.png); + } + + .tape-bl { + bottom: 10px; + left: -20px; + background-image: url(/graphics/m-tape-bl.png); + } + + .tape-br { + bottom: 10px; + right: -20px; + background-image: url(/graphics/m-tape-br.png); + } + } +} \ No newline at end of file diff --git a/src/style-accessibility/variables.scss b/src/style-accessibility/variables.scss new file mode 100644 index 00000000..d8a82bdc --- /dev/null +++ b/src/style-accessibility/variables.scss @@ -0,0 +1,73 @@ +//SIZE +$mobile-width: 31.25em; +$desktop-width: 59.99999em; + +$tablet-min-width: 31.25em; +$tablet-max-width: 64em; + +$content-full: 100%; +$content-wide: 80%; +$content-semi-wide: 70%; +$content-thin: 60%; + +$embed-video-ratio: 56.25%; + +//MARGINS +$small-margin: .2em; +$half-margin: .5em; +$single-margin: 1.0em; +$double-margin: 2.0em; +$post-margin: 5.0em; + +//COLOR +$dark-color: #1a1a1a; +$darker-color: #1a1a1a; +$light-color: #fff; +$lighter-color: #fff; + +$blue-color: $dark-color; +$orange-color: $dark-color; +$green-color: $dark-color; +$yellow-color: $dark-color; +$pink-color: $dark-color; +$magenta-color: $dark-color; +$red-color: $dark-color; +$gray-color: $dark-color; + +$link-color: $blue-color; +$inactive-link-color: $light-color; + +$schedule-row-color: #fff; + +//SHADOW +$white-shadow: 0 .1em 0.3em rgba(0, 0, 0, 0.2); + +//FONTS +$title-font: "PT Serif", Georgia, serif; +$text-font: "PT Sans", Arial, sans-serif; + +$default-font-size: 14pt; +$smaller-font-size: 0.9rem; +$normal-font-size: 1.0rem; +$bigger-font-size: 1.2rem; +$big-font-size: 1.5rem; +$biggest-font-size: 3rem; + +//MENU +$menu-thickness: 2.5em; +$menu-colored-mark-thickness: 4px; +$menu-inactive-item-color: $dark-color; + +//ANIMATION +$short-duration: 0.3s; + + +@media (max-width: $mobile-width) { + //FONTS + $default-font-size: 14pt; + $smaller-font-size: 0.9rem; + $normal-font-size: 1.0rem; + $bigger-font-size: 1.1rem; + $big-font-size: 1.3rem; + $biggest-font-size: 2.0rem; +} diff --git a/src/style-accessibility/vertical-image.scss b/src/style-accessibility/vertical-image.scss new file mode 100644 index 00000000..98c2f10b --- /dev/null +++ b/src/style-accessibility/vertical-image.scss @@ -0,0 +1,28 @@ +@import "variables"; + +.vertical-image { + position: relative; + width: 100%; + overflow: hidden; + + & > img { + position: relative; + z-index: 1; + width: 100%; + display: block; + margin: 0 auto; + } + + &__back { + position: absolute; + filter: blur(15px) grayscale(0) opacity(.75); + + top: -50%; + + & > img { + width: 105%; + display: block; + margin: 0 auto; + } + } +} \ No newline at end of file From e3b95a68e648c89f9e5bd749490d0f4b8214fc5d Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 22 Jan 2017 06:45:11 +0300 Subject: [PATCH 028/368] AppController eslinted --- src/client/controllers/AppController.js | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/client/controllers/AppController.js b/src/client/controllers/AppController.js index d6f5e2ce..e5dae7c0 100644 --- a/src/client/controllers/AppController.js +++ b/src/client/controllers/AppController.js @@ -1,19 +1,19 @@ -import {footer, mobileMatchSelector, contacts} from '../config'; +import {footer, mobileMatchSelector, contacts} from '../config' export default function (app) { - app.controller('AppController', ($scope, menu) => { - try { - if (window.matchMedia(mobileMatchSelector).matches) { - $scope.navigation = 'navigation'; - }else{ - $scope.navigation = 'main-menu'; - } - } catch (e) { - $scope.navigation = 'main-menu'; - } + app.controller('AppController', ($scope, menu) => { + try { + if (window.matchMedia(mobileMatchSelector).matches) { + $scope.navigation = 'navigation' + } else { + $scope.navigation = 'main-menu' + } + } catch (e) { + $scope.navigation = 'main-menu' + } - $scope.phone = contacts.telephone; - $scope.menuProvider = menu.items; - $scope.footer = footer; - }); + $scope.phone = contacts.telephone + $scope.menuProvider = menu.items + $scope.footer = footer + }) }; From 17de1d0fac358744d402a9affd8fedc4ecb43f87 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 22 Jan 2017 06:50:14 +0300 Subject: [PATCH 029/368] App eslinted --- src/client/app.js | 160 +++++++++++++++++++++++----------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/src/client/app.js b/src/client/app.js index 6412f4c8..a5d3476b 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -1,67 +1,67 @@ -import {getInitialData} from './core/init'; -import Navigation from './components/Navigation'; -import MainMenu from './components/MainMenu'; -import Breadcrumbs from './components/Breadcrumbs'; -import Document from './components/Document'; -import Award from './components/Award'; -import GalleryItem from './components/GalleryItem'; -import AlbumCollection from './components/AlbumCollection'; -import TeacherProfile from './components/TeacherProfile'; -import Timeline from './components/Timeline'; -import TimelineRecord from './components/TimelineRecord'; -import TimelineRecordInstagram from './components/TimelineRecordInstagram'; -import Schedule from './components/Schedule'; -import ScheduleTable from './components/ScheduleTable'; -import ScheduleSlider from './components/ScheduleSlider'; -import ScheduleSlide from './components/ScheduleSlide'; -import ScheduleRecord from './components/ScheduleRecord'; -import FooterLinks from './components/FooterLinks'; -import Article from './components/Article'; -import ArticlePageControl from './components/ArticlePageControl'; -import Album from './components/Album'; -import Parallax from './components/Parallax'; +import {getInitialData} from './core/init' +import Navigation from './components/Navigation' +import MainMenu from './components/MainMenu' +import Breadcrumbs from './components/Breadcrumbs' +import Document from './components/Document' +import Award from './components/Award' +import GalleryItem from './components/GalleryItem' +import AlbumCollection from './components/AlbumCollection' +import TeacherProfile from './components/TeacherProfile' +import Timeline from './components/Timeline' +import TimelineRecord from './components/TimelineRecord' +import TimelineRecordInstagram from './components/TimelineRecordInstagram' +import Schedule from './components/Schedule' +import ScheduleTable from './components/ScheduleTable' +import ScheduleSlider from './components/ScheduleSlider' +import ScheduleSlide from './components/ScheduleSlide' +import ScheduleRecord from './components/ScheduleRecord' +import FooterLinks from './components/FooterLinks' +import Article from './components/Article' +import ArticlePageControl from './components/ArticlePageControl' +import Album from './components/Album' +import Parallax from './components/Parallax' -import Page from './components/CloudPage'; -import PageSchool from './components/PageSchool'; -import PageEvents from './components/PageEvents'; -import PageArticle from './components/PageArticle'; -import PageSchedule from './components/PageSchedule'; -import PageCollective from './components/PageCollective'; -import PageTeacher from './components/PageTeacher'; -import PageGallery from './components/PageGallery'; -import PageAlbum from './components/PageAlbum'; -import PageDocuments from './components/PageDocuments'; -import PageDocument from './components/PageDocument'; +import Page from './components/CloudPage' +import PageSchool from './components/PageSchool' +import PageEvents from './components/PageEvents' +import PageArticle from './components/PageArticle' +import PageSchedule from './components/PageSchedule' +import PageCollective from './components/PageCollective' +import PageTeacher from './components/PageTeacher' +import PageGallery from './components/PageGallery' +import PageAlbum from './components/PageAlbum' +import PageDocuments from './components/PageDocuments' +import PageDocument from './components/PageDocument' -import AppController from './controllers/AppController'; -import CopyrightController from './controllers/CopyrightController'; -import ContactsController from './controllers/ContactsController'; +import AppController from './controllers/AppController' +import CopyrightController from './controllers/CopyrightController' +import ContactsController from './controllers/ContactsController' -import RemoveHashtags from './filters/RemoveHashtags'; -import RemoveNewline from './filters/RemoveNewline'; -import Strip from './filters/Strip'; -import Join from './filters/Join'; -import UppercaseFirst from './filters/UppercaseFirst'; -import Bytes from './filters/Bytes'; -import Ext from './filters/Ext'; +import RemoveHashtags from './filters/RemoveHashtags' +import RemoveNewline from './filters/RemoveNewline' +import Strip from './filters/Strip' +import Join from './filters/Join' +import UppercaseFirst from './filters/UppercaseFirst' +import Bytes from './filters/Bytes' +import Ext from './filters/Ext' -import IOService from './services/io'; -import MenuService from './services/menu'; -import API from './services/api'; +import IOService from './services/io' +import MenuService from './services/menu' +import API from './services/api' -import {sortByPattern} from '../utils/sort'; -import {documentsSortPattern, collectiveSortPattern} from './config'; +import {sortByPattern} from '../utils/sort' +import {documentsSortPattern, collectiveSortPattern} from './config' let app = angular.module('hudozka', [ 'ngRoute', 'angulartics', 'angulartics.google.analytics', 'angularSpinner' -]); +]) app.config(($locationProvider, $routeProvider) => { - $locationProvider.hashPrefix('!'); - $locationProvider.html5Mode(true); + $locationProvider.hashPrefix('!') + $locationProvider.html5Mode(true) const pages = getInitialData().pages .map(i => i.url) @@ -76,7 +76,7 @@ app.config(($locationProvider, $routeProvider) => { .then(i => i.data) } } - })); + })) let routers = [ { @@ -91,20 +91,20 @@ app.config(($locationProvider, $routeProvider) => { resolveAs: '$', resolve: { page: ($route, api) => { - let page = $route.current.params.page; - if (!page) page = 1; + let page = $route.current.params.page + if (!page) page = 1 return api.event .list(page) .then(i => i.data) .then(i => { - let totalPages = Math.ceil(i.total / i.limit); + let totalPages = Math.ceil(i.total / i.limit) return { data: i.data, page: page, totalPages: totalPages } - }); + }) } } }, @@ -114,8 +114,8 @@ app.config(($locationProvider, $routeProvider) => { resolveAs: '$', resolve: { data: ($route, api) => { - let id = $route.current.params.id; - if (!id) return null; + let id = $route.current.params.id + if (!id) return null return api.article.id(id) .then(i => i.data) } @@ -147,10 +147,10 @@ app.config(($locationProvider, $routeProvider) => { title: 'Преподаватели', resolve: { profile: ($route, api) => { - let id = $route.current.params.id; + let id = $route.current.params.id return api.teacher .fetch(id) - .then(i => i.data); + .then(i => i.data) } } }, @@ -169,7 +169,7 @@ app.config(($locationProvider, $routeProvider) => { template: '', resolve: { album: ($route, api) => { - let id = $route.current.params.id; + let id = $route.current.params.id return api.album .fetch(id) @@ -190,7 +190,7 @@ app.config(($locationProvider, $routeProvider) => { .documents() .then(i => i.data) .then(i => { - return sortByPattern(i, documentsSortPattern, i => i.category); + return sortByPattern(i, documentsSortPattern, i => i.category) }) } }, @@ -199,7 +199,7 @@ app.config(($locationProvider, $routeProvider) => { template: '', resolve: { document: ($route, api) => { - let id = $route.current.params.id; + let id = $route.current.params.id return api.document .id(id) @@ -210,50 +210,50 @@ app.config(($locationProvider, $routeProvider) => { ] .concat(pages) .map(i => { - let path = i.name; - delete i.name; + let path = i.name + delete i.name return { path: path, route: i } - }); + }) routers.forEach(i => { - $routeProvider.when(i.path, i.route); - }); + $routeProvider.when(i.path, i.route) + }) $routeProvider.otherwise({ templateUrl: '/404.html' - }); -}); + }) +}) app.run(($location, $rootScope, $http) => { $rootScope.$on('$routeChangeSuccess', (event, current) => { - const url = location.href; - const title = current['$$route'].title; + const url = location.href + const title = current['$$route'].title - if (title) $rootScope.title = title; + if (title) $rootScope.title = title setTimeout(() => { try { DISQUS.reset({ reload: true, config: function () { - this.page.identifier = url; - this.page.url = url; + this.page.identifier = url + this.page.url = url } - }); + }) } catch (e) { } }, 500) - }); + }) $rootScope.$on('$routeChangeError', (event, current) => { // let title = current['$$route'].title; // if (title) $rootScope.title = title; - }); + }) - $http.defaults.headers.common['Accept'] = 'application/json'; + $http.defaults.headers.common['Accept'] = 'application/json' }); [ @@ -302,4 +302,4 @@ app.run(($location, $rootScope, $http) => { ScheduleSlide, ScheduleRecord, FooterLinks -].map(i => i(app)); +].map(i => i(app)) From 37d85879d37c0f5f93e0e80770a61909a4c4ffd9 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 22 Jan 2017 07:33:53 +0300 Subject: [PATCH 030/368] server eslinted --- src/server.js | 86 +++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/server.js b/src/server.js index 255a0cca..232c5c19 100644 --- a/src/server.js +++ b/src/server.js @@ -1,67 +1,67 @@ -import path from 'path'; -import {Server} from 'http'; -import Koa from 'koa'; -import serve from 'koa-static'; -import logger from 'koa-logger'; -import convert from 'koa-convert'; -import conditional from 'koa-conditional-get'; -import etag from 'koa-etag'; -import prerender from 'koa-prerender'; -import helmet from 'koa-helmet'; -import mount from 'koa-mount'; -import bodyParser from 'koa-bodyparser'; +import path from 'path' +import {Server} from 'http' +import Koa from 'koa' +import serve from 'koa-static' +import logger from 'koa-logger' +import convert from 'koa-convert' +import conditional from 'koa-conditional-get' +import etag from 'koa-etag' +import prerender from 'koa-prerender' +import helmet from 'koa-helmet' +import mount from 'koa-mount' +import bodyParser from 'koa-bodyparser' -import apiV1 from 'hudozka-api-v1'; -import config, {redirectionTable} from './config'; -import {routes, queryObject} from './routes'; -import {redirect} from './routes/redirect'; -import {services as serviceKeys, authChecker} from './core/service'; -import handlebars from 'handlebars'; +import apiV1 from 'hudozka-api-v1' +import config, {redirectionTable} from './config' +import {routes, queryObject} from './routes' +import {redirect} from './routes/redirect' +import {services as serviceKeys, authChecker} from './core/service' +import handlebars from 'handlebars' -const dirPublic = path.join(__dirname, '../public'); -const dirTemplates = path.join(__dirname, 'templates'); +const dirPublic = path.join(__dirname, '../public') +const dirTemplates = path.join(__dirname, 'templates') -handlebars.registerHelper('raw-helper', options => options.fn()); +handlebars.registerHelper('raw-helper', options => options.fn()) export default function (store) { - const $ = convert; + const $ = convert - const app = new Koa(); - app.proxy = true; + const app = new Koa() + app.proxy = true app.use(bodyParser({ extendTypes: { json: 'application/ejson' } - })); - app.use(logger()); - app.use(apis(store)); - app.use($(conditional())); - app.use($(etag())); - app.use(prerenderRmFragment()); - app.use($(prerender(config.prerender))); - app.use(serve(dirPublic)); - app.use(serve(dirTemplates)); - app.use($(redirect(redirectionTable))); - app.use($(helmet())); - app.use(queryObject()); - app.use(routes(store)); + })) + app.use(logger()) + app.use(apis(store)) + app.use($(conditional())) + app.use($(etag())) + app.use(prerenderRmFragment()) + app.use($(prerender(config.prerender))) + app.use(serve(dirPublic)) + app.use(serve(dirTemplates)) + app.use($(redirect(redirectionTable))) + app.use($(helmet())) + app.use(queryObject()) + app.use(routes(store)) - return Server(app.callback()); + return Server(app.callback()) } function apis(store) { - let checkAuth = authChecker(serviceKeys); - return mount('/api/v1', apiV1(checkAuth, store)); + let checkAuth = authChecker(serviceKeys) + return mount('/api/v1', apiV1(checkAuth, store)) } function prerenderRmFragment() { return async(ctx, next) => { - await next(); + await next() try { - let xp = ctx.response.header['x-prerender'] === 'true'; - if (xp) ctx.body = ctx.body.replace('', ''); + let xp = ctx.response.header['x-prerender'] === 'true' + if (xp) ctx.body = ctx.body.replace('', '') } catch (e) { } } From 178d3c795597ee2205bba3fa2e6cf9d837943de8 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 22 Jan 2017 08:07:41 +0300 Subject: [PATCH 031/368] Navigator eslinterd --- src/client/components/Navigation.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/components/Navigation.js b/src/client/components/Navigation.js index 44761980..5a0f0a5e 100644 --- a/src/client/components/Navigation.js +++ b/src/client/components/Navigation.js @@ -1,12 +1,12 @@ -import template from '../../templates/components/navigation.html'; +import template from '../../templates/components/navigation.html' export default function (app) { - app.component('navigation', { - bindings: { - menu: '<', - rightText: '@' - }, - template: template, - controllerAs: '$' - }); -}; \ No newline at end of file + app.component('navigation', { + bindings: { + menu: '<', + rightText: '@' + }, + template: template, + controllerAs: '$' + }) +}; From 13726d88b07e2f882a7847405b721418446c7bf7 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 22 Jan 2017 08:30:43 +0300 Subject: [PATCH 032/368] theme enabled --- src/client/app.js | 6 ++++- src/client/components/ThemeSelector.js | 22 ++++++++++++++++ src/client/services/theme.js | 32 ++++++++++++++++++++++++ src/style/components/navigation.scss | 2 +- src/style/variables.scss | 2 +- src/templates/components/navigation.html | 2 +- src/templates/main.html | 14 ++++++++--- 7 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 src/client/components/ThemeSelector.js create mode 100644 src/client/services/theme.js diff --git a/src/client/app.js b/src/client/app.js index a5d3476b..9d1f82be 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -20,6 +20,7 @@ import Article from './components/Article' import ArticlePageControl from './components/ArticlePageControl' import Album from './components/Album' import Parallax from './components/Parallax' +import ThemeSelector from './components/ThemeSelector' import Page from './components/CloudPage' import PageSchool from './components/PageSchool' @@ -48,6 +49,7 @@ import Ext from './filters/Ext' import IOService from './services/io' import MenuService from './services/menu' import API from './services/api' +import Theme from './services/theme' import {sortByPattern} from '../utils/sort' import {documentsSortPattern, collectiveSortPattern} from './config' @@ -260,6 +262,7 @@ app.run(($location, $rootScope, $http) => { API, IOService, MenuService, + Theme, RemoveHashtags, RemoveNewline, Strip, @@ -301,5 +304,6 @@ app.run(($location, $rootScope, $http) => { ScheduleSlider, ScheduleSlide, ScheduleRecord, - FooterLinks + FooterLinks, + ThemeSelector ].map(i => i(app)) diff --git a/src/client/components/ThemeSelector.js b/src/client/components/ThemeSelector.js new file mode 100644 index 00000000..375c4950 --- /dev/null +++ b/src/client/components/ThemeSelector.js @@ -0,0 +1,22 @@ +export default function (app) { + app.component('themeSelector', { + template: ` +

+ + +

+ `, + controller: ($scope, theme) => { + const update = () => { + $scope.isMainTheme = theme.currentTheme === theme.mainTheme + } + + $scope.toggleTheme = () => { + theme.toggle() + update() + } + + update() + }, + }) +}; diff --git a/src/client/services/theme.js b/src/client/services/theme.js new file mode 100644 index 00000000..c3b80004 --- /dev/null +++ b/src/client/services/theme.js @@ -0,0 +1,32 @@ +const themes = { + main: 'style.css', + accessibility: 'style-accessibility.css', +} + +const defaultTheme = 'main' + +class Theme { + constructor($rootScope) { + this.mainTheme = defaultTheme + this.currentTheme = null + + const getTheme = value => themes[value] + const setTheme = value => { + const theme = value in themes ? value : defaultTheme + localStorage.setItem('theme', theme) + this.currentTheme = theme + $rootScope.theme = getTheme(theme) + } + + setTheme(localStorage.getItem('theme')) + + this.toggle = () => { + const t = this.currentTheme === 'main' ? 'accessibility' : 'main' + setTheme(t) + } + } +} + +export default function (app) { + app.service('theme', Theme) +} diff --git a/src/style/components/navigation.scss b/src/style/components/navigation.scss index 246b9354..28845560 100644 --- a/src/style/components/navigation.scss +++ b/src/style/components/navigation.scss @@ -19,7 +19,7 @@ .navigation__right { color: $dark-color; - font-size: $smaller-font-size; + font-size: $normal-font-size; margin-right: 1em; z-index: 1000; diff --git a/src/style/variables.scss b/src/style/variables.scss index c2a293e8..4971234c 100644 --- a/src/style/variables.scss +++ b/src/style/variables.scss @@ -55,7 +55,7 @@ $biggest-font-size: 2.5rem; //MENU $menu-thickness: 2.5em; -$menu-colored-mark-thickness: 2px; +$menu-colored-mark-thickness: 4px; $menu-inactive-item-color: hsl(0, 0%, 50%); //ANIMATION diff --git a/src/templates/components/navigation.html b/src/templates/components/navigation.html index f596953e..83507cfa 100644 --- a/src/templates/components/navigation.html +++ b/src/templates/components/navigation.html @@ -2,6 +2,6 @@
diff --git a/src/templates/main.html b/src/templates/main.html index 50949e26..a77517f8 100644 --- a/src/templates/main.html +++ b/src/templates/main.html @@ -1,5 +1,6 @@ + @@ -9,6 +10,8 @@ + {{{{raw-helper}}}} + Шлиссельбургская Детская Художественная Школа @@ -18,17 +21,22 @@ - + + + - + + + - + {{{{/raw-helper}}}} + {{{{/raw-helper}}}} From ba102fc9fc2c281ae6e9a42cbccd001d54c85242 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Mon, 20 Feb 2017 02:31:44 +0300 Subject: [PATCH 042/368] menu eslinted --- src/models/menu.js | 92 +++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/models/menu.js b/src/models/menu.js index 42407d5a..854a6277 100644 --- a/src/models/menu.js +++ b/src/models/menu.js @@ -1,47 +1,47 @@ export default [ - { - "text": "Школа", - "url": "/", - "color": "blue" - }, - { - "text": "События", - "url": "/events", - "color": "orange" - }, - { - "text": "Расписание", - "url": "/schedule", - "color": "green" - }, - { - "text": "Предметы", - "url": "/courses", - "color": "magenta" - }, - { - "text": "Коллектив", - "url": "/collective", - "color": "pink" - }, - { - "text": "Галерея", - "url": "/gallery", - "color": "red" - }, - { - "text": "Награды", - "url": "/awards", - "color": "yellow" - }, - { - "text": "Документы", - "url": "/documents", - "color": "yellow" - }, - { - "text": "Сведения об образовательной организации", - "url": "/info", - "color": "gray" - } -]; + { + 'text': 'Школа', + 'url': '/', + 'color': 'blue' + }, + { + 'text': 'События', + 'url': '/events', + 'color': 'orange' + }, + { + 'text': 'Расписание', + 'url': '/schedule', + 'color': 'green' + }, + { + 'text': 'Предметы', + 'url': '/courses', + 'color': 'magenta' + }, + { + 'text': 'Коллектив', + 'url': '/collective', + 'color': 'pink' + }, + { + 'text': 'Галерея', + 'url': '/gallery', + 'color': 'red' + }, + { + 'text': 'Награды', + 'url': '/awards', + 'color': 'yellow' + }, + { + 'text': 'Документы', + 'url': '/documents', + 'color': 'yellow' + }, + { + 'text': 'Сведения об образовательной организации', + 'url': '/info', + 'color': 'gray' + } +] From 969cabb5600ed1ac7de5e612b64ce5f428765f4f Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Mon, 20 Feb 2017 05:15:28 +0300 Subject: [PATCH 043/368] Accessibility update --- src/client/components/AccessibilityControl.js | 39 ++++++++--- src/client/services/theme.js | 50 +++++++++----- .../components/accessibility-control.scss | 8 ++- src/style/main.scss | 20 ------ src/style/style.scss | 7 +- ...s => theme-accessibility-black-white.scss} | 4 +- .../themes/theme-accessibility-font-big.scss | 13 ++++ .../theme-accessibility-font-biggest.scss | 13 ++++ .../themes/theme-accessibility-font-sans.scss | 5 ++ .../theme-accessibility-font-serif.scss | 5 ++ .../theme-accessibility-white-black.scss | 68 +++++++++++++++++++ src/style/themes/theme-default.scss | 4 ++ .../components/accessibility-control.html | 57 +++++++++++++++- 13 files changed, 237 insertions(+), 56 deletions(-) rename src/style/themes/{theme-accessibility-bw.scss => theme-accessibility-black-white.scss} (95%) create mode 100644 src/style/themes/theme-accessibility-font-big.scss create mode 100644 src/style/themes/theme-accessibility-font-biggest.scss create mode 100644 src/style/themes/theme-accessibility-font-sans.scss create mode 100644 src/style/themes/theme-accessibility-font-serif.scss create mode 100644 src/style/themes/theme-accessibility-white-black.scss diff --git a/src/client/components/AccessibilityControl.js b/src/client/components/AccessibilityControl.js index 29ac3e2f..787eb86b 100644 --- a/src/client/components/AccessibilityControl.js +++ b/src/client/components/AccessibilityControl.js @@ -4,16 +4,35 @@ export default function (app) { app.component('accessibilityControl', { template, controller: ($scope, theme) => { - //const update = () => { - // $scope.isMainTheme = theme.currentTheme === theme.mainTheme - //} - // - //$scope.toggleTheme = () => { - // theme.toggle() - // update() - //} - // - //update() + const themeSet = { + accessibility: 'accessibility', + color: '', + fontSize: '', + fontFamily: '', + } + + const install = () => { + const baked = Object + .values(themeSet) + .filter(Boolean) + .join(' ') + theme.setTheme(baked) + } + + $scope.setColorTheme = (color) => { + themeSet.color = color + install() + } + + $scope.setFontTheme = (font) => { + themeSet.fontSize = font + install() + } + + $scope.setFontFamilyTheme = (font) => { + themeSet.fontFamily = font + install() + } }, }) } diff --git a/src/client/services/theme.js b/src/client/services/theme.js index 2ce8d776..27c5e7cc 100644 --- a/src/client/services/theme.js +++ b/src/client/services/theme.js @@ -1,29 +1,43 @@ -const themes = { - main: 'theme-default', - accessibility: 'accessibility theme-accessibility-bw', -} +const defaultTheme = 'theme-default' +const defaultAccessibilityTheme = 'accessibility theme-accessibility-black-white' -const defaultTheme = 'main' +const getTheme = () => localStorage.getItem('theme') + +const isDefaultTheme = () => { + const theme = getTheme() + if (!theme) return true + return theme === defaultTheme +} class Theme { constructor($rootScope) { this.mainTheme = defaultTheme - this.currentTheme = null - - const getTheme = value => themes[value] - const setTheme = value => { - const theme = value in themes ? value : defaultTheme - localStorage.setItem('theme', theme) - this.currentTheme = theme - $rootScope.theme = getTheme(theme) - } - - setTheme(localStorage.getItem('theme')) + this.currentTheme = defaultAccessibilityTheme this.toggle = () => { - const t = this.currentTheme === 'main' ? 'accessibility' : 'main' - setTheme(t) + if (isDefaultTheme()) { + this.setTheme(this.currentTheme) + } else { + this.setMainTheme() + } } + + this.setTheme = (themeName) => { + if (!themeName) { + this.setMainTheme() + } else { + localStorage.setItem('theme', themeName) + this.currentTheme = themeName + $rootScope.theme = themeName + } + } + + this.setMainTheme = () => { + localStorage.removeItem('theme') + $rootScope.theme = this.mainTheme + } + + this.setTheme(getTheme()) } } diff --git a/src/style/components/accessibility-control.scss b/src/style/components/accessibility-control.scss index 97697756..684049b2 100644 --- a/src/style/components/accessibility-control.scss +++ b/src/style/components/accessibility-control.scss @@ -1,9 +1,11 @@ @import "../variables"; .accessibility-control{ - //display: none; - - background-color: gold; + background-color: white; height: 100px; width: 100%; + + ul li { + display: inline; + } } diff --git a/src/style/main.scss b/src/style/main.scss index df6a9284..15ecc6f2 100644 --- a/src/style/main.scss +++ b/src/style/main.scss @@ -16,28 +16,8 @@ body { h2{ text-align: center; margin-bottom: $single-margin; - - //background-color: hsl(0, 0, 95%); -} - -h1, h2{ - font-family: $title-font; } h3{ margin-bottom: $single-margin / 2; - - //a { - // color: $dark-color; - // text-decoration: none; - // border-bottom: 1px solid lighten($dark-color, 10%); - // - // &:hover { - // border-bottom: 1px solid lighten($dark-color, 25%); - // } - // - // &:active { - // border-bottom: 1px solid $dark-color; - // } - //} } diff --git a/src/style/style.scss b/src/style/style.scss index 47c89f16..43d8d847 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -42,4 +42,9 @@ // THEMES @import "themes/theme-default"; -@import "themes/theme-accessibility-bw"; \ No newline at end of file +@import "themes/theme-accessibility-black-white"; +@import "themes/theme-accessibility-white-black"; +@import "themes/theme-accessibility-font-big"; +@import "themes/theme-accessibility-font-biggest"; +@import "themes/theme-accessibility-font-sans"; +@import "themes/theme-accessibility-font-serif"; diff --git a/src/style/themes/theme-accessibility-bw.scss b/src/style/themes/theme-accessibility-black-white.scss similarity index 95% rename from src/style/themes/theme-accessibility-bw.scss rename to src/style/themes/theme-accessibility-black-white.scss index 6c0d7255..47813728 100644 --- a/src/style/themes/theme-accessibility-bw.scss +++ b/src/style/themes/theme-accessibility-black-white.scss @@ -1,6 +1,6 @@ @import "../variables"; -.theme-accessibility-bw { +.theme-accessibility-black-white { background-color: $darker-color; color: $lighter-color; @@ -23,9 +23,7 @@ border-width: 2px; } } - } - .main-menu { .selected { border-top: $menu-colored-mark-thickness solid $dark-color; diff --git a/src/style/themes/theme-accessibility-font-big.scss b/src/style/themes/theme-accessibility-font-big.scss new file mode 100644 index 00000000..f3a86e08 --- /dev/null +++ b/src/style/themes/theme-accessibility-font-big.scss @@ -0,0 +1,13 @@ +@import "../variables"; + +.theme-accessibility-font-big { + font-size: 18pt; + + .main-menu { + font-size: $bigger-font-size; + } + + footer { + font-size: $bigger-font-size; + } +} diff --git a/src/style/themes/theme-accessibility-font-biggest.scss b/src/style/themes/theme-accessibility-font-biggest.scss new file mode 100644 index 00000000..ccf7c583 --- /dev/null +++ b/src/style/themes/theme-accessibility-font-biggest.scss @@ -0,0 +1,13 @@ +@import "../variables"; + +.theme-accessibility-font-biggest { + font-size: 24pt; + + .main-menu { + font-size: $bigger-font-size; + } + + footer { + font-size: $bigger-font-size; + } +} diff --git a/src/style/themes/theme-accessibility-font-sans.scss b/src/style/themes/theme-accessibility-font-sans.scss new file mode 100644 index 00000000..27a9c9a3 --- /dev/null +++ b/src/style/themes/theme-accessibility-font-sans.scss @@ -0,0 +1,5 @@ +@import "../variables"; + +.theme-accessibility-font-sans { + font-family: sans-serif; +} diff --git a/src/style/themes/theme-accessibility-font-serif.scss b/src/style/themes/theme-accessibility-font-serif.scss new file mode 100644 index 00000000..a5fa83bd --- /dev/null +++ b/src/style/themes/theme-accessibility-font-serif.scss @@ -0,0 +1,5 @@ +@import "../variables"; + +.theme-accessibility-font-serif { + font-family: serif; +} diff --git a/src/style/themes/theme-accessibility-white-black.scss b/src/style/themes/theme-accessibility-white-black.scss new file mode 100644 index 00000000..f9dc41a8 --- /dev/null +++ b/src/style/themes/theme-accessibility-white-black.scss @@ -0,0 +1,68 @@ +@import "../variables"; + +.theme-accessibility-white-black { + background-color: $lighter-color; + color: $darker-color; + + a { + color: $darker-color; + text-decoration: none; + border-bottom: 1px solid $darker-color; + + &:hover { + border-width: 2px; + } + } + + .main-menu { + a { + color: $darker-color; + border-bottom: 1px solid $darker-color; + + &:hover { + border-width: 2px; + } + } + + .selected { + border-top: $menu-colored-mark-thickness solid $darker-color; + + a:link, a:visited { + color: $darker-color; + } + } + + } + + .content { + &.content--padding-top--menu { + padding-top: $menu-thickness + $double-margin + 5em; + padding-bottom: $single-margin; + } + } + + .navigation { + background-color: $lighter-color; + } + + .parallax { + &__end { + background-color: $lighter-color; + } + } + + .article { + &__head { + .date { + color: $darker-color; + } + } + } + + footer { + color: $darker-color; + background-color: $lighter-color; + + font-size: $normal-font-size; + } +} diff --git a/src/style/themes/theme-default.scss b/src/style/themes/theme-default.scss index 5325c279..9adf41c5 100644 --- a/src/style/themes/theme-default.scss +++ b/src/style/themes/theme-default.scss @@ -1,6 +1,10 @@ @import "../variables"; .theme-default { + h1, h2{ + font-family: $title-font; + } + a { color: $dark-color; diff --git a/src/templates/components/accessibility-control.html b/src/templates/components/accessibility-control.html index c55fdbb8..a3dc37b2 100644 --- a/src/templates/components/accessibility-control.html +++ b/src/templates/components/accessibility-control.html @@ -1,3 +1,58 @@
- +
    +
  • + +
  • +
  • + +
  • + + + + + + + + + + + + + +
+ +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+ +
    +
  • + +
  • +
  • + +
  • +
\ No newline at end of file From 369845f601ad4208b9266adfd9fc231f9a7a4b62 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 21 Feb 2017 00:53:29 +0300 Subject: [PATCH 044/368] themes udpated --- src/style/components/teacher-proifile.scss | 8 -------- src/style/components/timeline.scss | 5 ++++- .../themes/theme-accessibility-black-white.scss | 4 ++-- .../themes/theme-accessibility-font-biggest.scss | 12 +++++++++--- .../themes/theme-accessibility-white-black.scss | 4 ++-- src/style/themes/theme-default.scss | 10 +++++++--- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/style/components/teacher-proifile.scss b/src/style/components/teacher-proifile.scss index f1c942fe..a854ecc9 100644 --- a/src/style/components/teacher-proifile.scss +++ b/src/style/components/teacher-proifile.scss @@ -34,14 +34,6 @@ $info-width: 100% - $picture-width; strong { font-weight: 600; } - - a { - color: $dark-color; - - &:hover{ - border-bottom-color: lighten($dark-color, 40%); - } - } } } diff --git a/src/style/components/timeline.scss b/src/style/components/timeline.scss index f3012069..9bf636c9 100644 --- a/src/style/components/timeline.scss +++ b/src/style/components/timeline.scss @@ -11,6 +11,8 @@ justify-content: center; button.more { + cursor: hand; + position: relative; top: -2px; @@ -18,7 +20,8 @@ height: 40px; border: 2px solid $dark-color; padding: 0 10px; - background: none; + color: $dark-color; + background: $lighter-color; font-size: $normal-font-size; diff --git a/src/style/themes/theme-accessibility-black-white.scss b/src/style/themes/theme-accessibility-black-white.scss index 47813728..ea7e582d 100644 --- a/src/style/themes/theme-accessibility-black-white.scss +++ b/src/style/themes/theme-accessibility-black-white.scss @@ -10,7 +10,7 @@ border-bottom: 1px solid $lighter-color; &:hover { - border-width: 2px; + border-width: 4px; } } @@ -20,7 +20,7 @@ border-bottom: 1px solid $dark-color; &:hover { - border-width: 2px; + border-width: 4px; } } diff --git a/src/style/themes/theme-accessibility-font-biggest.scss b/src/style/themes/theme-accessibility-font-biggest.scss index ccf7c583..6030c1c5 100644 --- a/src/style/themes/theme-accessibility-font-biggest.scss +++ b/src/style/themes/theme-accessibility-font-biggest.scss @@ -1,13 +1,19 @@ @import "../variables"; .theme-accessibility-font-biggest { - font-size: 24pt; + font-size: 36pt; + + a { + &:hover { + border-width: 8px; + } + } .main-menu { - font-size: $bigger-font-size; + font-size: $big-font-size; } footer { - font-size: $bigger-font-size; + font-size: $big-font-size; } } diff --git a/src/style/themes/theme-accessibility-white-black.scss b/src/style/themes/theme-accessibility-white-black.scss index f9dc41a8..a5b31423 100644 --- a/src/style/themes/theme-accessibility-white-black.scss +++ b/src/style/themes/theme-accessibility-white-black.scss @@ -10,7 +10,7 @@ border-bottom: 1px solid $darker-color; &:hover { - border-width: 2px; + border-width: 4px; } } @@ -20,7 +20,7 @@ border-bottom: 1px solid $darker-color; &:hover { - border-width: 2px; + border-width: 4px; } } diff --git a/src/style/themes/theme-default.scss b/src/style/themes/theme-default.scss index 9adf41c5..0aa4ceca 100644 --- a/src/style/themes/theme-default.scss +++ b/src/style/themes/theme-default.scss @@ -9,11 +9,10 @@ color: $dark-color; text-decoration: none; - border-width: 1px; - border-bottom-style: solid; + border-bottom: 1px solid lighten($dark-color, 60%); &:hover { - border-width: 2px; + border-bottom: 2px solid $dark-color; } &:active { @@ -37,6 +36,11 @@ a { color: $light-color; + border-bottom-color: darken($light-color, 50%); + + &:hover { + border-bottom-color: $light-color; + } } } } From da3ea2173a653c303ecd0c0bf2d8a71b6447866e Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 21 Feb 2017 04:32:23 +0300 Subject: [PATCH 045/368] theme system updated --- src/client/components/AccessibilityControl.js | 32 +--- src/client/components/ThemeSelector.js | 2 +- src/client/services/theme.js | 142 ++++++++++++++---- .../components/accessibility-control.html | 12 +- 4 files changed, 126 insertions(+), 62 deletions(-) diff --git a/src/client/components/AccessibilityControl.js b/src/client/components/AccessibilityControl.js index 787eb86b..3463b006 100644 --- a/src/client/components/AccessibilityControl.js +++ b/src/client/components/AccessibilityControl.js @@ -4,35 +4,9 @@ export default function (app) { app.component('accessibilityControl', { template, controller: ($scope, theme) => { - const themeSet = { - accessibility: 'accessibility', - color: '', - fontSize: '', - fontFamily: '', - } - - const install = () => { - const baked = Object - .values(themeSet) - .filter(Boolean) - .join(' ') - theme.setTheme(baked) - } - - $scope.setColorTheme = (color) => { - themeSet.color = color - install() - } - - $scope.setFontTheme = (font) => { - themeSet.fontSize = font - install() - } - - $scope.setFontFamilyTheme = (font) => { - themeSet.fontFamily = font - install() - } + $scope.setColorTheme = theme.setColorTheme.bind(theme) + $scope.setFontTheme = theme.setFontTheme.bind(theme) + $scope.setFontFamilyTheme = theme.setFontFamilyTheme.bind(theme) }, }) } diff --git a/src/client/components/ThemeSelector.js b/src/client/components/ThemeSelector.js index 375c4950..3749e4c2 100644 --- a/src/client/components/ThemeSelector.js +++ b/src/client/components/ThemeSelector.js @@ -8,7 +8,7 @@ export default function (app) { `, controller: ($scope, theme) => { const update = () => { - $scope.isMainTheme = theme.currentTheme === theme.mainTheme + $scope.isMainTheme = theme.isDefaultTheme() } $scope.toggleTheme = () => { diff --git a/src/client/services/theme.js b/src/client/services/theme.js index 27c5e7cc..1c99fdc0 100644 --- a/src/client/services/theme.js +++ b/src/client/services/theme.js @@ -1,43 +1,133 @@ const defaultTheme = 'theme-default' -const defaultAccessibilityTheme = 'accessibility theme-accessibility-black-white' -const getTheme = () => localStorage.getItem('theme') +const themeScheme = { + accessibility: 'accessibility', -const isDefaultTheme = () => { - const theme = getTheme() - if (!theme) return true - return theme === defaultTheme + color: { + wb: 'theme-accessibility-white-black', + bw: 'theme-accessibility-black-white', + }, + + font: { + sans: 'theme-accessibility-font-sans', + serif: 'theme-accessibility-font-serif', + }, + + fontSize: { + normal: 'theme-accessibility-font-normal', + big: 'theme-accessibility-font-big', + biggest: 'theme-accessibility-font-biggest', + }, +} + +const defaultAccessibilityTheme = () => ({ + version: '1', + theme: { + accessibility: 'accessibility', + color: 'wb', + font: 'sans', + fontSize: 'big', + }, +}) + +function loadTheme() { + const theme = localStorage.getItem('theme') + try { + return JSON.parse(theme) + } catch (error) { + return null + } +} + +function saveTheme(theme) { + if (!theme) return theme + const str = typeof theme === 'string' + ? theme + : JSON.stringify(theme) + localStorage.setItem('theme', str) + return theme +} + +function resetTheme() { + localStorage.removeItem('theme') +} + +function compileTheme(item) { + if (!item) return defaultTheme + const {theme, version} = item + if (!version) return defaultTheme + + const cssClass = ([scope, name]) => { + try { + return themeScheme[scope][name] + } catch (error) { + return null + } + } + + return Object + .entries(theme) + .map(cssClass) + .filter(Boolean) + .join(' ') } class Theme { constructor($rootScope) { this.mainTheme = defaultTheme - this.currentTheme = defaultAccessibilityTheme + this.themeSetup = defaultAccessibilityTheme() + this.__scope = $rootScope - this.toggle = () => { - if (isDefaultTheme()) { - this.setTheme(this.currentTheme) - } else { - this.setMainTheme() - } + this.setTheme(loadTheme()) + } + + toggle() { + if (this.isDefaultTheme()) { + this.setTheme(this.themeSetup) + } else { + this.setMainTheme() } + } - this.setTheme = (themeName) => { - if (!themeName) { - this.setMainTheme() - } else { - localStorage.setItem('theme', themeName) - this.currentTheme = themeName - $rootScope.theme = themeName - } + setMainTheme() { + resetTheme() + this.__scope.theme = this.mainTheme + } + + setTheme(theme) { + if (!theme) { + this.setMainTheme() + } else { + const css = compileTheme(theme) + + saveTheme(theme) + this.themeSetup = theme + this.__scope.theme = css } + } - this.setMainTheme = () => { - localStorage.removeItem('theme') - $rootScope.theme = this.mainTheme - } + setColorTheme(theme) { + this.themeSetup.theme.color = theme + this.install() + } - this.setTheme(getTheme()) + setFontTheme(theme) { + this.themeSetup.theme.fontSize = theme + this.install() + } + + setFontFamilyTheme(theme) { + this.themeSetup.theme.font = theme + this.install() + } + + install() { + this.setTheme(this.themeSetup) + } + + isDefaultTheme(){ + const theme = loadTheme() + return !theme // default theme cleared up local storage } } diff --git a/src/templates/components/accessibility-control.html b/src/templates/components/accessibility-control.html index a3dc37b2..611342fc 100644 --- a/src/templates/components/accessibility-control.html +++ b/src/templates/components/accessibility-control.html @@ -1,12 +1,12 @@
) -const Article = ({children, article, shareable}) => ( +const Article = ({children, date, tags, title, shareable}) => (
- {article.title} + {title}
- {children || getHtml(article.post)} + {children}
{!shareable ? null : ( diff --git a/src/render/articles.js b/src/render/articles.js index 85db6637..db70403c 100644 --- a/src/render/articles.js +++ b/src/render/articles.js @@ -6,6 +6,7 @@ const {render} = require('../lib/render') const timestamp = require('../lib/date').timestamp const ImageArtifactType = require('../core/ImageArtifactType') const {sortBy} = require('../utils/sort') +const getHtml = require('../lib/component').getHtml const sortArticleByDate = sortBy( x => timestamp(new Date(x.date)) @@ -112,9 +113,13 @@ async function renderArticle(id) { const Component = (
+ > + {getHtml(article.post)} +
) From f174d297f299dab00e390092325690eb40676739 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 17:26:18 +0300 Subject: [PATCH 340/368] [www] renderAlbum --- src/render/albums.js | 34 ++++++++++++++++++++++++++++++++++ src/routes/albums.js | 31 ++++--------------------------- 2 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 src/render/albums.js diff --git a/src/render/albums.js b/src/render/albums.js new file mode 100644 index 00000000..4f48cd04 --- /dev/null +++ b/src/render/albums.js @@ -0,0 +1,34 @@ +const React = require('react') +const Article = require('../components/Article') +const Album = require('../core/Album') +const {render} = require('../lib/render') +const getHtml = require('../lib/component').getHtml + +function getMeta(album) { + return { + title: album.title, + description: album.title, + } +} + +async function renderAlbum(id) { + const album = await Album.findById(id) + + if (!album) return null + + const Component = ( +
+
+ {getHtml(album.post)} +
+
+ ) + + return render(album.url, Component, getMeta(album), {commentsEnabled: true, menuPadding: true}) +} + +exports.renderAlbum = renderAlbum diff --git a/src/routes/albums.js b/src/routes/albums.js index bac44308..5f343912 100644 --- a/src/routes/albums.js +++ b/src/routes/albums.js @@ -1,36 +1,13 @@ -const React = require('react') -const Article = require('../components/Article') -const Album = require('../core/Album') -const {render} = require('../lib/render') -const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash +const {renderAlbum} = require('../render/albums') const {get} = require('koa-route') -function getMeta(album) { - return { - title: album.title, - description: album.title, - } -} - function getAlbum() { return get('/album/:id', async (ctx, id) => { - const path = getPathWithNoTrailingSlash(ctx.path) - const album = await Album.findById(id) - - if (album) { - const Component = ( -
-
-
- ) + const body = await renderAlbum(id) + if (body) { ctx.type = 'text/html' - ctx.body = await render(path, Component, getMeta(album), {commentsEnabled: true, menuPadding: true}) + ctx.body = body } else { ctx.status = 404 } From 438c340a964168e05be8908320669d0afad23da7 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 17:26:36 +0300 Subject: [PATCH 341/368] [www] content sizes for tablet updated --- src/style/content.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/content.scss b/src/style/content.scss index ddfc5bef..8dbd1298 100644 --- a/src/style/content.scss +++ b/src/style/content.scss @@ -86,7 +86,7 @@ } &.content--padding-top--menu { - padding-top: $menu-thickness + $double-margin; + padding-top: var(--double-margin); } } From 3d453ead4b26a6c92b00299fd50514fe03737d9f Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 17:27:24 +0300 Subject: [PATCH 342/368] [www] sticky footer improvements (fix on old iOS) --- src/style/body-wrapper.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/body-wrapper.scss b/src/style/body-wrapper.scss index 4af8c9c9..b8eb513e 100644 --- a/src/style/body-wrapper.scss +++ b/src/style/body-wrapper.scss @@ -3,7 +3,7 @@ .body-wrapper { display: flex; flex-direction: column; - height: 100%; + min-height: 100vh; background-color: white; font-family: $text-font; From a72fe8b14d29decbc889fd5db2fc5d6ff8e82274 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 19:10:49 +0300 Subject: [PATCH 343/368] [www] opa version updated --- src/3rdparty/opa.js | 1226 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 1095 insertions(+), 131 deletions(-) diff --git a/src/3rdparty/opa.js b/src/3rdparty/opa.js index dc8455a6..695f2c86 100644 --- a/src/3rdparty/opa.js +++ b/src/3rdparty/opa.js @@ -60,7 +60,7 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 41); +/******/ return __webpack_require__(__webpack_require__.s = 42); /******/ }) /************************************************************************/ /******/ ([ @@ -79,8 +79,8 @@ if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef /* 1 */ /***/ (function(module, exports, __webpack_require__) { -var store = __webpack_require__(27)('wks'); -var uid = __webpack_require__(28); +var store = __webpack_require__(28)('wks'); +var uid = __webpack_require__(29); var Symbol = __webpack_require__(0).Symbol; var USE_SYMBOL = typeof Symbol == 'function'; @@ -219,7 +219,7 @@ exports.f = __webpack_require__(7) ? Object.defineProperty : function defineProp /***/ (function(module, exports, __webpack_require__) { // Thank's IE8 for his funny defineProperty -module.exports = !__webpack_require__(26)(function () { +module.exports = !__webpack_require__(27)(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); @@ -375,8 +375,8 @@ module.exports = function (it) { /* 20 */ /***/ (function(module, exports, __webpack_require__) { -var shared = __webpack_require__(27)('keys'); -var uid = __webpack_require__(28); +var shared = __webpack_require__(28)('keys'); +var uid = __webpack_require__(29); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; @@ -424,12 +424,18 @@ module.exports.f = function (C) { /* 23 */ /***/ (function(module, exports, __webpack_require__) { +module.exports = { "default": __webpack_require__(43), __esModule: true }; + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; var $at = __webpack_require__(45)(true); // 21.1.3.27 String.prototype[@@iterator]() -__webpack_require__(24)(String, 'String', function (iterated) { +__webpack_require__(25)(String, 'String', function (iterated) { this._t = String(iterated); // target this._i = 0; // next index // 21.1.5.2.1 %StringIteratorPrototype%.next() @@ -445,12 +451,12 @@ __webpack_require__(24)(String, 'String', function (iterated) { /***/ }), -/* 24 */ +/* 25 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var LIBRARY = __webpack_require__(25); +var LIBRARY = __webpack_require__(26); var $export = __webpack_require__(4); var redefine = __webpack_require__(48); var hide = __webpack_require__(5); @@ -522,14 +528,14 @@ module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE /***/ }), -/* 25 */ +/* 26 */ /***/ (function(module, exports) { module.exports = true; /***/ }), -/* 26 */ +/* 27 */ /***/ (function(module, exports) { module.exports = function (exec) { @@ -542,7 +548,7 @@ module.exports = function (exec) { /***/ }), -/* 27 */ +/* 28 */ /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(0); @@ -554,7 +560,7 @@ module.exports = function (key) { /***/ }), -/* 28 */ +/* 29 */ /***/ (function(module, exports) { var id = 0; @@ -565,7 +571,7 @@ module.exports = function (key) { /***/ }), -/* 29 */ +/* 30 */ /***/ (function(module, exports) { // IE 8- don't enum bug keys @@ -575,7 +581,7 @@ module.exports = ( /***/ }), -/* 30 */ +/* 31 */ /***/ (function(module, exports, __webpack_require__) { var document = __webpack_require__(0).document; @@ -583,7 +589,7 @@ module.exports = document && document.documentElement; /***/ }), -/* 31 */ +/* 32 */ /***/ (function(module, exports, __webpack_require__) { // 7.1.13 ToObject(argument) @@ -594,7 +600,7 @@ module.exports = function (it) { /***/ }), -/* 32 */ +/* 33 */ /***/ (function(module, exports, __webpack_require__) { // getting tag from 19.1.3.6 Object.prototype.toString() @@ -623,7 +629,7 @@ module.exports = function (it) { /***/ }), -/* 33 */ +/* 34 */ /***/ (function(module, exports, __webpack_require__) { // call something on iterator step with safe closing on error @@ -641,7 +647,7 @@ module.exports = function (iterator, fn, value, entries) { /***/ }), -/* 34 */ +/* 35 */ /***/ (function(module, exports, __webpack_require__) { // check on default Array iterator @@ -655,10 +661,10 @@ module.exports = function (it) { /***/ }), -/* 35 */ +/* 36 */ /***/ (function(module, exports, __webpack_require__) { -var classof = __webpack_require__(32); +var classof = __webpack_require__(33); var ITERATOR = __webpack_require__(1)('iterator'); var Iterators = __webpack_require__(10); module.exports = __webpack_require__(2).getIteratorMethod = function (it) { @@ -669,7 +675,7 @@ module.exports = __webpack_require__(2).getIteratorMethod = function (it) { /***/ }), -/* 36 */ +/* 37 */ /***/ (function(module, exports, __webpack_require__) { // 7.3.20 SpeciesConstructor(O, defaultConstructor) @@ -684,12 +690,12 @@ module.exports = function (O, D) { /***/ }), -/* 37 */ +/* 38 */ /***/ (function(module, exports, __webpack_require__) { var ctx = __webpack_require__(8); var invoke = __webpack_require__(65); -var html = __webpack_require__(30); +var html = __webpack_require__(31); var cel = __webpack_require__(16); var global = __webpack_require__(0); var process = global.process; @@ -774,7 +780,7 @@ module.exports = { /***/ }), -/* 38 */ +/* 39 */ /***/ (function(module, exports) { module.exports = function (exec) { @@ -787,7 +793,7 @@ module.exports = function (exec) { /***/ }), -/* 39 */ +/* 40 */ /***/ (function(module, exports, __webpack_require__) { var anObject = __webpack_require__(3); @@ -805,7 +811,7 @@ module.exports = function (C, x) { /***/ }), -/* 40 */ +/* 41 */ /***/ (function(module, exports, __webpack_require__) { var ITERATOR = __webpack_require__(1)('iterator'); @@ -833,13 +839,13 @@ module.exports = function (exec, skipClosing) { /***/ }), -/* 41 */ +/* 42 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var _promise = __webpack_require__(42); +var _promise = __webpack_require__(23); var _promise2 = _interopRequireDefault(_promise); @@ -847,14 +853,140 @@ var _toConsumableArray2 = __webpack_require__(71); var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); -var _classCallCheck2 = __webpack_require__(76); +var _regenerator = __webpack_require__(76); + +var _regenerator2 = _interopRequireDefault(_regenerator); + +var _asyncToGenerator2 = __webpack_require__(79); + +var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); + +var _classCallCheck2 = __webpack_require__(80); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); -var _createClass2 = __webpack_require__(77); +var _createClass2 = __webpack_require__(81); var _createClass3 = _interopRequireDefault(_createClass2); +var runAppear = function () { + var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(item) { + return _regenerator2.default.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + item.classList.add('opa--visible'); + return _context3.abrupt('return', timeout(500, item).then(function (item) { + item.dataset.opaAppeared = true; + item.classList.remove('opa--visible'); + item.classList.remove('opa'); + return item; + })); + + case 2: + case 'end': + return _context3.stop(); + } + } + }, _callee3, this); + })); + + return function runAppear(_x) { + return _ref3.apply(this, arguments); + }; +}(); + +var opaAppear = function () { + var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(item) { + return _regenerator2.default.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + if (!item.dataset.opaAppeared) { + _context4.next = 2; + break; + } + + return _context4.abrupt('return', _promise2.default.resolve(item)); + + case 2: + if (!item.classList.contains('opa--visible')) { + _context4.next = 4; + break; + } + + return _context4.abrupt('return', _promise2.default.resolve(item)); + + case 4: + + // noinspection JSIgnoredPromiseFromCall + runAppear(item); + + case 5: + case 'end': + return _context4.stop(); + } + } + }, _callee4, this); + })); + + return function opaAppear(_x2) { + return _ref4.apply(this, arguments); + }; +}(); + +var elementLoaded = function () { + var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(element) { + return _regenerator2.default.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + return _context5.abrupt('return', isImageLoaded(element) ? _promise2.default.resolve(element) : new _promise2.default(function (resolve) { + element.addEventListener('load', function () { + resolve(element); + }); + })); + + case 1: + case 'end': + return _context5.stop(); + } + } + }, _callee5, this); + })); + + return function elementLoaded(_x3) { + return _ref5.apply(this, arguments); + }; +}(); + +var timeout = function () { + var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(time) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return _regenerator2.default.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + return _context6.abrupt('return', new _promise2.default(function (resolve) { + setTimeout.apply(undefined, [resolve, time].concat((0, _toConsumableArray3.default)(args))); + })); + + case 1: + case 'end': + return _context6.stop(); + } + } + }, _callee6, this); + })); + + return function timeout(_x4) { + return _ref6.apply(this, arguments); + }; +}(); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Opa = function () { @@ -876,38 +1008,91 @@ var Opa = function () { } }, { key: 'appear', - value: async function appear() { - var _this = this; + value: function () { + var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() { + var _this = this; - if (this.after) { - return this.after.appear().then(function () { - return timeout(_this.delay); - }).then(function () { - return _this.appearNow(); - }); - } else { - return this.appearNow(); + return _regenerator2.default.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + if (!this.after) { + _context.next = 4; + break; + } + + return _context.abrupt('return', this.after.appear().then(function () { + return timeout(_this.delay); + }).then(function () { + return _this.appearNow(); + })); + + case 4: + return _context.abrupt('return', this.appearNow()); + + case 5: + case 'end': + return _context.stop(); + } + } + }, _callee, this); + })); + + function appear() { + return _ref.apply(this, arguments); } - } + + return appear; + }() }, { key: 'appearNow', - value: async function appearNow() { - var _this2 = this; + value: function () { + var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { + var _this2 = this; - if (this.isLoaded) { - if (this.__appear) return this.__appear; + return _regenerator2.default.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + if (!this.isLoaded) { + _context2.next = 5; + break; + } - this.__appear = opaAppear(this.item).then(function (item) { - return _this2.__clear(); - }); - return this.__appear; + if (!this.__appear) { + _context2.next = 3; + break; + } + + return _context2.abrupt('return', this.__appear); + + case 3: + + this.__appear = opaAppear(this.item).then(function (item) { + return _this2.__clear(); + }); + return _context2.abrupt('return', this.__appear); + + case 5: + return _context2.abrupt('return', elementLoaded(this.item).then(function () { + _this2.isLoaded = true; + return _this2.appearNow(); + })); + + case 6: + case 'end': + return _context2.stop(); + } + } + }, _callee2, this); + })); + + function appearNow() { + return _ref2.apply(this, arguments); } - return elementLoaded(this.item).then(function () { - _this2.isLoaded = true; - return _this2.appearNow(); - }); - } + return appearNow; + }() }, { key: '__clear', value: function __clear() { @@ -963,32 +1148,6 @@ function initOpaGroup(items) { }); } -async function runAppear(item) { - item.classList.add('opa--visible'); - return timeout(500, item).then(function (item) { - item.dataset.opaAppeared = true; - item.classList.remove('opa--visible'); - item.classList.remove('opa'); - return item; - }); -} - -async function opaAppear(item) { - if (item.dataset.opaAppeared) return _promise2.default.resolve(item); - if (item.classList.contains('opa--visible')) return _promise2.default.resolve(item); - - // noinspection JSIgnoredPromiseFromCall - runAppear(item); -} - -async function elementLoaded(element) { - return isImageLoaded(element) ? _promise2.default.resolve(element) : new _promise2.default(function (resolve) { - element.addEventListener('load', function () { - resolve(element); - }); - }); -} - function isImageLoaded(img) { if (!img.complete) return false; if (typeof img.naturalWidth !== 'undefined' && img.naturalWidth === 0) return false; @@ -997,28 +1156,12 @@ function isImageLoaded(img) { return true; } -async function timeout(time) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - return new _promise2.default(function (resolve) { - setTimeout.apply(undefined, [resolve, time].concat(args)); - }); -} - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = { "default": __webpack_require__(43), __esModule: true }; - /***/ }), /* 43 */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(44); -__webpack_require__(23); +__webpack_require__(24); __webpack_require__(58); __webpack_require__(62); __webpack_require__(69); @@ -1059,7 +1202,7 @@ module.exports = function (TO_STRING) { /* 46 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = !__webpack_require__(7) && !__webpack_require__(26)(function () { +module.exports = !__webpack_require__(7) && !__webpack_require__(27)(function () { return Object.defineProperty(__webpack_require__(16)('div'), 'a', { get: function () { return 7; } }).a != 7; }); @@ -1116,7 +1259,7 @@ module.exports = function (Constructor, NAME, next) { // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = __webpack_require__(3); var dPs = __webpack_require__(51); -var enumBugKeys = __webpack_require__(29); +var enumBugKeys = __webpack_require__(30); var IE_PROTO = __webpack_require__(20)('IE_PROTO'); var Empty = function () { /* empty */ }; var PROTOTYPE = 'prototype'; @@ -1130,7 +1273,7 @@ var createDict = function () { var gt = '>'; var iframeDocument; iframe.style.display = 'none'; - __webpack_require__(30).appendChild(iframe); + __webpack_require__(31).appendChild(iframe); iframe.src = 'javascript:'; // eslint-disable-line no-script-url // createDict = iframe.contentWindow.Object; // html.removeChild(iframe); @@ -1181,7 +1324,7 @@ module.exports = __webpack_require__(7) ? Object.defineProperties : function def // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = __webpack_require__(53); -var enumBugKeys = __webpack_require__(29); +var enumBugKeys = __webpack_require__(30); module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); @@ -1271,7 +1414,7 @@ module.exports = function (index, length) { // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var has = __webpack_require__(12); -var toObject = __webpack_require__(31); +var toObject = __webpack_require__(32); var IE_PROTO = __webpack_require__(20)('IE_PROTO'); var ObjectProto = Object.prototype; @@ -1324,7 +1467,7 @@ var toIObject = __webpack_require__(18); // 22.1.3.13 Array.prototype.keys() // 22.1.3.29 Array.prototype.values() // 22.1.3.30 Array.prototype[@@iterator]() -module.exports = __webpack_require__(24)(Array, 'Array', function (iterated, kind) { +module.exports = __webpack_require__(25)(Array, 'Array', function (iterated, kind) { this._t = toIObject(iterated); // target this._i = 0; // next index this._k = kind; // kind @@ -1372,21 +1515,21 @@ module.exports = function (done, value) { "use strict"; -var LIBRARY = __webpack_require__(25); +var LIBRARY = __webpack_require__(26); var global = __webpack_require__(0); var ctx = __webpack_require__(8); -var classof = __webpack_require__(32); +var classof = __webpack_require__(33); var $export = __webpack_require__(4); var isObject = __webpack_require__(9); var aFunction = __webpack_require__(11); var anInstance = __webpack_require__(63); var forOf = __webpack_require__(64); -var speciesConstructor = __webpack_require__(36); -var task = __webpack_require__(37).set; +var speciesConstructor = __webpack_require__(37); +var task = __webpack_require__(38).set; var microtask = __webpack_require__(66)(); var newPromiseCapabilityModule = __webpack_require__(22); -var perform = __webpack_require__(38); -var promiseResolve = __webpack_require__(39); +var perform = __webpack_require__(39); +var promiseResolve = __webpack_require__(40); var PROMISE = 'Promise'; var TypeError = global.TypeError; var process = global.process; @@ -1607,7 +1750,7 @@ $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x); } }); -$export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(40)(function (iter) { +$export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(41)(function (iter) { $Promise.all(iter)['catch'](empty); })), PROMISE, { // 25.4.4.1 Promise.all(iterable) @@ -1669,11 +1812,11 @@ module.exports = function (it, Constructor, name, forbiddenField) { /***/ (function(module, exports, __webpack_require__) { var ctx = __webpack_require__(8); -var call = __webpack_require__(33); -var isArrayIter = __webpack_require__(34); +var call = __webpack_require__(34); +var isArrayIter = __webpack_require__(35); var anObject = __webpack_require__(3); var toLength = __webpack_require__(19); -var getIterFn = __webpack_require__(35); +var getIterFn = __webpack_require__(36); var BREAK = {}; var RETURN = {}; var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { @@ -1722,7 +1865,7 @@ module.exports = function (fn, args, that) { /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(0); -var macrotask = __webpack_require__(37).set; +var macrotask = __webpack_require__(38).set; var Observer = global.MutationObserver || global.WebKitMutationObserver; var process = global.process; var Promise = global.Promise; @@ -1835,8 +1978,8 @@ module.exports = function (KEY) { var $export = __webpack_require__(4); var core = __webpack_require__(2); var global = __webpack_require__(0); -var speciesConstructor = __webpack_require__(36); -var promiseResolve = __webpack_require__(39); +var speciesConstructor = __webpack_require__(37); +var promiseResolve = __webpack_require__(40); $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) { var C = speciesConstructor(this, core.Promise || global.Promise); @@ -1861,7 +2004,7 @@ $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) { // https://github.com/tc39/proposal-promise-try var $export = __webpack_require__(4); var newPromiseCapability = __webpack_require__(22); -var perform = __webpack_require__(38); +var perform = __webpack_require__(39); $export($export.S, 'Promise', { 'try': function (callbackfn) { var promiseCapability = newPromiseCapability.f(this); @@ -1908,7 +2051,7 @@ module.exports = { "default": __webpack_require__(73), __esModule: true }; /* 73 */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(23); +__webpack_require__(24); __webpack_require__(74); module.exports = __webpack_require__(2).Array.from; @@ -1921,14 +2064,14 @@ module.exports = __webpack_require__(2).Array.from; var ctx = __webpack_require__(8); var $export = __webpack_require__(4); -var toObject = __webpack_require__(31); -var call = __webpack_require__(33); -var isArrayIter = __webpack_require__(34); +var toObject = __webpack_require__(32); +var call = __webpack_require__(34); +var isArrayIter = __webpack_require__(35); var toLength = __webpack_require__(19); var createProperty = __webpack_require__(75); -var getIterFn = __webpack_require__(35); +var getIterFn = __webpack_require__(36); -$export($export.S + $export.F * !__webpack_require__(40)(function (iter) { Array.from(iter); }), 'Array', { +$export($export.S + $export.F * !__webpack_require__(41)(function (iter) { Array.from(iter); }), 'Array', { // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { var O = toObject(arrayLike); @@ -1976,6 +2119,827 @@ module.exports = function (object, index, value) { /* 76 */ /***/ (function(module, exports, __webpack_require__) { +module.exports = __webpack_require__(77); + + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +// This method of obtaining a reference to the global object needs to be +// kept identical to the way it is obtained in runtime.js +var g = (function() { return this })() || Function("return this")(); + +// Use `getOwnPropertyNames` because not all browsers support calling +// `hasOwnProperty` on the global `self` object in a worker. See #183. +var hadRuntime = g.regeneratorRuntime && + Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; + +// Save the old regeneratorRuntime in case it needs to be restored later. +var oldRuntime = hadRuntime && g.regeneratorRuntime; + +// Force reevalutation of runtime.js. +g.regeneratorRuntime = undefined; + +module.exports = __webpack_require__(78); + +if (hadRuntime) { + // Restore the original runtime. + g.regeneratorRuntime = oldRuntime; +} else { + // Remove the global property added by runtime.js. + try { + delete g.regeneratorRuntime; + } catch(e) { + g.regeneratorRuntime = undefined; + } +} + + +/***/ }), +/* 78 */ +/***/ (function(module, exports) { + +/** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * https://raw.github.com/facebook/regenerator/master/LICENSE file. An + * additional grant of patent rights can be found in the PATENTS file in + * the same directory. + */ + +!(function(global) { + "use strict"; + + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; + var undefined; // More compressible than void 0. + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; + + var inModule = typeof module === "object"; + var runtime = global.regeneratorRuntime; + if (runtime) { + if (inModule) { + // If regeneratorRuntime is defined globally and we're in a module, + // make the exports object identical to regeneratorRuntime. + module.exports = runtime; + } + // Don't bother evaluating the rest of this file if the runtime was + // already defined globally. + return; + } + + // Define the runtime globally (as expected by generated code) as either + // module.exports (if we're in a module) or a new, empty object. + runtime = global.regeneratorRuntime = inModule ? module.exports : {}; + + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; + var generator = Object.create(protoGenerator.prototype); + var context = new Context(tryLocsList || []); + + // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + generator._invoke = makeInvokeMethod(innerFn, self, context); + + return generator; + } + runtime.wrap = wrap; + + // Try/catch helper to minimize deoptimizations. Returns a completion + // record like context.tryEntries[i].completion. This interface could + // have been (and was previously) designed to take a closure to be + // invoked without arguments, but in all the cases we care about we + // already have an existing method we want to call, so there's no need + // to create a new function object. We can even get away with assuming + // the method takes exactly one argument, since that happens to be true + // in every case, so we don't have to touch the arguments object. The + // only additional allocation required is the completion record, which + // has a stable shape and so hopefully should be cheap to allocate. + function tryCatch(fn, obj, arg) { + try { + return { type: "normal", arg: fn.call(obj, arg) }; + } catch (err) { + return { type: "throw", arg: err }; + } + } + + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; + + // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. + var ContinueSentinel = {}; + + // Dummy constructor functions that we use as the .constructor and + // .constructor.prototype properties for functions that return Generator + // objects. For full spec compliance, you may wish to configure your + // minifier not to mangle the names of these two functions. + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + + // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + var IteratorPrototype = {}; + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; + + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + if (NativeIteratorPrototype && + NativeIteratorPrototype !== Op && + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; + } + + var Gp = GeneratorFunctionPrototype.prototype = + Generator.prototype = Object.create(IteratorPrototype); + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = + GeneratorFunction.displayName = "GeneratorFunction"; + + // Helper for defining the .next, .throw, and .return methods of the + // Iterator interface in terms of a single ._invoke method. + function defineIteratorMethods(prototype) { + ["next", "throw", "return"].forEach(function(method) { + prototype[method] = function(arg) { + return this._invoke(method, arg); + }; + }); + } + + runtime.isGeneratorFunction = function(genFun) { + var ctor = typeof genFun === "function" && genFun.constructor; + return ctor + ? ctor === GeneratorFunction || + // For the native GeneratorFunction constructor, the best we can + // do is to check its .name property. + (ctor.displayName || ctor.name) === "GeneratorFunction" + : false; + }; + + runtime.mark = function(genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + } else { + genFun.__proto__ = GeneratorFunctionPrototype; + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; + } + } + genFun.prototype = Object.create(Gp); + return genFun; + }; + + // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. + runtime.awrap = function(arg) { + return { __await: arg }; + }; + + function AsyncIterator(generator) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + if (value && + typeof value === "object" && + hasOwn.call(value, "__await")) { + return Promise.resolve(value.__await).then(function(value) { + invoke("next", value, resolve, reject); + }, function(err) { + invoke("throw", err, resolve, reject); + }); + } + + return Promise.resolve(value).then(function(unwrapped) { + // When a yielded Promise is resolved, its final value becomes + // the .value of the Promise<{value,done}> result for the + // current iteration. If the Promise is rejected, however, the + // result for this iteration will be rejected with the same + // reason. Note that rejections of yielded Promises are not + // thrown back into the generator function, as is the case + // when an awaited Promise is rejected. This difference in + // behavior between yield and await is important, because it + // allows the consumer to decide what to do with the yielded + // rejection (swallow it and continue, manually .throw it back + // into the generator, abandon iteration, whatever). With + // await, by contrast, there is no opportunity to examine the + // rejection reason outside the generator function, so the + // only option is to throw it from the await expression, and + // let the generator function handle the exception. + result.value = unwrapped; + resolve(result); + }, reject); + } + } + + var previousPromise; + + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new Promise(function(resolve, reject) { + invoke(method, arg, resolve, reject); + }); + } + + return previousPromise = + // If enqueue has been called before, then we want to wait until + // all previous Promises have been resolved before calling invoke, + // so that results are always delivered in the correct order. If + // enqueue has not been called before, then it is important to + // call invoke immediately, without waiting on a callback to fire, + // so that the async generator function has the opportunity to do + // any necessary setup in a predictable way. This predictability + // is why the Promise constructor synchronously invokes its + // executor callback, and why async functions synchronously + // execute code before the first await. Since we implement simple + // async functions in terms of async generators, it is especially + // important to get this right, even though it requires care. + previousPromise ? previousPromise.then( + callInvokeWithMethodAndArg, + // Avoid propagating failures to Promises returned by later + // invocations of the iterator. + callInvokeWithMethodAndArg + ) : callInvokeWithMethodAndArg(); + } + + // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + this._invoke = enqueue; + } + + defineIteratorMethods(AsyncIterator.prototype); + AsyncIterator.prototype[asyncIteratorSymbol] = function () { + return this; + }; + runtime.AsyncIterator = AsyncIterator; + + // Note that simple async functions are implemented on top of + // AsyncIterator objects; they just return a Promise for the value of + // the final result produced by the iterator. + runtime.async = function(innerFn, outerFn, self, tryLocsList) { + var iter = new AsyncIterator( + wrap(innerFn, outerFn, self, tryLocsList) + ); + + return runtime.isGeneratorFunction(outerFn) + ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function(result) { + return result.done ? result.value : iter.next(); + }); + }; + + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; + + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); + } + + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; + } + + // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + return doneResult(); + } + + context.method = method; + context.arg = arg; + + while (true) { + var delegate = context.delegate; + if (delegate) { + var delegateResult = maybeInvokeDelegate(delegate, context); + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; + } + } + + if (context.method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = context.arg; + + } else if (context.method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw context.arg; + } + + context.dispatchException(context.arg); + + } else if (context.method === "return") { + context.abrupt("return", context.arg); + } + + state = GenStateExecuting; + + var record = tryCatch(innerFn, self, context); + if (record.type === "normal") { + // If an exception is thrown from innerFn, we leave state === + // GenStateExecuting and loop back for another invocation. + state = context.done + ? GenStateCompleted + : GenStateSuspendedYield; + + if (record.arg === ContinueSentinel) { + continue; + } + + return { + value: record.arg, + done: context.done + }; + + } else if (record.type === "throw") { + state = GenStateCompleted; + // Dispatch the exception by looping back around to the + // context.dispatchException(context.arg) call above. + context.method = "throw"; + context.arg = record.arg; + } + } + }; + } + + // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; + + if (context.method === "throw") { + if (delegate.iterator.return) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); + + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } + } + + context.method = "throw"; + context.arg = new TypeError( + "The iterator does not provide a 'throw' method"); + } + + return ContinueSentinel; + } + + var record = tryCatch(method, delegate.iterator, context.arg); + + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } + + var info = record.arg; + + if (! info) { + context.method = "throw"; + context.arg = new TypeError("iterator result is not an object"); + context.delegate = null; + return ContinueSentinel; + } + + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; + + // Resume execution at the desired location (see delegateYield). + context.next = delegate.nextLoc; + + // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; + } + + } else { + // Re-yield the result returned by the delegate method. + return info; + } + + // The delegate iterator is finished, so forget it and continue with + // the outer generator. + context.delegate = null; + return ContinueSentinel; + } + + // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. + defineIteratorMethods(Gp); + + Gp[toStringTagSymbol] = "Generator"; + + // A Generator should always return itself as the iterator object when the + // @@iterator function is called on it. Some browsers' implementations of the + // iterator prototype chain incorrectly implement this, causing the Generator + // object to not be returned from this call. This ensures that doesn't happen. + // See https://github.com/facebook/regenerator/issues/274 for more details. + Gp[iteratorSymbol] = function() { + return this; + }; + + Gp.toString = function() { + return "[object Generator]"; + }; + + function pushTryEntry(locs) { + var entry = { tryLoc: locs[0] }; + + if (1 in locs) { + entry.catchLoc = locs[1]; + } + + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; + } + + this.tryEntries.push(entry); + } + + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; + } + + function Context(tryLocsList) { + // The root entry object (effectively a try statement without a catch + // or a finally block) gives us a place to store values thrown from + // locations where there is no enclosing try statement. + this.tryEntries = [{ tryLoc: "root" }]; + tryLocsList.forEach(pushTryEntry, this); + this.reset(true); + } + + runtime.keys = function(object) { + var keys = []; + for (var key in object) { + keys.push(key); + } + keys.reverse(); + + // Rather than returning an object with a next method, we keep + // things simple and return the next function itself. + return function next() { + while (keys.length) { + var key = keys.pop(); + if (key in object) { + next.value = key; + next.done = false; + return next; + } + } + + // To avoid creating an additional object, we just hang the .value + // and .done properties off the next function object itself. This + // also ensures that the minifier will not anonymize the function. + next.done = true; + return next; + }; + }; + + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; + if (iteratorMethod) { + return iteratorMethod.call(iterable); + } + + if (typeof iterable.next === "function") { + return iterable; + } + + if (!isNaN(iterable.length)) { + var i = -1, next = function next() { + while (++i < iterable.length) { + if (hasOwn.call(iterable, i)) { + next.value = iterable[i]; + next.done = false; + return next; + } + } + + next.value = undefined; + next.done = true; + + return next; + }; + + return next.next = next; + } + } + + // Return an iterator with no values. + return { next: doneResult }; + } + runtime.values = values; + + function doneResult() { + return { value: undefined, done: true }; + } + + Context.prototype = { + constructor: Context, + + reset: function(skipTempReset) { + this.prev = 0; + this.next = 0; + // Resetting context._sent for legacy support of Babel's + // function.sent implementation. + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; + + this.method = "next"; + this.arg = undefined; + + this.tryEntries.forEach(resetTryEntry); + + if (!skipTempReset) { + for (var name in this) { + // Not sure about the optimal order of these conditions: + if (name.charAt(0) === "t" && + hasOwn.call(this, name) && + !isNaN(+name.slice(1))) { + this[name] = undefined; + } + } + } + }, + + stop: function() { + this.done = true; + + var rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } + + return this.rval; + }, + + dispatchException: function(exception) { + if (this.done) { + throw exception; + } + + var context = this; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; + + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; + } + + return !! caught; + } + + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; + + if (entry.tryLoc === "root") { + // Exception thrown outside of any try block that could handle + // it, so set the completion value of the entire function to + // throw the exception. + return handle("end"); + } + + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); + + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } + + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else { + throw new Error("try statement without catch or finally"); + } + } + } + }, + + abrupt: function(type, arg) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc <= this.prev && + hasOwn.call(entry, "finallyLoc") && + this.prev < entry.finallyLoc) { + var finallyEntry = entry; + break; + } + } + + if (finallyEntry && + (type === "break" || + type === "continue") && + finallyEntry.tryLoc <= arg && + arg <= finallyEntry.finallyLoc) { + // Ignore the finally entry if control is not jumping to a + // location outside the try/catch block. + finallyEntry = null; + } + + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; + + if (finallyEntry) { + this.method = "next"; + this.next = finallyEntry.finallyLoc; + return ContinueSentinel; + } + + return this.complete(record); + }, + + complete: function(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; + } + + if (record.type === "break" || + record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = this.arg = record.arg; + this.method = "return"; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } + + return ContinueSentinel; + }, + + finish: function(finallyLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.finallyLoc === finallyLoc) { + this.complete(entry.completion, entry.afterLoc); + resetTryEntry(entry); + return ContinueSentinel; + } + } + }, + + "catch": function(tryLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc === tryLoc) { + var record = entry.completion; + if (record.type === "throw") { + var thrown = record.arg; + resetTryEntry(entry); + } + return thrown; + } + } + + // The context.catch method must only be called with a location + // argument that corresponds to a known catch block. + throw new Error("illegal catch attempt"); + }, + + delegateYield: function(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; + + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; + } + + return ContinueSentinel; + } + }; +})( + // In sloppy mode, unbound `this` refers to the global object, fallback to + // Function constructor if we're in global strict mode. That is sadly a form + // of indirect eval which violates Content Security Policy. + (function() { return this })() || Function("return this")() +); + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _promise = __webpack_require__(23); + +var _promise2 = _interopRequireDefault(_promise); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (fn) { + return function () { + var gen = fn.apply(this, arguments); + return new _promise2.default(function (resolve, reject) { + function step(key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + return _promise2.default.resolve(value).then(function (value) { + step("next", value); + }, function (err) { + step("throw", err); + }); + } + } + + return step("next"); + }); + }; +}; + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; @@ -1988,7 +2952,7 @@ exports.default = function (instance, Constructor) { }; /***/ }), -/* 77 */ +/* 81 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -1996,7 +2960,7 @@ exports.default = function (instance, Constructor) { exports.__esModule = true; -var _defineProperty = __webpack_require__(78); +var _defineProperty = __webpack_require__(82); var _defineProperty2 = _interopRequireDefault(_defineProperty); @@ -2021,16 +2985,16 @@ exports.default = function () { }(); /***/ }), -/* 78 */ +/* 82 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = { "default": __webpack_require__(79), __esModule: true }; +module.exports = { "default": __webpack_require__(83), __esModule: true }; /***/ }), -/* 79 */ +/* 83 */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(80); +__webpack_require__(84); var $Object = __webpack_require__(2).Object; module.exports = function defineProperty(it, key, desc) { return $Object.defineProperty(it, key, desc); @@ -2038,7 +3002,7 @@ module.exports = function defineProperty(it, key, desc) { /***/ }), -/* 80 */ +/* 84 */ /***/ (function(module, exports, __webpack_require__) { var $export = __webpack_require__(4); From d2f578c1c8076dfc28ca6ce67c5f0689960f4387 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 19:11:41 +0300 Subject: [PATCH 344/368] [www] gulp compile updated: compile with webpack and babel --- gulpfile.babel.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 7702e78b..2699b287 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -74,19 +74,19 @@ gulp.task('compile', () => { return gulp.src([ './src/public/app.js' ]) - //.pipe(named()) - //.pipe(webpack({ + .pipe(named()) + .pipe(webpack({ // devtool: doSourceMaps ? 'inline-source-map' : null, // watch: doWatch, - // output: { - // filename: '[name].js' - // }, - // module: { - // loaders: [ - // {test: /\.js$/, loader: 'babel'}, + output: { + filename: '[name].js' + }, + module: { + loaders: [ + {test: /\.js$/, loader: 'babel'}, // {test: /\.html$/, loader: 'raw!html-minify'} - // ] - // }, + ] + }, // 'html-minify-loader': { // empty: true, // cdata: true, @@ -95,7 +95,7 @@ gulp.task('compile', () => { // lowerCaseAttributeNames: false // } // } - //})) + })) .pipe(gulp.dest('./public')) }) From e6b206fa4964a564dd7bb6e674247d43cd0469fe Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 19:22:47 +0300 Subject: [PATCH 345/368] [www] opa version updated: opacity 1 by default --- src/3rdparty/opa.css | 13 ++++++++++++- src/3rdparty/opa.js | 10 +++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/opa.css b/src/3rdparty/opa.css index be4d104d..2135fd5b 100644 --- a/src/3rdparty/opa.css +++ b/src/3rdparty/opa.css @@ -4,10 +4,21 @@ transition: opacity var(--time) var(--ease), transform var(--time) var(--ease); transform: scale(.95); +} + +.opa--start { opacity: 0; } .opa--visible { opacity: 1; - transform: scale(1); + transform: scale(1) rotateX(0); } + +figure { + width: 100px; +} + +figure img{ + width: 100%; +} \ No newline at end of file diff --git a/src/3rdparty/opa.js b/src/3rdparty/opa.js index 695f2c86..382d1a28 100644 --- a/src/3rdparty/opa.js +++ b/src/3rdparty/opa.js @@ -875,6 +875,7 @@ var runAppear = function () { while (1) { switch (_context3.prev = _context3.next) { case 0: + item.classList.remove('opa--start'); item.classList.add('opa--visible'); return _context3.abrupt('return', timeout(500, item).then(function (item) { item.dataset.opaAppeared = true; @@ -883,7 +884,7 @@ var runAppear = function () { return item; })); - case 2: + case 3: case 'end': return _context3.stop(); } @@ -1000,6 +1001,11 @@ var Opa = function () { } (0, _createClass3.default)(Opa, [{ + key: 'initElement', + value: function initElement() { + this.item.classList.add('opa--start'); + } + }, { key: 'appearAfter', value: function appearAfter(item) { this.after = item; @@ -1106,8 +1112,6 @@ var Opa = function () { document.addEventListener('DOMContentLoaded', function () { var groups = splitGroups([].concat((0, _toConsumableArray3.default)(document.querySelectorAll('.opa')))); - console.log(groups); - groups.map(initOpaGroup); }); From 1d1b19e2e9a235fea94e0a635b27547fa4bbe1f5 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 19:22:58 +0300 Subject: [PATCH 346/368] [www] person card clean --- src/components/PersonCard.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/components/PersonCard.js b/src/components/PersonCard.js index de7a5a07..538ab819 100644 --- a/src/components/PersonCard.js +++ b/src/components/PersonCard.js @@ -7,14 +7,6 @@ const Link = ({href, children}) => ( ) -const Info = ({children}) => ( -
-
- {children} -
-
-) - module.exports = ({picture, name, url, profile}) => (
@@ -28,13 +20,6 @@ module.exports = ({picture, name, url, profile}) => (
{profile.position} - - {/**/} - {/*

{profile.position}

*/} - {/*

{profile.status}

*/} - {/*

Образование: {profile.edu}

*/} - {/*

Диплом: {profile.diploma}

*/} - {/*
*/}
From dbcd89ac7fad5572ee8e02df446a27df69e0a184 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 19:24:19 +0300 Subject: [PATCH 347/368] [www] article card style updated and optimized for tablet --- src/style/components/ArticleCard.scss | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/style/components/ArticleCard.scss b/src/style/components/ArticleCard.scss index 06094a57..46744518 100644 --- a/src/style/components/ArticleCard.scss +++ b/src/style/components/ArticleCard.scss @@ -2,6 +2,7 @@ .ArticleCard { --article-card-width: 30%; + --article-card-image-height: 15em; --article-card-margin: var(--single-margin) var(--half-margin); display: flex; @@ -9,7 +10,7 @@ margin: var(--article-card-margin); width: var(--article-card-width); - min-width: 15em; + min-width: 10em; max-width: 30em; border: 1px solid #ccc; @@ -18,7 +19,7 @@ & > a { display: block; position: relative; - height: 100%; + // height: 100%; } } @@ -26,11 +27,11 @@ border-radius: 2px 2px 0 0; width: 100%; - height: 15em; + height: var(--article-card-image-height); img { width: 100%; - height: 15em; + height: var(--article-card-image-height); object-fit: cover; } @@ -74,6 +75,19 @@ } } + +// Tablet + +@media screen and (min-width: $tablet-min-width) and (max-width: $tablet-max-width) { + .ArticleCard { + --article-card-image-height: 12em; + } + + @media screen and (orientation: portrait) { + } +} + + // Mobile @media (max-width: $mobile-width) { From 31a345b182e842522ff854b26e5d808ce941cb44 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 19:24:27 +0300 Subject: [PATCH 348/368] [www] person card style updated and optimized for tablet --- src/style/components/PersonCard.scss | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/style/components/PersonCard.scss b/src/style/components/PersonCard.scss index 0dbbaa14..e8e8ddb7 100644 --- a/src/style/components/PersonCard.scss +++ b/src/style/components/PersonCard.scss @@ -2,6 +2,7 @@ .PersonCard { --person-card-width: 30%; + --person-card-height: 24em; display: flex; flex-direction: column; @@ -9,7 +10,7 @@ margin: var(--single-margin) 0; width: var(--person-card-width); - min-width: 15em; + min-width: 10em; max-width: 30em; //border: 1px solid #ccc; @@ -18,7 +19,7 @@ & > a { display: block; position: relative; - height: 100%; + // height: 100%; } } @@ -26,11 +27,11 @@ border-radius: 3px; width: 100%; - height: 24em; + height: var(--person-card-height); img { width: 100%; - height: 24em; + height: var(--person-card-height); object-fit: cover; } @@ -55,6 +56,7 @@ bottom: 0; } + //Animation .PersonCard-Picture { @@ -74,6 +76,18 @@ } +// Tablet + +@media screen and (min-width: $tablet-min-width) and (max-width: $tablet-max-width) { + .PersonCard { + --person-card-height: 20em; + } + + @media screen and (orientation: portrait) { + } +} + + // Mobile @media (max-width: $mobile-width) { From 5bb2f0dc15f06c4b4a886e6f674a8de860d47de9 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 19:24:54 +0300 Subject: [PATCH 349/368] [Sync] Image id updated --- utils/Sync/sync/models/DocumentPreviewImage.py | 4 ---- utils/Sync/sync/models/Image.py | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/utils/Sync/sync/models/DocumentPreviewImage.py b/utils/Sync/sync/models/DocumentPreviewImage.py index e60d3c46..731c8fbe 100644 --- a/utils/Sync/sync/models/DocumentPreviewImage.py +++ b/utils/Sync/sync/models/DocumentPreviewImage.py @@ -2,7 +2,6 @@ import os from tempfile import mkstemp from sync.models.Image import Image, default_url_factory -from utils.hash import md5 from utils.image import image_magick_pdf_to_img @@ -50,9 +49,6 @@ class DocumentPreviewImage(Image): def _get_image_file(self): return self.temp_image_path - def __get_id(self): - return md5(self.file) - def __get_hash(self): return self.provider.hash(self.file) diff --git a/utils/Sync/sync/models/Image.py b/utils/Sync/sync/models/Image.py index 99058f2a..2afec853 100644 --- a/utils/Sync/sync/models/Image.py +++ b/utils/Sync/sync/models/Image.py @@ -148,8 +148,7 @@ class Image(Model): return os.path.basename(self.file) def __get_id(self): - filename = os.path.basename(self.file) - return url_encode_text(filename) + return md5(self.file) def __get_hash(self): file_hash = self.provider.hash(self.file) From 9ce0fbb53dcd31aafb7508dd2461d802c5025e61 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 20:26:16 +0300 Subject: [PATCH 350/368] [Sync] Page preview --- utils/Sync/sync/models/Page.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/utils/Sync/sync/models/Page.py b/utils/Sync/sync/models/Page.py index d62e3281..d8a2d4dd 100644 --- a/utils/Sync/sync/models/Page.py +++ b/utils/Sync/sync/models/Page.py @@ -90,7 +90,10 @@ class Page(Model): self.__hash_salt = settings.hash_salt_pages self.__hash_keys = ['id', 'url'] self.images = [] + self.documents = [] self.title = None + self.data = None + self.preview = None self.__id_template: str = '{category}-{file}' self.__url_template: str = settings.document_url_template @@ -127,8 +130,14 @@ class Page(Model): self.images = images self.documents = documents + if self.has_param('preview'): + preview = self.get_param('preview') + preview = self._get_relpath(preview) + self.preview = await Image.new(self.provider, preview, sizes) + def bake(self): - images = [image.ref for image in self.images] + images = [x.ref for x in self.images] + documents = [x.ref for x in self.documents] return { **self.params, @@ -138,7 +147,9 @@ class Page(Model): 'file': self.file, 'data': self.data, 'images': images, + 'documents': documents, 'title': self.title, + 'preview': self.preview.ref if self.preview else None, } def __filename(self): From 78b1526a3db8937beb2e25d1e74777a33daf0a7e Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 20:28:14 +0300 Subject: [PATCH 351/368] [www] Page refactoring: added model, creating preview, renderPage --- src/core/Page.js | 93 +++++++++++++++++++++++++++++++++++++++++++++ src/core/db.js | 2 + src/render/page.js | 54 ++++++++++++++++++++++++++ src/routes/pages.js | 37 ++---------------- 4 files changed, 153 insertions(+), 33 deletions(-) create mode 100644 src/core/Page.js create mode 100644 src/render/page.js diff --git a/src/core/Page.js b/src/core/Page.js new file mode 100644 index 00000000..388800a9 --- /dev/null +++ b/src/core/Page.js @@ -0,0 +1,93 @@ +const Data = require('./Data') +const Image = require('./Image') +const Config = require('./Config') +const {find, findOne, total} = require('../lib/store') + +const store = () => Data.getStore(Page) + +class Page { + static async find(query, options = {}) { + const items = await find(store(), query, options) + + return Promise.all(items.map(processPage)) + } + + static async findById(id) { + const item = await findOne(store(), {id}) + + return !item + ? null + : processPage(item) + } + + static async findByUrl(url) { + const item = await findOne(store(), {url}) + + return !item + ? null + : processPage(item) + } + + static async total(query = {}) { + return total(store(), query) + } + + constructor(data) { + this.id = data.id + this.hash = data.hash + this.file = data.file + this.url = data.url + this.content = data.content + this.title = data.title + this.data = data.data + this.images = data.images + this.documents = data.documents + this.preview = data.preview + } + + plain() { + return { + id: this.id, + images: this.images, + documents: this.documents, + data: this.data, + title: this.title, + content: this.content, + hash: this.hash, + file: this.file, + preview: this.preview, + url: this.url, + } + } +} + +const previewFromImage = (imgs = []) => imgs.length + ? imgs[0] + : null + +async function resolveDefaultPreview() { + const config = await Config.findConfig() + if (!config) return null + + return Image.findByFile(config.articleCardDefaultPreview) +} + +async function processPage(article) { + let preview = null + const previewId = article.preview + ? article.preview + : previewFromImage(article.images) + + if (previewId) { + preview = await Image.findById(previewId) + } else { + preview = await resolveDefaultPreview() + } + + return new Page({ + ...article, + preview, + }) +} + +module.exports = Page diff --git a/src/core/db.js b/src/core/db.js index 9528a1de..b3a6e123 100644 --- a/src/core/db.js +++ b/src/core/db.js @@ -1,4 +1,5 @@ const Data = require('./Data') +const Page = require('./Page') const Article = require('./Article') const Album = require('./Album') const Teacher = require('./Teacher') @@ -30,6 +31,7 @@ export function id(i) { } function init(db) { + Data.setStore(Page, db.collection('pages')) Data.setStore(Article, db.collection('articles')) Data.setStore(Album, db.collection('albums')) Data.setStore(Image, db.collection('images')) diff --git a/src/render/page.js b/src/render/page.js new file mode 100644 index 00000000..0b118e71 --- /dev/null +++ b/src/render/page.js @@ -0,0 +1,54 @@ +const React = require('react') +const Page = require('../core/Page') +const ImageArtifactType = require('../core/ImageArtifactType') + +const {render} = require('../lib/render') + +const metaImageTypesPriority = [ + ImageArtifactType.FACEBOOK, + ImageArtifactType.MEDIUM, + ImageArtifactType.BIG, + ImageArtifactType.ORIGIN, +] + +function getMeta(page) { + const meta = { + title: page.title, + description: page.title, + } + + if (page.preview) { + try { + const artifact = page.preview.findArtifact(metaImageTypesPriority) + meta.image = artifact.url + meta.imageWidth = artifact.width + meta.imageHeight = artifact.height + } catch (error) { + } + } + return meta +} + +function getComponent(page) { + const Page = require('../components/Page') + + return ( +
+ {page.data} +
+ ) +} + +async function renderPage(path) { + const page = await Page.findByUrl(path) + if (!page) return null + + return render( + path, + getComponent(page), + getMeta(page), + {menuPadding: true}, + ) +} + +exports.renderPage = renderPage diff --git a/src/routes/pages.js b/src/routes/pages.js index ca5a5fea..c06afb30 100644 --- a/src/routes/pages.js +++ b/src/routes/pages.js @@ -1,43 +1,14 @@ -const React = require('react') -const Page = require('../components/Page') - +const {renderPage} = require('../render/page') const {get} = require('koa-route') -const {c} = require('../core/db') - const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash -const {render} = require('../lib/render') - -async function getPage(path) { - return await c('pages').findOne({url: path}) -} - -function getPageMeta(page) { - return { - title: page.title, - description: page.title, - } -} - -function getComponent(page) { - return ( -
- {page.data} -
- ) -} module.exports = function () { return get('*', async ctx => { const path = getPathWithNoTrailingSlash(ctx.path) - const page = await getPage(path) - if (page) { + const body = await renderPage(path) + if (body) { ctx.type = 'text/html' - ctx.body = await render( - path, - getComponent(page), - getPageMeta(page), - {menuPadding: true}, - ) + ctx.body = body } else { ctx.status = 404 } From 871a3ee279614fd0018bda523016849f2f55c909 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sat, 28 Oct 2017 20:28:23 +0300 Subject: [PATCH 352/368] [www] opa style updated --- src/3rdparty/opa.css | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/3rdparty/opa.css b/src/3rdparty/opa.css index 2135fd5b..5508bd47 100644 --- a/src/3rdparty/opa.css +++ b/src/3rdparty/opa.css @@ -14,11 +14,3 @@ opacity: 1; transform: scale(1) rotateX(0); } - -figure { - width: 100px; -} - -figure img{ - width: 100%; -} \ No newline at end of file From 1887b6265fa9fbd011e8bd4215e4cf9eb1df3464 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 29 Oct 2017 01:50:13 +0300 Subject: [PATCH 353/368] [www] /documents color yellow -> gray --- src/models/menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/menu.js b/src/models/menu.js index b9e2fd45..e7fa0cbe 100644 --- a/src/models/menu.js +++ b/src/models/menu.js @@ -62,7 +62,7 @@ export default [ { text: 'Документы', url: '/documents', - color: 'yellow', + color: 'gray', items: [ {url: '/document/*', text: ''}, ] From 7c531f93d2b34823764a64cb1de0923307323ac5 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 29 Oct 2017 01:50:30 +0300 Subject: [PATCH 354/368] [www] + /neighbors menu item --- src/models/menu.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/models/menu.js b/src/models/menu.js index e7fa0cbe..cdf32227 100644 --- a/src/models/menu.js +++ b/src/models/menu.js @@ -59,6 +59,11 @@ export default [ {url: '/album/*', text: ''}, ] }, + { + text: '«Мы соседи»', + url: '/neighbors', + color: 'yellow', + }, { text: 'Документы', url: '/documents', From ec8d18b5875ed1125e7b805181f74e3bf8374bd0 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Mon, 6 Nov 2017 17:36:50 +0300 Subject: [PATCH 355/368] [www] removed instagram code --- src/config.js | 2 -- src/core/service.js | 8 -------- 2 files changed, 10 deletions(-) delete mode 100644 src/core/service.js diff --git a/src/config.js b/src/config.js index bced6832..3df10f4a 100644 --- a/src/config.js +++ b/src/config.js @@ -31,8 +31,6 @@ export const homeUrl = protocol + host export const index = path.join(__dirname, indexFile) export const sitemapCacheTime = 600000// 600 sec - cache purge period -export const instagramToken = privateData['instagramToken'] - export const viewMain = path.join(__dirname, 'views/main.hbs') export const view404 = path.join(__dirname, 'views/404.hbs') diff --git a/src/core/service.js b/src/core/service.js deleted file mode 100644 index 64795dad..00000000 --- a/src/core/service.js +++ /dev/null @@ -1,8 +0,0 @@ -import {instagramToken} from '../config'; - -export const services = { - instagram: instagramToken -}; - -export const checkAuth = (name, token) => name in services && services[name] === token; -export const authChecker = store => (name, token) => name in store && store[name] === token; \ No newline at end of file From 396b7a6d404718baf8d0183b2370a10d098f14d0 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Mon, 6 Nov 2017 17:42:42 +0300 Subject: [PATCH 356/368] [www] config optimisation: removed private.json --- src/config.js | 24 ++---------------------- src/lib/render.js | 4 ++-- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/config.js b/src/config.js index 3df10f4a..0b4f5008 100644 --- a/src/config.js +++ b/src/config.js @@ -1,34 +1,14 @@ -import fs from 'fs' import path from 'path' -export const configFile = process.env['PRIVATE'] || 'private.json' -const privateData = JSON.parse(fs.readFileSync(configFile, 'utf-8')) - -const indexFile = process.env['INDEX'] || 'templates/main.html' export const port = process.env['PORT'] || 1800 - -const value = (name, def) => name in privateData - ? privateData[name] - : def - -const config = { - pub: './', -} - -export const dbUri = value('dbUri', 'mongodb://localhost:27017/hudozka') - -export default Object.keys(privateData) - .reduce((config, key) => { - config[key] = privateData[key] - return config -}, config) +export const dbUri = process.env['DB_URI'] || 'mongodb://localhost:27017/hudozka' export const name = 'Hudozka' export const host = 'art.shlisselburg.org' export const protocol = 'https://' export const homeUrl = protocol + host -export const index = path.join(__dirname, indexFile) +export const index = path.join(__dirname, 'templates/main.html') export const sitemapCacheTime = 600000// 600 sec - cache purge period export const viewMain = path.join(__dirname, 'views/main.hbs') diff --git a/src/lib/render.js b/src/lib/render.js index d7285691..42801734 100644 --- a/src/lib/render.js +++ b/src/lib/render.js @@ -11,13 +11,13 @@ const isEqualPate = require('../lib/url').isEqualPath const {compose, any} = require('../lib/common') const menuModel = require('../models/menu').default -const config = require('../config') +const {viewMain} = require('../config') const defaultOptions = { commentsEnabled: false, showAuthor: false, menuPadding: false, - templateFile: config.viewMain, + templateFile: viewMain, } const defaultMeta = { From 77e663a9c2de45af40e55aa536914e88bc411833 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Mon, 6 Nov 2017 17:43:06 +0300 Subject: [PATCH 357/368] [www] default port changed to 3000 --- src/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index 0b4f5008..c31a9c10 100644 --- a/src/config.js +++ b/src/config.js @@ -1,6 +1,6 @@ import path from 'path' -export const port = process.env['PORT'] || 1800 +export const port = process.env['PORT'] || 3000 export const dbUri = process.env['DB_URI'] || 'mongodb://localhost:27017/hudozka' export const name = 'Hudozka' From 70af6cc37eeeaea33888126772dbe56461726c22 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 7 Nov 2017 01:12:32 +0300 Subject: [PATCH 358/368] [www] core Config stability improvements. Config::findConfig always returns an instance of Config --- src/core/Config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/Config.js b/src/core/Config.js index 64f3352d..bb900cc9 100644 --- a/src/core/Config.js +++ b/src/core/Config.js @@ -7,7 +7,8 @@ class Config { } static async findConfig() { - return Config.findById('settings') + const config = await Config.findById('settings') + return config || new Config({}) } static async findById(id) { @@ -26,8 +27,9 @@ class Config { this.articleCardDefaultPreview = data.articleCardDefaultPreview this.collectiveImage = data.collectiveImage + const redirect = data.redirect || {} this.redirect = new Map(Object - .entries(data.redirect) + .entries(redirect) ) } } From 1b3c6fcfa126f80f41145d8cc0cde501318a1b3d Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 7 Nov 2017 01:13:16 +0300 Subject: [PATCH 359/368] [www] /collective render not fail on 404 big image --- src/render/persons.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/render/persons.js b/src/render/persons.js index 96c3f8ad..db65fbd5 100644 --- a/src/render/persons.js +++ b/src/render/persons.js @@ -72,7 +72,6 @@ async function renderCollective(path, order) { if (!config) return null const collectiveImage = await Image.findByFile(config.collectiveImage) - if (!collectiveImage) return null let teachers = await Teacher.find({hidden: false}) if (!teachers) return null @@ -80,7 +79,9 @@ async function renderCollective(path, order) { const teachersSorted = prioritySort.bind(null, [...order], t => t.id) teachers = teachersSorted(teachers) - const image = collectiveImage.getPicture(ImageArtifactType.LARGE) + const image = collectiveImage + ? collectiveImage.getPicture(ImageArtifactType.LARGE) + : null const PersonCardList = ({children}) => (
@@ -90,7 +91,9 @@ async function renderCollective(path, order) { const Component = (
- + {!image ? null : ( + + )} {teachers.map((teacher, index) => ( From b948c8962c0f46ae8100c88b99ebc8a8089607eb Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 7 Nov 2017 13:46:17 +0300 Subject: [PATCH 360/368] [Sync] image hash salt incremented --- utils/Sync/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/Sync/settings.py b/utils/Sync/settings.py index 2fd68817..b1f715d5 100644 --- a/utils/Sync/settings.py +++ b/utils/Sync/settings.py @@ -119,7 +119,7 @@ hash_salt_articles = '5' hash_salt_pages = '2' hash_salt_albums = '0' hash_salt_documents = '1' -hash_salt_images = '0' +hash_salt_images = '1' hash_salt_person = '2' provider_name = value('provider')['name'] # env('SYNC_PROVIDER', 'fs') From c3618747db772951a18762786dd15bbfd98e87f1 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 7 Nov 2017 13:46:56 +0300 Subject: [PATCH 361/368] [Sync] Image url factory generates lower cased file extension --- utils/Sync/sync/models/Image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/Sync/sync/models/Image.py b/utils/Sync/sync/models/Image.py index 2afec853..57efa69e 100644 --- a/utils/Sync/sync/models/Image.py +++ b/utils/Sync/sync/models/Image.py @@ -24,7 +24,7 @@ def get_upload_url(url): def default_url_factory(file, size, ext): url = settings.image_url_base + '{}-{}{}' - return url.format(md5(file), size, ext) + return url.format(md5(file), size, ext.lower()) class Image(Model): From 07e0d85f3e7f9ace32f2bcd594bd74f27c985789 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 7 Nov 2017 13:48:55 +0300 Subject: [PATCH 362/368] [www] remove configFile from config --- src/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 21f3f94f..aa8d94f2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ import 'babel-polyfill' -import {dbUri, port, name, configFile} from './config' +import {dbUri, port, name} from './config' import {connect} from './core/db' import server from './server' @@ -23,7 +23,6 @@ function main() { console.log(`Using node ${process.version}`) console.log(`App ${name} started`) console.log(`Server: ${config.server}`) - console.log(`Config file: ${configFile}`) console.log(`DB Address: ${dbUri}`) console.log(`Listening ${port}`) } From 72333475798d34924443912babc48b902adbf1b4 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 7 Nov 2017 13:49:20 +0300 Subject: [PATCH 363/368] [www] exit if mongo connection fails --- src/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index aa8d94f2..61f344ea 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,13 @@ import server from './server' function main() { async function loop() { - await connect(dbUri) + try { + await connect(dbUri) + } catch (e) { + console.error(e.message) + + process.exit(1) + } const Config = require('./core/Config') const config = await Config.findConfig() From 983fc1ef040a4f91afefb66f5df0053b73fe0611 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 3 Jan 2018 06:11:29 +0300 Subject: [PATCH 364/368] [www] config eslinted --- src/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index c31a9c10..25a913db 100644 --- a/src/config.js +++ b/src/config.js @@ -20,4 +20,4 @@ export const sessionConfig = { overwrite: false, /** (boolean) can overwrite or not */ httpOnly: false, /** (boolean) httpOnly or not */ signed: true, /** (boolean) signed or not */ -} \ No newline at end of file +} From 6ad43fa995578cdb98411b00aab03382a37c00b7 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 3 Jan 2018 06:15:48 +0300 Subject: [PATCH 365/368] [www] added Dockerfile --- Hudozka.Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Hudozka.Dockerfile diff --git a/Hudozka.Dockerfile b/Hudozka.Dockerfile new file mode 100644 index 00000000..04f00de1 --- /dev/null +++ b/Hudozka.Dockerfile @@ -0,0 +1,25 @@ +# Build +FROM node:8 as build +WORKDIR /app + +COPY package.json package-lock.json gulpfile.babel.js .babelrc ./ +RUN npm i + +COPY src ./src +RUN npm run gulp deploy +RUN npm run out + + +# Run +FROM node:8-alpine +WORKDIR /app + +COPY package.json package-lock.json gulpfile.babel.js .babelrc ./ +RUN npm i --production + +COPY --from=build /app/out ./src +COPY --from=build /app/public ./public + +EXPOSE 3000 + +CMD npm start \ No newline at end of file From e8880ba46605beeacedfb3f027b296a7158b1ca3 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Wed, 3 Jan 2018 06:23:58 +0300 Subject: [PATCH 366/368] [www] added docker-compose.yaml --- docker-compose.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..207bb850 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: '3' +services: + app: + restart: always + build: + context: ./ + dockerfile: Hudozka.Dockerfile + ports: + - "1880:3000" + environment: + - DB_URI=${HUDOZKA_DB_URI} + From 9d6e22fac8c32bd436cabb7a30990ca9bba16a1e Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Thu, 4 Jan 2018 23:33:19 +0300 Subject: [PATCH 367/368] [www] npm start using plain node --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4dddc233..9c2eb5c4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "", "main": "src/bin/www.js", "scripts": { - "start": "babel-node src/index.js", + "start": "node src/index.js", "out": "babel src/ -d out/", "gulp": "gulp", "test": "mocha --compilers js:babel-register", From 5f108945a27f716238bf1160b4230396bb9755a9 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Thu, 4 Jan 2018 23:33:42 +0300 Subject: [PATCH 368/368] [www] version 4.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c2eb5c4..0a4c7210 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Hudozka", "private": true, - "version": "3.5.0", + "version": "4.0.0", "description": "", "main": "src/bin/www.js", "scripts": {