├── webroot ├── views │ ├── index.mustache │ ├── sidebar.mustache │ ├── page.mustache │ ├── tags.mustache │ ├── sidebar_about.mustache │ ├── sidebar_intro.mustache │ ├── index_body.mustache │ ├── admin_index.mustache │ ├── sidebar_miniposts.mustache │ ├── register.mustache │ ├── login.mustache │ ├── article_stub.mustache │ ├── header_orig.mustache │ ├── admin │ │ ├── users.mustache │ │ ├── useredit.mustache │ │ ├── site.mustache │ │ ├── social.mustache │ │ ├── pages.mustache │ │ └── pageedit.mustache │ ├── footer.mustache │ ├── sidebar_postlist.mustache │ ├── article.mustache │ ├── header.mustache │ ├── single.html │ └── index.html ├── images │ ├── logo.jpg │ ├── pic01.jpg │ ├── pic02.jpg │ ├── pic03.jpg │ ├── pic04.jpg │ ├── pic05.jpg │ ├── pic06.jpg │ ├── pic07.jpg │ ├── pic08.jpg │ ├── pic09.jpg │ ├── pic10.jpg │ ├── pic11.jpg │ ├── pic12.jpg │ └── avatar.jpg ├── assets │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── css │ │ ├── ie8.css │ │ ├── ie9.css │ │ └── font-awesome.min.css │ └── js │ │ ├── ie │ │ ├── html5shiv.js │ │ └── respond.min.js │ │ ├── main.js │ │ ├── skel.min.js │ │ └── util.js └── styles │ └── admin.css ├── config └── ApplicationConfiguration.json ├── Dockerfile ├── README.md ├── Sources ├── Routes.swift ├── Components.swift ├── AppCredentials.swift ├── Setup.swift ├── Site.swift ├── AdminRoutes.swift ├── main.swift ├── AdminHandlersUsers.swift ├── AdminHandlers.swift ├── Handlers.swift ├── AdminHandlersPages.swift └── Pages.swift ├── Package.swift ├── .gitignore └── LICENSE /webroot/views/index.mustache: -------------------------------------------------------------------------------- 1 | {{>header}} 2 | {{>index_body}} 3 | {{>sidebar}} 4 | {{>footer}} 5 | -------------------------------------------------------------------------------- /webroot/images/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/logo.jpg -------------------------------------------------------------------------------- /webroot/images/pic01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic01.jpg -------------------------------------------------------------------------------- /webroot/images/pic02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic02.jpg -------------------------------------------------------------------------------- /webroot/images/pic03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic03.jpg -------------------------------------------------------------------------------- /webroot/images/pic04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic04.jpg -------------------------------------------------------------------------------- /webroot/images/pic05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic05.jpg -------------------------------------------------------------------------------- /webroot/images/pic06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic06.jpg -------------------------------------------------------------------------------- /webroot/images/pic07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic07.jpg -------------------------------------------------------------------------------- /webroot/images/pic08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic08.jpg -------------------------------------------------------------------------------- /webroot/images/pic09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic09.jpg -------------------------------------------------------------------------------- /webroot/images/pic10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic10.jpg -------------------------------------------------------------------------------- /webroot/images/pic11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic11.jpg -------------------------------------------------------------------------------- /webroot/images/pic12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/pic12.jpg -------------------------------------------------------------------------------- /webroot/images/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/images/avatar.jpg -------------------------------------------------------------------------------- /webroot/assets/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/assets/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /webroot/assets/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/assets/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /webroot/assets/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/assets/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /webroot/assets/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/assets/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /webroot/assets/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectServers/SwiftBlog/HEAD/webroot/assets/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /webroot/views/sidebar.mustache: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {{#components}}{{#googleanalytics?}} 23 | 33 | {{/googleanalytics?}}{{/components}} 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /webroot/views/admin/social.mustache: -------------------------------------------------------------------------------- 1 | {{>../header}} 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 |

Site Social Media Links & Analytics

10 | 11 |
12 | 13 |
14 | Twitter:
15 | 16 |
17 | 18 |
19 | Facebook:
20 | 21 |
22 | 23 |
24 | Instagram:
25 | 26 |
27 | 28 |
29 | Email:
30 | 31 |
32 | 33 |
34 | 35 |
36 | Disqus:
37 | 38 |
39 | 40 | 41 |
42 | 43 |
44 | Google Analytics Code:
45 | 46 |
47 | 48 |
49 | Google Tag Manager Code:
50 | 51 |
52 | 53 | 54 |
55 | 56 |
57 |
58 | 59 |
60 | {{>../sidebar}} 61 | {{>../footer}} 62 | 63 | -------------------------------------------------------------------------------- /webroot/views/sidebar_postlist.mustache: -------------------------------------------------------------------------------- 1 | 2 |
3 | 50 |
51 | -------------------------------------------------------------------------------- /webroot/assets/css/ie9.css: -------------------------------------------------------------------------------- 1 | /* 2 | Future Imperfect by HTML5 UP 3 | html5up.net | @ajlkn 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* List */ 8 | 9 | ul.posts article:after { 10 | clear: both; 11 | content: ''; 12 | display: block; 13 | } 14 | 15 | ul.posts article .image { 16 | display: table-cell; 17 | vertical-align: top; 18 | } 19 | 20 | ul.posts article header { 21 | display: table-cell; 22 | padding-right: 1em; 23 | vertical-align: top; 24 | } 25 | 26 | /* Author */ 27 | 28 | .author .name { 29 | display: inline-block; 30 | vertical-align: middle; 31 | } 32 | 33 | .author img { 34 | display: inline-block; 35 | vertical-align: middle; 36 | } 37 | 38 | /* Post */ 39 | 40 | .post:after { 41 | clear: both; 42 | content: ''; 43 | display: block; 44 | } 45 | 46 | .post > header:after { 47 | clear: both; 48 | content: ''; 49 | display: block; 50 | } 51 | 52 | .post > header .title { 53 | display: table-cell; 54 | vertical-align: top; 55 | width: 65%; 56 | } 57 | 58 | .post > header .meta { 59 | display: table-cell; 60 | vertical-align: top; 61 | width: 30%; 62 | } 63 | 64 | .post > footer:after { 65 | clear: both; 66 | content: ''; 67 | display: block; 68 | } 69 | 70 | .post > footer .actions { 71 | display: inline-block; 72 | } 73 | 74 | .post > footer .stats { 75 | display: inline-block; 76 | margin-left: 2em; 77 | } 78 | 79 | /* Mini Post */ 80 | 81 | .mini-post .image { 82 | display: block; 83 | } 84 | 85 | /* Header */ 86 | 87 | #header:after { 88 | clear: both; 89 | content: ''; 90 | display: block; 91 | } 92 | 93 | #header h1 { 94 | float: left; 95 | } 96 | 97 | #header .links { 98 | float: left; 99 | } 100 | 101 | #header .main { 102 | position: absolute; 103 | right: 0; 104 | top: 0; 105 | } 106 | 107 | /* Wrapper */ 108 | 109 | /* Sidebar */ 110 | 111 | #sidebar { 112 | display: table-cell; 113 | margin-right: 0; 114 | padding-right: 3em; 115 | vertical-align: top; 116 | } 117 | 118 | /* Main */ 119 | 120 | #main { 121 | display: table-cell; 122 | vertical-align: top; 123 | } -------------------------------------------------------------------------------- /webroot/views/admin/pages.mustache: -------------------------------------------------------------------------------- 1 | {{>../header}} 2 | 3 | 4 | 5 | 6 |
7 | 8 |

{{pagename}} 9 | 10 |

11 | 12 | 13 | 16 | 19 | 22 | 25 | 28 | 29 | 30 | {{#pages}} 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | {{/pages}} 41 | 42 |
14 | Page Name 15 | 17 | URL 18 | 20 | Type 21 | 23 | Date Published 24 | 26 | State 27 |
{{name}}{{url}}{{type}}{{datepublished}}{{state}}ConfigDelete
43 | 44 | 45 |
46 | 79 | 80 | 81 | {{>../sidebar}} 82 | {{>../footer}} 83 | 84 | -------------------------------------------------------------------------------- /webroot/views/admin/pageedit.mustache: -------------------------------------------------------------------------------- 1 | {{>../header}} 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 |

{{pagename}}

10 | 11 |
12 | 13 |
14 | Page Name:
15 | 16 |
17 |
18 | Page URL:
19 | 20 |
21 |
22 | Type:
23 | 29 |
30 |
31 | Subhead:
32 | 33 |
34 |
35 | Date Published:
36 | 37 |
38 | 39 |
40 | Hero Image:
41 | 42 |
43 | 44 |
45 | Hero Image Alt Text:
46 | 47 |
48 | 49 |
50 | Tags:
51 | 52 |
53 |
54 | Page Script:
55 | 56 |
57 | 58 | 59 |
60 | Intro:
61 | 62 |
63 | 64 |
65 | Meta Description:
66 | 67 |
68 | 69 | 70 |
71 | 72 |
73 |
74 | 75 |
76 | {{>../sidebar}} 77 | {{>../footer}} 78 | 79 | -------------------------------------------------------------------------------- /webroot/assets/js/ie/html5shiv.js: -------------------------------------------------------------------------------- 1 | /* 2 | HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); 5 | a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; 6 | c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| 7 | "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video",version:"3.6.2",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment(); 8 | for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d Routes { 8 | var routes = Routes() 9 | 10 | routes.add(method: .get, uri: "/admin/login", handler: BlogAdmin.makeLogin) 11 | routes.add(method: .get, uri: "/admin/logout", handler: AuthHandlersWeb.logoutHandler) 12 | 13 | 14 | // Site 15 | routes.add(method: .get, uri: "/admin/site", handler: BlogAdmin.siteAdmin) 16 | routes.add(method: .post, uri: "/admin/site", handler: BlogAdmin.siteAdmin) 17 | 18 | routes.add(method: .get, uri: "/admin/social", handler: BlogAdmin.siteSocial) 19 | routes.add(method: .post, uri: "/admin/social", handler: BlogAdmin.siteSocial) 20 | 21 | 22 | // Pages 23 | routes.add(method: .get, uri: "/admin/pages", handler: BlogAdmin.pagesAdmin) 24 | routes.add(method: .post, uri: "/admin/pages/saveorder", handler: BlogAdmin.pagesAdminSaveOrder) 25 | 26 | routes.add(method: .get, uri: "/admin/pages/new", handler: BlogAdmin.pagesAdminCreate) 27 | routes.add(method: .post, uri: "/admin/pages/new", handler: BlogAdmin.pagesAdminCreate) 28 | 29 | routes.add(method: .get, uri: "/admin/pages/{id}/edit", handler: BlogAdmin.pagesAdminEdit) 30 | routes.add(method: .post, uri: "/admin/pages/{id}/edit", handler: BlogAdmin.pagesAdminEdit) 31 | routes.add(method: .post, uri: "/admin/pages/{id}/save", handler: BlogAdmin.pagesAdminSaveContent) 32 | 33 | routes.add(method: .get, uri: "/admin/pages/{id}/delete", handler: BlogAdmin.pagesAdminDelete) 34 | routes.add(method: .post, uri: "/admin/pages/{id}/delete", handler: BlogAdmin.pagesAdminDelete) 35 | 36 | routes.add(method: .get, uri: "/admin/pages/{id}/toggle", handler: BlogAdmin.pagesAdminToggle) 37 | 38 | 39 | // Users 40 | routes.add(method: .get, uri: "/admin/users", handler: BlogAdmin.userAdmin) 41 | routes.add(method: .post, uri: "/admin/users", handler: BlogAdmin.userAdmin) 42 | 43 | routes.add(method: .get, uri: "/admin/users/new", handler: BlogAdmin.userAdminCreate) 44 | routes.add(method: .post, uri: "/admin/users/new", handler: BlogAdmin.userAdminCreate) 45 | 46 | routes.add(method: .get, uri: "/admin/users/{id}/edit", handler: BlogAdmin.userAdminEdit) 47 | routes.add(method: .post, uri: "/admin/users/{id}/edit", handler: BlogAdmin.userAdminEdit) 48 | 49 | routes.add(method: .get, uri: "/admin/users/{id}/delete", handler: BlogAdmin.userAdminDelete) 50 | routes.add(method: .post, uri: "/admin/users/{id}/delete", handler: BlogAdmin.userAdminDelete) 51 | 52 | 53 | return routes 54 | } 55 | -------------------------------------------------------------------------------- /webroot/views/article.mustache: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

{{name}}

5 |

{{subhead}}

6 |
7 |
8 | 9 |
10 |
11 | {{{script}}} 12 | {{#heroimage?}}{{{alt}}}{{/heroimage?}} 13 | {{#components}} 14 | 15 | {{#body?}}{{{content}}}{{/body?}} 16 | 17 | {{/components}} 18 |
19 |
    20 | {{#tags}}
  • {{tag}}
  • {{/tags}} 21 |
22 |
23 | 24 | {{#disqus?}}
25 | 39 | 40 | {{/disqus?}} 41 | 42 |
43 | 44 | 45 | {{#disqus?}}{{/disqus?}} 46 | 47 | 48 | {{#authenticated}} 49 | 50 | 51 | 92 | {{/authenticated}} 93 | -------------------------------------------------------------------------------- /webroot/assets/js/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | Future Imperfect by HTML5 UP 3 | html5up.net | @ajlkn 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | (function($) { 8 | 9 | skel.breakpoints({ 10 | xlarge: '(max-width: 1680px)', 11 | large: '(max-width: 1280px)', 12 | medium: '(max-width: 980px)', 13 | small: '(max-width: 736px)', 14 | xsmall: '(max-width: 480px)' 15 | }); 16 | 17 | $(function() { 18 | 19 | var $window = $(window), 20 | $body = $('body'), 21 | $menu = $('#menu'), 22 | $sidebar = $('#sidebar'), 23 | $main = $('#main'); 24 | 25 | // Disable animations/transitions until the page has loaded. 26 | $body.addClass('is-loading'); 27 | 28 | $window.on('load', function() { 29 | window.setTimeout(function() { 30 | $body.removeClass('is-loading'); 31 | }, 100); 32 | }); 33 | 34 | // Fix: Placeholder polyfill. 35 | $('form').placeholder(); 36 | 37 | // Prioritize "important" elements on medium. 38 | skel.on('+medium -medium', function() { 39 | $.prioritize( 40 | '.important\\28 medium\\29', 41 | skel.breakpoint('medium').active 42 | ); 43 | }); 44 | 45 | // IE<=9: Reverse order of main and sidebar. 46 | if (skel.vars.IEVersion <= 9) 47 | $main.insertAfter($sidebar); 48 | 49 | // Menu. 50 | $menu 51 | .appendTo($body) 52 | .panel({ 53 | delay: 500, 54 | hideOnClick: true, 55 | hideOnSwipe: true, 56 | resetScroll: true, 57 | resetForms: true, 58 | side: 'right', 59 | target: $body, 60 | visibleClass: 'is-menu-visible' 61 | }); 62 | 63 | // Search (header). 64 | var $search = $('#search'), 65 | $search_input = $search.find('input'); 66 | 67 | $body 68 | .on('click', '[href="#search"]', function(event) { 69 | 70 | event.preventDefault(); 71 | 72 | // Not visible? 73 | if (!$search.hasClass('visible')) { 74 | 75 | // Reset form. 76 | $search[0].reset(); 77 | 78 | // Show. 79 | $search.addClass('visible'); 80 | 81 | // Focus input. 82 | $search_input.focus(); 83 | 84 | } 85 | 86 | }); 87 | 88 | $search_input 89 | .on('keydown', function(event) { 90 | 91 | if (event.keyCode == 27) 92 | $search_input.blur(); 93 | 94 | }) 95 | .on('blur', function() { 96 | window.setTimeout(function() { 97 | $search.removeClass('visible'); 98 | }, 100); 99 | }); 100 | 101 | // Intro. 102 | var $intro = $('#intro'); 103 | 104 | // Move to main on <=large, back to sidebar on >large. 105 | skel 106 | .on('+large', function() { 107 | $intro.prependTo($main); 108 | }) 109 | .on('-large', function() { 110 | $intro.prependTo($sidebar); 111 | }); 112 | 113 | }); 114 | 115 | })(jQuery); -------------------------------------------------------------------------------- /Sources/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // SwiftBlog 4 | // PostgreSQL version 5 | // 6 | // Created by Jonathan Guthrie on 2016-11-12. 7 | // Copyright (C) 2015 PerfectlySoft, Inc. 8 | // 9 | //===----------------------------------------------------------------------===// 10 | // 11 | // This source file is part of the Perfect.org open source project 12 | // 13 | // Copyright (c) 2015 - 2016 PerfectlySoft Inc. and the Perfect project authors 14 | // Licensed under Apache License v2.0 15 | // 16 | // See http://perfect.org/licensing.html for license information 17 | // 18 | //===----------------------------------------------------------------------===// 19 | // 20 | 21 | import PerfectLib 22 | import PerfectHTTP 23 | import PerfectHTTPServer 24 | import PerfectLogger 25 | 26 | import StORM 27 | import PostgresStORM 28 | import PerfectTurnstilePostgreSQL 29 | import PerfectRequestLogger 30 | import TurnstilePerfect 31 | 32 | //StORMdebug = true 33 | 34 | let pturnstile = TurnstilePerfectRealm() 35 | 36 | let webRoot = "./webroot" 37 | 38 | LogFile.location = "./log.txt" 39 | 40 | LogFile.info("Starting SwiftBlog") 41 | 42 | #if os(Linux) 43 | let fileRoot = "/perfect-deployed/swiftblog/" 44 | var httpPort = 80 45 | #else 46 | let fileRoot = "" 47 | var httpPort = 8181 48 | RequestLogFile.location = "./webLog.log" 49 | #endif 50 | 51 | LogFile.info("httpPort: \(httpPort)") 52 | 53 | 54 | let apiRoute = "/api/v1/" 55 | 56 | // set up creds 57 | makeCreds() 58 | setupSystem() 59 | 60 | // Create HTTP server. 61 | let server = HTTPServer() 62 | 63 | // Register authentication routes and handlers 64 | let authWebRoutes = makeWebAuthRoutes() 65 | 66 | // Add the routes to the server. 67 | server.addRoutes(authWebRoutes) 68 | server.addRoutes(makeRoutes()) 69 | server.addRoutes(makeAdminRoutes()) 70 | 71 | 72 | let httplogger = RequestLogger() 73 | 74 | server.setRequestFilters([(httplogger, .high)]) 75 | server.setResponseFilters([(httplogger, .low)]) 76 | 77 | 78 | 79 | // add routes to be checked for auth 80 | var authenticationConfig = AuthenticationConfig() 81 | //authenticationConfig.include("/api/v1/check") 82 | authenticationConfig.include("/admin/*") 83 | authenticationConfig.exclude("/admin/login") 84 | authenticationConfig.exclude("/admin/register") 85 | 86 | let authFilter = AuthFilter(authenticationConfig) 87 | 88 | // Note that order matters when the filters are of the same priority level 89 | server.setRequestFilters([pturnstile.requestFilter]) 90 | server.setResponseFilters([pturnstile.responseFilter]) 91 | server.setRequestFilters([(authFilter, .high)]) 92 | 93 | 94 | 95 | // Set a listen port 96 | server.serverPort = UInt16(httpPort) 97 | 98 | // Set a document root. 99 | server.documentRoot = webRoot 100 | 101 | 102 | do { 103 | LogFile.info("HTTP Server starting") 104 | // Launch the HTTP server. 105 | try server.start() 106 | } catch PerfectError.networkError(let err, let msg) { 107 | print("Network error thrown: \(err) \(msg)") 108 | } 109 | -------------------------------------------------------------------------------- /webroot/views/header.mustache: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | {{#components}}{{#gtmcode?}} 10 | 11 | 16 | 17 | {{/gtmcode?}}{{/components}} 18 | 19 | 20 | {{title}} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | {{#components}}{{#gtmcode?}} 34 | 35 | 37 | 38 | {{/gtmcode?}}{{/components}} 39 | 40 | 41 |
42 | 43 | 44 | 69 | 70 | 71 | 117 | -------------------------------------------------------------------------------- /webroot/assets/js/ie/respond.min.js: -------------------------------------------------------------------------------- 1 | /*! Respond.js v1.4.2: min/max-width media query polyfill 2 | * Copyright 2014 Scott Jehl 3 | * Licensed under MIT 4 | * http://j.mp/respondjs */ 5 | 6 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b AuthAccount { 29 | let random: Random = URandom() 30 | var state = false // means it's a save not a create 31 | if user.uniqueID.isEmpty() { 32 | user.uniqueID = String(random.secureToken) 33 | state = true // new user 34 | } 35 | user.username = request.param(name: "username", defaultValue: "-")! 36 | user.email = request.param(name: "email", defaultValue: "")! 37 | user.firstname = request.param(name: "firstname", defaultValue: "")! 38 | user.lastname = request.param(name: "lastname", defaultValue: "")! 39 | 40 | let p1 = request.param(name: "password", defaultValue: ".")! 41 | let p2 = request.param(name: "password2", defaultValue: "..")! 42 | 43 | if !p1.isEmpty && p1 == p2 { 44 | user.password = BCrypt.hash(password: p1) 45 | } 46 | 47 | if user.username == "-" { 48 | return user 49 | } 50 | 51 | 52 | do { 53 | if state { 54 | try user.create() 55 | } else { 56 | try user.save() 57 | } 58 | BlogAdmin.returnToUserList(request: request, response) 59 | } catch { 60 | print("Save Edit user id \(user.id) error - cannot save user: \(error)") 61 | } 62 | return user 63 | } 64 | 65 | static func userAdmin(request: HTTPRequest, _ response: HTTPResponse) { 66 | 67 | let users = AuthAccount() 68 | try? users.select(whereclause: "", params: [], orderby: ["username"]) 69 | var userArray = [[String: Any]]() 70 | 71 | let articles = Page() 72 | for row in users.rows() { 73 | var r = [String: Any]() 74 | r["uniqueID"] = row.uniqueID 75 | r["username"] = row.username 76 | r["firstname"] = row.firstname 77 | r["lastname"] = row.lastname 78 | r["email"] = row.email 79 | 80 | userArray.append(r) 81 | } 82 | 83 | 84 | let context: [String : Any] = [ 85 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 86 | "authenticated": request.user.authenticated, 87 | "token": request.user.authDetails?.sessionID ?? "", 88 | "title": (site.config["title"] ?? "") as! String, 89 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 90 | "pagename": "User Admin", 91 | "components": BlogAdmin.componentList(0), 92 | "articles": articles.getArticles(), 93 | "users": userArray 94 | ] 95 | 96 | response.render(template: "admin/users", context: context) 97 | } 98 | 99 | 100 | static func userAdminCreate(request: HTTPRequest, _ response: HTTPResponse) { 101 | let articles = Page() 102 | 103 | // save component... 104 | var user = AuthAccount() 105 | if request.method == .post { 106 | user.uniqueID = "" 107 | user = BlogAdmin.saveUserData(request, response, user: user) 108 | } 109 | // end save compoennt 110 | 111 | 112 | let context: [String : Any] = [ 113 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 114 | "authenticated": request.user.authenticated, 115 | "title": (site.config["title"] ?? "") as! String, 116 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 117 | "pagename": "New User", 118 | "components": BlogAdmin.componentList(0), 119 | "articles": articles.getArticles(), 120 | 121 | "username": user.username, 122 | "email": user.email, 123 | "firstname": user.firstname, 124 | "lastname": user.lastname 125 | 126 | ] 127 | 128 | response.render(template: "admin/useredit", context: context) 129 | 130 | } 131 | 132 | static func userAdminEdit(request: HTTPRequest, _ response: HTTPResponse) { 133 | 134 | let articles = Page() 135 | 136 | var user = AuthAccount() 137 | let id = request.urlVariables["id"] ?? "" 138 | do { 139 | try user.get(id) 140 | } catch { 141 | print("Edit user id \(id) error - cannot load user: \(error)") 142 | } 143 | 144 | // save component... 145 | if request.method == .post { 146 | user = BlogAdmin.saveUserData(request, response, user: user) 147 | } 148 | // end save compoennt 149 | 150 | 151 | let context: [String : Any] = [ 152 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 153 | "authenticated": request.user.authenticated, 154 | "title": (site.config["title"] ?? "") as! String, 155 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 156 | "pagename": "Edit User", 157 | "components": BlogAdmin.componentList(0), 158 | "articles": articles.getArticles(), 159 | 160 | "username": user.username, 161 | "email": user.email, 162 | "firstname": user.firstname, 163 | "lastname": user.lastname 164 | ] 165 | response.render(template: "admin/useredit", context: context) 166 | 167 | } 168 | 169 | static func userAdminDelete(request: HTTPRequest, _ response: HTTPResponse) { 170 | 171 | let user = AuthAccount() 172 | let id = request.urlVariables["id"] ?? "" 173 | do { 174 | try user.delete(id) 175 | } catch { 176 | print("Deleting user id \(id) error - cannot delete user: \(error)") 177 | } 178 | 179 | BlogAdmin.returnToUserList(request: request, response) 180 | 181 | } 182 | 183 | 184 | 185 | } 186 | -------------------------------------------------------------------------------- /Sources/AdminHandlers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AdminHandlers.swift 3 | // SwiftBlog 4 | // 5 | // Created by Jonathan Guthrie on 2016-11-14. 6 | // 7 | // 8 | 9 | import PerfectHTTP 10 | import StORM 11 | import PostgresStORM 12 | 13 | class BlogAdmin { 14 | 15 | static func componentList(_ pageid: Int) -> [[String: Any]] { 16 | var componentArray = [[String: Any]]() 17 | let components = Component() 18 | do { 19 | // gets all generic compoennts (pageid 0) 20 | try components.select(columns: [], whereclause: "pageid = $1", params: [pageid], orderby: []) 21 | 22 | // process incoming array of data 23 | for row in components.rows() { 24 | if row.content.isEmpty == false { 25 | var r = [String: Any]() 26 | r["\(row.spot)?"] = ["content":row.content] 27 | componentArray.append(r) 28 | } 29 | } 30 | // set array of data to the highscores property 31 | } catch { 32 | print(error) 33 | } 34 | 35 | return componentArray 36 | } 37 | 38 | static func makeLogin(request: HTTPRequest, _ response: HTTPResponse) { 39 | let page = Page() 40 | // set the cursor (number of results to return, and offset from start) 41 | let pageCursor = StORMCursor(limit: 1, offset: 0) 42 | 43 | do { 44 | try page.select(columns: [], whereclause: "url = $1", params: ["/"], orderby: [], cursor: pageCursor) 45 | } catch { 46 | print(error) 47 | } 48 | 49 | let componentArray = BlogAdmin.componentList(0) 50 | 51 | let articles = Page() 52 | let articleArray = articles.getArticles() 53 | 54 | let context: [String : Any] = [ 55 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 56 | "authenticated": request.user.authenticated, 57 | "title": (site.config["title"] ?? "") as! String, 58 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 59 | "pagename": "Login", 60 | "components": componentArray, 61 | "articles": articleArray 62 | ] 63 | 64 | response.render(template: "login",context: context) 65 | } 66 | 67 | static func siteAdmin(request: HTTPRequest, _ response: HTTPResponse) { 68 | 69 | // save component... 70 | if request.method == .post { 71 | let thisSite = Site() 72 | thisSite.id = site.id 73 | thisSite.url = request.param(name: "url", defaultValue: "Not Set")! 74 | //{"menu": [{"link": "/one", "name": "One"}, {"link": "/two", "name": "Two"}, {"link": "/dragons", "name": "Three"}], "title": "Relatable Rachel"} 75 | thisSite.config["title"] = request.param(name: "title", defaultValue: "Not Set")! 76 | 77 | 78 | let menunames = request.params(named: "menuname") 79 | let menulinks = request.params(named: "menulink") 80 | 81 | var menuOptions = [[String: String]]() 82 | for i in 0..<10 { 83 | if menunames[i].characters.count > 0 { 84 | var 85 | this = [String:String]() 86 | this["name"] = menunames[i] 87 | this["link"] = menulinks[i] 88 | menuOptions.append(this) 89 | } 90 | } 91 | // thisSite.config["menu"] = site.config["menu"] 92 | thisSite.config["menu"] = menuOptions 93 | try? thisSite.save() 94 | 95 | // also need to save subhead component 96 | let sub = Component() 97 | var opts = [(String,Any)]() 98 | opts.append(("spot","subhead")) 99 | opts.append(("pageid",0)) 100 | try? sub.find(opts) 101 | sub.content = request.param(name: "subhead", defaultValue: "Not Set")! 102 | try? sub.save() 103 | 104 | // also need to save about 105 | let about = Component() 106 | var optsAbout = [(String,Any)]() 107 | optsAbout.append(("spot","about")) 108 | optsAbout.append(("pageid",0)) 109 | try? about.find(optsAbout) 110 | about.content = request.param(name: "about", defaultValue: "Not Set")! 111 | try? about.save() 112 | 113 | site.getSiteInfo() 114 | } 115 | // end save compoennt 116 | 117 | 118 | let componentArray = BlogAdmin.componentList(0) 119 | 120 | let articles = Page() 121 | let articleArray = articles.getArticles() 122 | 123 | var menu = [[String:String]]() 124 | if let _ = site.config["menu"] { 125 | for ob in site.config["menu"] as! [[String:String]] { 126 | menu.append(ob) 127 | } 128 | for _ in menu.count..<10 { 129 | menu.append(["link":"","name":""]) 130 | } 131 | } 132 | let context: [String : Any] = [ 133 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 134 | "authenticated": request.user.authenticated, 135 | "title": (site.config["title"] ?? "") as! String, 136 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 137 | "menudata": menu, 138 | "url": site.url, 139 | "pagename": "Site Admin", 140 | "components": componentArray, 141 | "articles": articleArray 142 | ] 143 | 144 | response.render(template: "admin/site", context: context) 145 | } 146 | 147 | static func siteSocial(request: HTTPRequest, _ response: HTTPResponse) { 148 | 149 | // save component... 150 | if request.method == .post { 151 | 152 | for obj in ["twitter", "facebook", "instagram", "email", "googleanalytics", "gtmcode", "disqus"] { 153 | 154 | // also need to save subhead component 155 | let sub = Component() 156 | sub.spot = obj 157 | var opts = [(String,Any)]() 158 | opts.append(("spot",obj)) 159 | opts.append(("pageid",0)) 160 | try? sub.find(opts) 161 | sub.content = request.param(name: obj, defaultValue: "Not Set")! 162 | try? sub.save() 163 | 164 | } 165 | 166 | } 167 | // end save compoennt 168 | 169 | 170 | let componentArray = BlogAdmin.componentList(0) 171 | 172 | let articles = Page() 173 | let articleArray = articles.getArticles() 174 | 175 | 176 | let context: [String : Any] = [ 177 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 178 | "authenticated": request.user.authenticated, 179 | "title": (site.config["title"] ?? "") as! String, 180 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 181 | "pagename": "Site Social & Analytics", 182 | "components": componentArray, 183 | "articles": articleArray 184 | ] 185 | 186 | response.render(template: "admin/social", context: context) 187 | } 188 | 189 | 190 | 191 | 192 | } 193 | -------------------------------------------------------------------------------- /webroot/views/single.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Single - Future Imperfect by HTML5 UP 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 48 | 49 | 50 | 97 | 98 | 99 |
100 | 101 | 102 |
103 |
104 |
105 |

Magna sed adipiscing

106 |

Lorem ipsum dolor amet nullam consequat etiam feugiat

107 |
108 |
109 | 110 | Jane Doe 111 |
112 |
113 | 114 |

Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl. Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper. Praesent tincidunt sed tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla.

115 |

Nunc quis dui scelerisque, scelerisque urna ut, dapibus orci. Sed vitae condimentum lectus, ut imperdiet quam. Maecenas in justo ut nulla aliquam sodales vel at ligula. Sed blandit diam odio, sed fringilla lectus molestie sit amet. Praesent eu tortor viverra lorem mattis pulvinar feugiat in turpis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce ullamcorper tellus sit amet mattis dignissim. Phasellus ut metus ligula. Curabitur nec leo turpis. Ut gravida purus quis erat pretium, sed pellentesque massa elementum. Fusce vestibulum porta augue, at mattis justo. Integer sed sapien fringilla, dapibus risus id, faucibus ante. Pellentesque mattis nunc sit amet tortor pellentesque, non placerat neque viverra.

116 | 123 |
124 | 125 |
126 | 127 | 128 | 138 | 139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /Sources/Handlers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Handlers.swift 3 | // SwiftBlog 4 | // 5 | // Created by Jonathan Guthrie on 2016-11-12. 6 | // 7 | // 8 | 9 | import PerfectHTTP 10 | import StORM 11 | import PostgresStORM 12 | import SwiftString 13 | import PerfectLogger 14 | 15 | class PageHandlers { 16 | 17 | static func makeHome(request: HTTPRequest, _ response: HTTPResponse) { 18 | // set up container object for results 19 | let page = Page() 20 | let components = Component() 21 | // set the cursor (number of results to return, and offset from start) 22 | let pageCursor = StORMCursor(limit: 1, offset: 0) 23 | 24 | var componentArray = [[String: Any]]() 25 | do { 26 | try page.select(columns: [], whereclause: "url = $1", params: ["/"], orderby: [], cursor: pageCursor) 27 | } catch { 28 | print(error) 29 | } 30 | var disqus = "" 31 | do { 32 | // gets all generic compoennts (pageid 0) 33 | try components.select(columns: [], whereclause: "pageid = $1", params: [0], orderby: []) 34 | 35 | // process incoming array of data 36 | for row in components.rows() { 37 | var r = [String: Any]() 38 | r["\(row.spot)?"] = ["content":row.content] 39 | componentArray.append(r) 40 | 41 | if row.spot == "disqus" { 42 | disqus = row.content 43 | } 44 | } 45 | // set array of data to the highscores property 46 | } catch { 47 | print(error) 48 | } 49 | 50 | let articles = Page() 51 | let articleArray = articles.getArticles() 52 | 53 | let homeArticle = Page() 54 | let thisArticle = homeArticle.getPage(link: "", isArticle: true) 55 | 56 | let contextAccountID = request.user.authDetails?.account.uniqueID ?? "" 57 | 58 | let contextAuthenticated = request.user.authenticated 59 | 60 | let contextTitle = "\(site.config["title"] ?? "No Title Defined")" 61 | 62 | var contextMenu = [Any]() 63 | if let contextMenuis = site.config["menu"] { 64 | contextMenu = contextMenuis as! [Any] 65 | } 66 | 67 | var context: [String : Any] = [ 68 | "accountID": contextAccountID, 69 | "authenticated": contextAuthenticated, 70 | "title": contextTitle, 71 | "menu": contextMenu, 72 | "siteurl": site.url, 73 | "pagename": page.name, 74 | "components": componentArray, 75 | "articles": articleArray, 76 | "featured": thisArticle 77 | ] 78 | 79 | if !disqus.isEmpty { 80 | context["disqus?"] = ["content":disqus, "link":homeArticle.url] 81 | } 82 | 83 | response.render(template: "index", context: context) 84 | } 85 | 86 | 87 | static func makePage(request: HTTPRequest, _ response: HTTPResponse) { 88 | 89 | // set up container object for results 90 | let page = Page() 91 | let components = Component() 92 | // set the cursor (number of results to return, and offset from start) 93 | let pageCursor = StORMCursor(limit: 1, offset: 0) 94 | 95 | let pageid = request.urlVariables["pageid"] ?? "" 96 | 97 | 98 | var componentArray = [[String: Any]]() 99 | do { 100 | try page.select(columns: [], whereclause: "url = $1", params: [pageid], orderby: [], cursor: pageCursor) 101 | } catch { 102 | print(error) 103 | } 104 | var disqus = "" 105 | do { 106 | // gets all generic compoennts (pageid 0) 107 | try components.select(columns: [], whereclause: "pageid = $1", params: [0], orderby: []) 108 | 109 | // process incoming array of data 110 | for row in components.rows() { 111 | var r = [String: Any]() 112 | r["\(row.spot)?"] = ["content":row.content] 113 | componentArray.append(r) 114 | 115 | if row.spot == "disqus" { 116 | disqus = row.content 117 | } 118 | 119 | } 120 | } catch { 121 | print(error) 122 | } 123 | if page.id == 0 { 124 | var r = [String: Any]() 125 | r["body?"] = ["content":"Page not found"] 126 | // Set 404 127 | response.status = .notFound 128 | componentArray.append(r) 129 | } 130 | let articles = Page() 131 | let articleArray = articles.getArticles() 132 | 133 | 134 | var context: [String : Any] = [ 135 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 136 | "token": request.user.authDetails?.sessionID ?? "", 137 | "authenticated": request.user.authenticated, 138 | "title": (site.config["title"] ?? "") as! String, 139 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 140 | "siteurl": site.url, 141 | "pagename": page.name, 142 | "components": componentArray, 143 | "articles": articleArray, 144 | "page": page.getPageData() 145 | ] 146 | if !disqus.isEmpty { 147 | context["disqus?"] = ["content":disqus, "link":page.url] 148 | } 149 | response.render(template: "page", context: context) 150 | } 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | static func makeTagPage(request: HTTPRequest, _ response: HTTPResponse) { 159 | 160 | // set up container object for results 161 | let page = Page() 162 | let components = Component() 163 | // set the cursor (number of results to return, and offset from start) 164 | let pageCursor = StORMCursor(limit: 100, offset: 0) 165 | 166 | var tag = request.urlVariables["tag"] ?? "" 167 | tag = tag.stringByReplacing(string: "%20", withString: " ") 168 | 169 | // main search 170 | do { 171 | try page.select(columns: [], whereclause: "config @> '{\"tags\": [{\"tag\": \"\(tag.latinize())\"}]}'::jsonb AND state = $1", params: ["true"], orderby: [], cursor: pageCursor) 172 | } catch { 173 | print(error) 174 | } 175 | 176 | // sidebar components 177 | var componentArray = [[String: Any]]() 178 | do { 179 | // gets all generic compoennts (pageid 0) 180 | try components.select(columns: [], whereclause: "pageid = $1", params: [0], orderby: []) 181 | 182 | // process incoming array of data 183 | for row in components.rows() { 184 | var r = [String: Any]() 185 | r["\(row.spot)?"] = ["content":row.content] 186 | componentArray.append(r) 187 | } 188 | } catch { 189 | print(error) 190 | } 191 | let articles = Page() 192 | let articleArray = articles.getArticles() 193 | 194 | 195 | let context: [String : Any] = [ 196 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 197 | "token": request.user.authDetails?.sessionID ?? "", 198 | "authenticated": request.user.authenticated, 199 | "title": (site.config["title"] ?? "") as! String, 200 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 201 | "siteurl": site.url, 202 | "pagename": page.name, 203 | "components": componentArray, 204 | "articles": articleArray, 205 | "pages": page.toStub() 206 | ] 207 | response.render(template: "tags", context: context) 208 | } 209 | 210 | } 211 | 212 | -------------------------------------------------------------------------------- /Sources/AdminHandlersPages.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AdminHandlers.swift 3 | // SwiftBlog 4 | // 5 | // Created by Jonathan Guthrie on 2016-11-14. 6 | // 7 | // 8 | 9 | import PerfectHTTP 10 | import StORM 11 | import PostgresStORM 12 | import SwiftString 13 | 14 | extension BlogAdmin { 15 | 16 | static func returnToList(request: HTTPRequest, _ response: HTTPResponse) { 17 | // set the HTTP Response status to "302", a temporary redirect 18 | response.status = .found 19 | // set the location for the redirect 20 | response.setHeader(.location, value: "/admin/pages") 21 | 22 | 23 | // Signalling that the request is completed 24 | response.completed() 25 | 26 | } 27 | 28 | static func savePageData(_ request: HTTPRequest, _ response: HTTPResponse, page: Page) { 29 | page.url = request.param(name: "url", defaultValue: "Not Set")! 30 | page.name = request.param(name: "pagename", defaultValue: "Not Set")! 31 | 32 | for opt in ["type", "intro", "subhead", "datepublished", "metadescription", "script", "heroimage", "heroimagealt"] { 33 | page.config[opt] = request.param(name: opt, defaultValue: "")! 34 | } 35 | 36 | 37 | let tags = request.param(name: "tags", defaultValue: "")! 38 | let taglist = tags.split(",") 39 | var tagassembled = [[String:String]]() 40 | for tag in taglist { 41 | if !tag.trimmed().isEmpty { 42 | tagassembled.append(["tag":tag.trimmed()]) 43 | } 44 | } 45 | page.config["tags"] = tagassembled 46 | do { 47 | try page.save() 48 | BlogAdmin.returnToList(request: request, response) 49 | } catch { 50 | print("Save Edit page id \(page.id) error - cannot save page: \(error)") 51 | } 52 | 53 | } 54 | 55 | 56 | static func pagesAdminSaveOrder(request: HTTPRequest, _ response: HTTPResponse) { 57 | 58 | let orders = request.params(named: "sort") 59 | 60 | let aPage = Page() 61 | var orderN = 1 62 | for p in orders { 63 | _ = try? aPage.sql("UPDATE page SET displayorder = $1 WHERE id = $2", params: [String(orderN),p]) 64 | orderN += 1 65 | } 66 | 67 | // return JSON data to client 68 | do { 69 | try response.setBody(json: ["order":"complete"]) 70 | } catch { 71 | print(error) 72 | } 73 | response.completed() 74 | 75 | } 76 | 77 | 78 | static func pagesAdmin(request: HTTPRequest, _ response: HTTPResponse) { 79 | 80 | let articles = Page() 81 | let pages = Page() 82 | 83 | let context: [String : Any] = [ 84 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 85 | "authenticated": request.user.authenticated, 86 | "token": request.user.authDetails?.sessionID ?? "", 87 | "title": (site.config["title"] ?? "") as! String, 88 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 89 | "pagename": "Pages Admin", 90 | "components": BlogAdmin.componentList(0), 91 | "articles": articles.getArticles(), 92 | "pages": pages.pageList() 93 | ] 94 | 95 | response.render(template: "admin/pages", context: context) 96 | 97 | } 98 | 99 | static func pagesAdminCreate(request: HTTPRequest, _ response: HTTPResponse) { 100 | 101 | let articles = Page() 102 | 103 | // save component. 104 | if request.method == .post { 105 | let page = Page() 106 | BlogAdmin.savePageData(request, response, page: page) 107 | } 108 | // end save compoennt 109 | 110 | 111 | let context: [String : Any] = [ 112 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 113 | "authenticated": request.user.authenticated, 114 | "title": (site.config["title"] ?? "") as! String, 115 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 116 | "pagename": "New Page", 117 | "components": BlogAdmin.componentList(0), 118 | "articles": articles.getArticles() 119 | ] 120 | 121 | response.render(template: "admin/pageedit", context: context) 122 | 123 | } 124 | 125 | static func pagesAdminEdit(request: HTTPRequest, _ response: HTTPResponse) { 126 | 127 | let articles = Page() 128 | 129 | let page = Page() 130 | let id = request.urlVariables["id"] ?? "" 131 | do { 132 | try page.get(id) 133 | } catch { 134 | print("Edit page id \(id) error - cannot load page: \(error)") 135 | } 136 | 137 | // save component. 138 | if request.method == .post { 139 | BlogAdmin.savePageData(request, response, page: page) 140 | } 141 | // end save compoennt 142 | 143 | 144 | var context: [String : Any] = [ 145 | "accountID": request.user.authDetails?.account.uniqueID ?? "", 146 | "authenticated": request.user.authenticated, 147 | "title": (site.config["title"] ?? "") as! String, 148 | "menu": (site.config["menu"] ?? [Any]()) as! [Any], 149 | "pagename": "Edit Page", 150 | "components": BlogAdmin.componentList(0), 151 | "articles": articles.getArticles(), 152 | 153 | "id": id, 154 | "name": page.name, 155 | "url": page.url, 156 | "config": page.config 157 | ] 158 | if let obj = page.config["type"] { 159 | if obj as! String == "article" { 160 | context["isArticle"] = "selected=\"selected\"" 161 | } else if obj as! String == "general" { 162 | context["isGeneral"] = "selected=\"selected\"" 163 | } else { 164 | context["isUnspecified"] = "selected=\"selected\"" 165 | } 166 | } 167 | 168 | response.render(template: "admin/pageedit", context: context) 169 | 170 | } 171 | 172 | static func pagesAdminDelete(request: HTTPRequest, _ response: HTTPResponse) { 173 | 174 | let page = Page() 175 | let id = request.urlVariables["id"] ?? "" 176 | do { 177 | try page.delete(id) 178 | } catch { 179 | print("Deleting page id \(id) error - cannot delete page: \(error)") 180 | } 181 | 182 | BlogAdmin.returnToList(request: request, response) 183 | 184 | } 185 | 186 | static func pagesAdminToggle(request: HTTPRequest, _ response: HTTPResponse) { 187 | 188 | let page = Page() 189 | let id = request.urlVariables["id"] ?? "" 190 | do { 191 | try page.get(id) 192 | if page.state == true { page.state = false } else { page.state = true } 193 | try page.save() 194 | } catch { 195 | print("Toggling page id \(id) error - cannot load page: \(error)") 196 | } 197 | 198 | BlogAdmin.returnToList(request: request, response) 199 | } 200 | 201 | static func pagesAdminSaveContent(request: HTTPRequest, _ response: HTTPResponse) { 202 | // set the JSON content type 203 | response.setHeader(.contentType, value: "application/json") 204 | 205 | // response data container 206 | var resp = [String: Any]() 207 | 208 | 209 | // process incoming data, with protections in case the params are not supplied 210 | guard let content = request.param(name: "content") else { 211 | // set an error response to be returned 212 | response.status = .badRequest 213 | resp["error"] = "Please supply values" 214 | do { 215 | try response.setBody(json: resp) 216 | } catch { 217 | print(error) 218 | } 219 | response.completed() 220 | return 221 | } 222 | 223 | 224 | let page = Page() 225 | let id = request.urlVariables["id"] ?? "" 226 | do { 227 | try page.get(id) 228 | 229 | let sub = Component() 230 | sub.pageid = page.id 231 | sub.spot = "body" 232 | var opts = [(String,Any)]() 233 | opts.append(("spot","body")) 234 | opts.append(("pageid",page.id)) 235 | try? sub.find(opts) 236 | sub.content = content 237 | try? sub.save() 238 | resp["saved"] = "ok" 239 | 240 | } catch { 241 | print("Editing page id \(id) error - cannot load page: \(error)") 242 | resp["error"] = "\(error)" 243 | } 244 | 245 | // return JSON data to client 246 | do { 247 | try response.setBody(json: resp) 248 | } catch { 249 | print(error) 250 | } 251 | response.completed() 252 | 253 | } 254 | 255 | } 256 | -------------------------------------------------------------------------------- /webroot/assets/js/skel.min.js: -------------------------------------------------------------------------------- 1 | /* skel.js v3.0.1 | (c) skel.io | MIT licensed */ 2 | var skel=function(){"use strict";var t={breakpointIds:null,events:{},isInit:!1,obj:{attachments:{},breakpoints:{},head:null,states:{}},sd:"/",state:null,stateHandlers:{},stateId:"",vars:{},DOMReady:null,indexOf:null,isArray:null,iterate:null,matchesMedia:null,extend:function(e,n){t.iterate(n,function(i){t.isArray(n[i])?(t.isArray(e[i])||(e[i]=[]),t.extend(e[i],n[i])):"object"==typeof n[i]?("object"!=typeof e[i]&&(e[i]={}),t.extend(e[i],n[i])):e[i]=n[i]})},newStyle:function(t){var e=document.createElement("style");return e.type="text/css",e.innerHTML=t,e},_canUse:null,canUse:function(e){t._canUse||(t._canUse=document.createElement("div"));var n=t._canUse.style,i=e.charAt(0).toUpperCase()+e.slice(1);return e in n||"Moz"+i in n||"Webkit"+i in n||"O"+i in n||"ms"+i in n},on:function(e,n){var i=e.split(/[\s]+/);return t.iterate(i,function(e){var a=i[e];if(t.isInit){if("init"==a)return void n();if("change"==a)n();else{var r=a.charAt(0);if("+"==r||"!"==r){var o=a.substring(1);if(o in t.obj.breakpoints)if("+"==r&&t.obj.breakpoints[o].active)n();else if("!"==r&&!t.obj.breakpoints[o].active)return void n()}}}t.events[a]||(t.events[a]=[]),t.events[a].push(n)}),t},trigger:function(e){return t.events[e]&&0!=t.events[e].length?(t.iterate(t.events[e],function(n){t.events[e][n]()}),t):void 0},breakpoint:function(e){return t.obj.breakpoints[e]},breakpoints:function(e){function n(t,e){this.name=this.id=t,this.media=e,this.active=!1,this.wasActive=!1}return n.prototype.matches=function(){return t.matchesMedia(this.media)},n.prototype.sync=function(){this.wasActive=this.active,this.active=this.matches()},t.iterate(e,function(i){t.obj.breakpoints[i]=new n(i,e[i])}),window.setTimeout(function(){t.poll()},0),t},addStateHandler:function(e,n){t.stateHandlers[e]=n},callStateHandler:function(e){var n=t.stateHandlers[e]();t.iterate(n,function(e){t.state.attachments.push(n[e])})},changeState:function(e){t.iterate(t.obj.breakpoints,function(e){t.obj.breakpoints[e].sync()}),t.vars.lastStateId=t.stateId,t.stateId=e,t.breakpointIds=t.stateId===t.sd?[]:t.stateId.substring(1).split(t.sd),t.obj.states[t.stateId]?t.state=t.obj.states[t.stateId]:(t.obj.states[t.stateId]={attachments:[]},t.state=t.obj.states[t.stateId],t.iterate(t.stateHandlers,t.callStateHandler)),t.detachAll(t.state.attachments),t.attachAll(t.state.attachments),t.vars.stateId=t.stateId,t.vars.state=t.state,t.trigger("change"),t.iterate(t.obj.breakpoints,function(e){t.obj.breakpoints[e].active?t.obj.breakpoints[e].wasActive||t.trigger("+"+e):t.obj.breakpoints[e].wasActive&&t.trigger("-"+e)})},generateStateConfig:function(e,n){var i={};return t.extend(i,e),t.iterate(t.breakpointIds,function(e){t.extend(i,n[t.breakpointIds[e]])}),i},getStateId:function(){var e="";return t.iterate(t.obj.breakpoints,function(n){var i=t.obj.breakpoints[n];i.matches()&&(e+=t.sd+i.id)}),e},poll:function(){var e="";e=t.getStateId(),""===e&&(e=t.sd),e!==t.stateId&&t.changeState(e)},_attach:null,attach:function(e){var n=t.obj.head,i=e.element;return i.parentNode&&i.parentNode.tagName?!1:(t._attach||(t._attach=n.firstChild),n.insertBefore(i,t._attach.nextSibling),e.permanent&&(t._attach=i),!0)},attachAll:function(e){var n=[];t.iterate(e,function(t){n[e[t].priority]||(n[e[t].priority]=[]),n[e[t].priority].push(e[t])}),n.reverse(),t.iterate(n,function(e){t.iterate(n[e],function(i){t.attach(n[e][i])})})},detach:function(t){var e=t.element;return t.permanent||!e.parentNode||e.parentNode&&!e.parentNode.tagName?!1:(e.parentNode.removeChild(e),!0)},detachAll:function(e){var n={};t.iterate(e,function(t){n[e[t].id]=!0}),t.iterate(t.obj.attachments,function(e){e in n||t.detach(t.obj.attachments[e])})},attachment:function(e){return e in t.obj.attachments?t.obj.attachments[e]:null},newAttachment:function(e,n,i,a){return t.obj.attachments[e]={id:e,element:n,priority:i,permanent:a}},init:function(){t.initMethods(),t.initVars(),t.initEvents(),t.obj.head=document.getElementsByTagName("head")[0],t.isInit=!0,t.trigger("init")},initEvents:function(){t.on("resize",function(){t.poll()}),t.on("orientationChange",function(){t.poll()}),t.DOMReady(function(){t.trigger("ready")}),window.onload&&t.on("load",window.onload),window.onload=function(){t.trigger("load")},window.onresize&&t.on("resize",window.onresize),window.onresize=function(){t.trigger("resize")},window.onorientationchange&&t.on("orientationChange",window.onorientationchange),window.onorientationchange=function(){t.trigger("orientationChange")}},initMethods:function(){document.addEventListener?!function(e,n){t.DOMReady=n()}("domready",function(){function t(t){for(r=1;t=n.shift();)t()}var e,n=[],i=document,a="DOMContentLoaded",r=/^loaded|^c/.test(i.readyState);return i.addEventListener(a,e=function(){i.removeEventListener(a,e),t()}),function(t){r?t():n.push(t)}}):!function(e,n){t.DOMReady=n()}("domready",function(t){function e(t){for(h=1;t=i.shift();)t()}var n,i=[],a=!1,r=document,o=r.documentElement,s=o.doScroll,c="DOMContentLoaded",d="addEventListener",u="onreadystatechange",l="readyState",f=s?/^loaded|^c/:/^loaded|c/,h=f.test(r[l]);return r[d]&&r[d](c,n=function(){r.removeEventListener(c,n,a),e()},a),s&&r.attachEvent(u,n=function(){/^c/.test(r[l])&&(r.detachEvent(u,n),e())}),t=s?function(e){self!=top?h?e():i.push(e):function(){try{o.doScroll("left")}catch(n){return setTimeout(function(){t(e)},50)}e()}()}:function(t){h?t():i.push(t)}}),Array.prototype.indexOf?t.indexOf=function(t,e){return t.indexOf(e)}:t.indexOf=function(t,e){if("string"==typeof t)return t.indexOf(e);var n,i,a=e?e:0;if(!this)throw new TypeError;if(i=this.length,0===i||a>=i)return-1;for(0>a&&(a=i-Math.abs(a)),n=a;i>n;n++)if(this[n]===t)return n;return-1},Array.isArray?t.isArray=function(t){return Array.isArray(t)}:t.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},Object.keys?t.iterate=function(t,e){if(!t)return[];var n,i=Object.keys(t);for(n=0;i[n]&&e(i[n],t[i[n]])!==!1;n++);}:t.iterate=function(t,e){if(!t)return[];var n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])===!1)break},window.matchMedia?t.matchesMedia=function(t){return""==t?!0:window.matchMedia(t).matches}:window.styleMedia||window.media?t.matchesMedia=function(t){if(""==t)return!0;var e=window.styleMedia||window.media;return e.matchMedium(t||"all")}:window.getComputedStyle?t.matchesMedia=function(t){if(""==t)return!0;var e=document.createElement("style"),n=document.getElementsByTagName("script")[0],i=null;e.type="text/css",e.id="matchmediajs-test",n.parentNode.insertBefore(e,n),i="getComputedStyle"in window&&window.getComputedStyle(e,null)||e.currentStyle;var a="@media "+t+"{ #matchmediajs-test { width: 1px; } }";return e.styleSheet?e.styleSheet.cssText=a:e.textContent=a,"1px"===i.width}:t.matchesMedia=function(t){if(""==t)return!0;var e,n,i,a,r={"min-width":null,"max-width":null},o=!1;for(i=t.split(/\s+and\s+/),e=0;er["max-width"]||null!==r["min-height"]&&cr["max-height"]?!1:!0},navigator.userAgent.match(/MSIE ([0-9]+)/)&&RegExp.$1<9&&(t.newStyle=function(t){var e=document.createElement("span");return e.innerHTML=' ",e})},initVars:function(){var e,n,i,a=navigator.userAgent;e="other",n=0,i=[["firefox",/Firefox\/([0-9\.]+)/],["bb",/BlackBerry.+Version\/([0-9\.]+)/],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/],["opera",/OPR\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)/],["edge",/Edge\/([0-9\.]+)/],["safari",/Version\/([0-9\.]+).+Safari/],["chrome",/Chrome\/([0-9\.]+)/],["ie",/MSIE ([0-9]+)/],["ie",/Trident\/.+rv:([0-9]+)/]],t.iterate(i,function(t,i){return a.match(i[1])?(e=i[0],n=parseFloat(RegExp.$1),!1):void 0}),t.vars.browser=e,t.vars.browserVersion=n,e="other",n=0,i=[["ios",/([0-9_]+) like Mac OS X/,function(t){return t.replace("_",".").replace("_","")}],["ios",/CPU like Mac OS X/,function(t){return 0}],["wp",/Windows Phone ([0-9\.]+)/,null],["android",/Android ([0-9\.]+)/,null],["mac",/Macintosh.+Mac OS X ([0-9_]+)/,function(t){return t.replace("_",".").replace("_","")}],["windows",/Windows NT ([0-9\.]+)/,null],["bb",/BlackBerry.+Version\/([0-9\.]+)/,null],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/,null]],t.iterate(i,function(t,i){return a.match(i[1])?(e=i[0],n=parseFloat(i[2]?i[2](RegExp.$1):RegExp.$1),!1):void 0}),t.vars.os=e,t.vars.osVersion=n,t.vars.IEVersion="ie"==t.vars.browser?t.vars.browserVersion:99,t.vars.touch="wp"==t.vars.os?navigator.msMaxTouchPoints>0:!!("ontouchstart"in window),t.vars.mobile="wp"==t.vars.os||"android"==t.vars.os||"ios"==t.vars.os||"bb"==t.vars.os}};return t.init(),t}();!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.skel=e()}(this,function(){return skel}); 3 | -------------------------------------------------------------------------------- /Sources/Pages.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Pages.swift 3 | // SwiftBlog 4 | // 5 | // Created by Jonathan Guthrie on 2016-11-12. 6 | // 7 | // 8 | 9 | import StORM 10 | import PostgresStORM 11 | 12 | class Page: PostgresStORM { 13 | var id = 0 14 | var name = "" 15 | var url = "" // slugified name by default 16 | var config = [String: Any]() // page level config 17 | var state = false // visible, not visible 18 | var displayorder = 0 19 | 20 | // Set the table name 21 | override open func table() -> String { 22 | return "page" 23 | } 24 | 25 | // Need to do this because of the nature of Swift's introspection 26 | override func to(_ this: StORMRow) { 27 | id = this.data["id"] as? Int ?? 0 28 | name = this.data["name"] as! String 29 | url = this.data["url"] as! String 30 | displayorder = this.data["displayorder"] as? Int ?? 0 31 | if let configObj = this.data["config"] { 32 | self.config = (configObj as? [String:Any])! 33 | } 34 | if let stateObj = this.data["state"] { 35 | if stateObj as! Bool == false { 36 | state = false 37 | } else { 38 | state = true 39 | } 40 | } 41 | } 42 | 43 | func rows() -> [Page] { 44 | var rows = [Page]() 45 | for i in 0.. [[String: Any]] { 54 | 55 | try? select(whereclause: "config @> '{\"type\":\"article\"}'::jsonb AND state = $1", params: ["true"], orderby: ["displayorder","id"]) 56 | var articleArray = [[String: Any]]() 57 | 58 | for row in rows() { 59 | var r = [String: Any]() 60 | r["name"] = row.name 61 | r["url"] = row.url 62 | if let datepublished = row.config["datepublished"] { 63 | r["datepublished"] = datepublished as! String 64 | } 65 | if let subhead = row.config["subhead"] { 66 | r["subhead"] = subhead as! String 67 | } 68 | if let intro = row.config["intro"] { 69 | r["intro"] = intro as! String 70 | } 71 | if let tags = row.config["tags"] { 72 | r["tags"] = (tags as? [Any])! 73 | } 74 | var heroimagealt = "" 75 | if let heroimagealtt = row.config["heroimagealt"] { 76 | heroimagealt = heroimagealtt as! String 77 | } 78 | if let heroimage = row.config["heroimage"] { 79 | r["heroimage?"] = ["image":heroimage, "alt":heroimagealt] 80 | } 81 | 82 | articleArray.append(r) 83 | } 84 | 85 | return articleArray 86 | 87 | 88 | } 89 | 90 | func getPage(link: String, isArticle: Bool) -> [String: Any] { 91 | var article = [String: Any]() 92 | 93 | var whereclause = [String]() 94 | var orderby = [String]() 95 | var params = [String]() 96 | let cursor = StORMCursor(limit: 1, offset: 0) 97 | 98 | // whereclause.append("state = $1") 99 | // params.append("true") 100 | 101 | if isArticle == true { 102 | whereclause.append("config @> '{\"type\":\"article\"}'::jsonb") 103 | } 104 | if link.isEmpty == false { 105 | whereclause.append("url = $1") 106 | params.append(link) 107 | } else { 108 | orderby.append("displayorder") 109 | } 110 | orderby.append("id DESC") 111 | 112 | try? select(whereclause: whereclause.joined(separator: " AND "), params: params, orderby: orderby, cursor: cursor) 113 | 114 | if results.cursorData.totalRecords == 0 { 115 | return article 116 | } 117 | 118 | for row in rows() { 119 | // only ever max 1 120 | article["id"] = row.id 121 | article["name"] = row.name 122 | article["url"] = row.url 123 | if let datepublished = row.config["datepublished"] { 124 | article["datepublished"] = datepublished as! String 125 | } 126 | if let subhead = row.config["subhead"] { 127 | article["subhead"] = subhead as! String 128 | } 129 | if let script = row.config["script"] { 130 | article["script"] = script as! String 131 | } 132 | 133 | var heroimagealt = "" 134 | if let heroimagealtt = row.config["heroimagealt"] { 135 | heroimagealt = heroimagealtt as! String 136 | } 137 | if let heroimage = row.config["heroimage"] { 138 | article["heroimage?"] = ["image":heroimage, "alt":heroimagealt] 139 | } 140 | if let tags = row.config["tags"] { 141 | article["tags"] = (tags as? [Any])! 142 | } 143 | 144 | // get components 145 | let components = Component() 146 | try? components.select(whereclause: "pageid = $1", params: [row.id], orderby: []) 147 | var cRowData = [[String: Any]]() 148 | for cRow in components.rows() { 149 | var thisRow = [String: Any]() 150 | thisRow["spot"] = cRow.spot 151 | thisRow["config"] = cRow.config 152 | thisRow["content"] = cRow.content 153 | cRowData.append(["\(cRow.spot)?": thisRow]) 154 | } 155 | article["components"] = cRowData 156 | } 157 | return article 158 | 159 | 160 | } 161 | 162 | func getPageData() -> [String: Any] { 163 | var article = [String: Any]() 164 | let foundRows = rows() 165 | if foundRows.count == 0 { 166 | 167 | article["name"] = "Page not found" 168 | 169 | } else { 170 | for row in foundRows { 171 | // only ever max 1 172 | article["id"] = row.id 173 | article["name"] = row.name 174 | article["url"] = row.url 175 | if let datepublished = row.config["datepublished"] { 176 | article["datepublished"] = datepublished as! String 177 | } 178 | if let script = row.config["script"] { 179 | article["script"] = script as! String 180 | } 181 | var heroimagealt = "" 182 | if let heroimagealtt = row.config["heroimagealt"] { 183 | heroimagealt = heroimagealtt as! String 184 | } 185 | 186 | if let heroimage = row.config["heroimage"] { 187 | article["heroimage?"] = ["image":heroimage, "alt":heroimagealt] 188 | } 189 | 190 | if let subhead = row.config["subhead"] { 191 | article["subhead"] = subhead as! String 192 | } 193 | if let tags = row.config["tags"] { 194 | article["tags"] = (tags as? [Any])! 195 | } 196 | 197 | // get components 198 | var gotBody = false 199 | let components = Component() 200 | try? components.select(whereclause: "pageid = $1", params: [row.id], orderby: []) 201 | var cRowData = [[String: Any]]() 202 | for cRow in components.rows() { 203 | var thisRow = [String: Any]() 204 | thisRow["spot"] = cRow.spot 205 | thisRow["config"] = cRow.config 206 | thisRow["content"] = cRow.content 207 | if cRow.spot == "body" { 208 | gotBody = true 209 | } 210 | cRowData.append(["\(cRow.spot)?": thisRow]) 211 | } 212 | if gotBody == false { 213 | var r = [String: Any]() 214 | r["body?"] = ["content":""] 215 | cRowData.append(r) 216 | } 217 | article["components"] = cRowData 218 | } 219 | } 220 | 221 | return article 222 | 223 | 224 | } 225 | 226 | 227 | func pageList() -> [[String: Any]] { 228 | //config @> '{"type":"article"}'::jsonb 229 | try? select(whereclause: "", params: [], orderby: ["displayorder","id DESC"]) 230 | var pageArray = [[String: Any]]() 231 | 232 | for row in rows() { 233 | var r = [String: Any]() 234 | r["id"] = row.id 235 | r["name"] = row.name 236 | if row.url.startsWith("/") { 237 | r["url"] = row.url 238 | } else { 239 | r["url"] = "/\(row.url)" 240 | } 241 | if row.state == true { r["state"] = "Active" } else { r["state"] = "Inactive" } 242 | if let datepublished = row.config["datepublished"] { 243 | r["datepublished"] = datepublished as! String 244 | } else { 245 | r["datepublished"] = "" 246 | } 247 | if let type = row.config["type"] { 248 | r["type"] = type as! String 249 | } else { 250 | r["type"] = "unspecified" 251 | } 252 | 253 | pageArray.append(r) 254 | } 255 | return pageArray 256 | } 257 | 258 | func toStub() -> [[String: Any]] { 259 | //assumes search already made and we have results 260 | 261 | var articleArray = [[String: Any]]() 262 | 263 | for row in rows() { 264 | var r = [String: Any]() 265 | r["name"] = row.name 266 | r["url"] = row.url 267 | if let datepublished = row.config["datepublished"] { 268 | r["datepublished"] = datepublished as! String 269 | } 270 | if let subhead = row.config["subhead"] { 271 | r["subhead"] = subhead as! String 272 | } 273 | if let intro = row.config["intro"] { 274 | r["intro"] = intro as! String 275 | } 276 | if let tags = row.config["tags"] { 277 | r["tags"] = (tags as? [Any])! 278 | } 279 | var heroimagealt = "" 280 | if let heroimagealtt = row.config["heroimagealt"] { 281 | heroimagealt = heroimagealtt as! String 282 | } 283 | if let heroimage = row.config["heroimage"] { 284 | r["heroimage?"] = ["image":heroimage, "alt":heroimagealt] 285 | } 286 | 287 | articleArray.append(r) 288 | } 289 | 290 | return articleArray 291 | 292 | 293 | } 294 | 295 | } 296 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /webroot/assets/js/util.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | 3 | /** 4 | * Generate an indented list of links from a nav. Meant for use with panel(). 5 | * @return {jQuery} jQuery object. 6 | */ 7 | $.fn.navList = function() { 8 | 9 | var $this = $(this); 10 | $a = $this.find('a'), 11 | b = []; 12 | 13 | $a.each(function() { 14 | 15 | var $this = $(this), 16 | indent = Math.max(0, $this.parents('li').length - 1), 17 | href = $this.attr('href'), 18 | target = $this.attr('target'); 19 | 20 | b.push( 21 | '' + 26 | '' + 27 | $this.text() + 28 | '' 29 | ); 30 | 31 | }); 32 | 33 | return b.join(''); 34 | 35 | }; 36 | 37 | /** 38 | * Panel-ify an element. 39 | * @param {object} userConfig User config. 40 | * @return {jQuery} jQuery object. 41 | */ 42 | $.fn.panel = function(userConfig) { 43 | 44 | // No elements? 45 | if (this.length == 0) 46 | return $this; 47 | 48 | // Multiple elements? 49 | if (this.length > 1) { 50 | 51 | for (var i=0; i < this.length; i++) 52 | $(this[i]).panel(userConfig); 53 | 54 | return $this; 55 | 56 | } 57 | 58 | // Vars. 59 | var $this = $(this), 60 | $body = $('body'), 61 | $window = $(window), 62 | id = $this.attr('id'), 63 | config; 64 | 65 | // Config. 66 | config = $.extend({ 67 | 68 | // Delay. 69 | delay: 0, 70 | 71 | // Hide panel on link click. 72 | hideOnClick: false, 73 | 74 | // Hide panel on escape keypress. 75 | hideOnEscape: false, 76 | 77 | // Hide panel on swipe. 78 | hideOnSwipe: false, 79 | 80 | // Reset scroll position on hide. 81 | resetScroll: false, 82 | 83 | // Reset forms on hide. 84 | resetForms: false, 85 | 86 | // Side of viewport the panel will appear. 87 | side: null, 88 | 89 | // Target element for "class". 90 | target: $this, 91 | 92 | // Class to toggle. 93 | visibleClass: 'visible' 94 | 95 | }, userConfig); 96 | 97 | // Expand "target" if it's not a jQuery object already. 98 | if (typeof config.target != 'jQuery') 99 | config.target = $(config.target); 100 | 101 | // Panel. 102 | 103 | // Methods. 104 | $this._hide = function(event) { 105 | 106 | // Already hidden? Bail. 107 | if (!config.target.hasClass(config.visibleClass)) 108 | return; 109 | 110 | // If an event was provided, cancel it. 111 | if (event) { 112 | 113 | event.preventDefault(); 114 | event.stopPropagation(); 115 | 116 | } 117 | 118 | // Hide. 119 | config.target.removeClass(config.visibleClass); 120 | 121 | // Post-hide stuff. 122 | window.setTimeout(function() { 123 | 124 | // Reset scroll position. 125 | if (config.resetScroll) 126 | $this.scrollTop(0); 127 | 128 | // Reset forms. 129 | if (config.resetForms) 130 | $this.find('form').each(function() { 131 | this.reset(); 132 | }); 133 | 134 | }, config.delay); 135 | 136 | }; 137 | 138 | // Vendor fixes. 139 | $this 140 | .css('-ms-overflow-style', '-ms-autohiding-scrollbar') 141 | .css('-webkit-overflow-scrolling', 'touch'); 142 | 143 | // Hide on click. 144 | if (config.hideOnClick) { 145 | 146 | $this.find('a') 147 | .css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)'); 148 | 149 | $this 150 | .on('click', 'a', function(event) { 151 | 152 | var $a = $(this), 153 | href = $a.attr('href'), 154 | target = $a.attr('target'); 155 | 156 | if (!href || href == '#' || href == '' || href == '#' + id) 157 | return; 158 | 159 | // Cancel original event. 160 | event.preventDefault(); 161 | event.stopPropagation(); 162 | 163 | // Hide panel. 164 | $this._hide(); 165 | 166 | // Redirect to href. 167 | window.setTimeout(function() { 168 | 169 | if (target == '_blank') 170 | window.open(href); 171 | else 172 | window.location.href = href; 173 | 174 | }, config.delay + 10); 175 | 176 | }); 177 | 178 | } 179 | 180 | // Event: Touch stuff. 181 | $this.on('touchstart', function(event) { 182 | 183 | $this.touchPosX = event.originalEvent.touches[0].pageX; 184 | $this.touchPosY = event.originalEvent.touches[0].pageY; 185 | 186 | }) 187 | 188 | $this.on('touchmove', function(event) { 189 | 190 | if ($this.touchPosX === null 191 | || $this.touchPosY === null) 192 | return; 193 | 194 | var diffX = $this.touchPosX - event.originalEvent.touches[0].pageX, 195 | diffY = $this.touchPosY - event.originalEvent.touches[0].pageY, 196 | th = $this.outerHeight(), 197 | ts = ($this.get(0).scrollHeight - $this.scrollTop()); 198 | 199 | // Hide on swipe? 200 | if (config.hideOnSwipe) { 201 | 202 | var result = false, 203 | boundary = 20, 204 | delta = 50; 205 | 206 | switch (config.side) { 207 | 208 | case 'left': 209 | result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX > delta); 210 | break; 211 | 212 | case 'right': 213 | result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX < (-1 * delta)); 214 | break; 215 | 216 | case 'top': 217 | result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY > delta); 218 | break; 219 | 220 | case 'bottom': 221 | result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY < (-1 * delta)); 222 | break; 223 | 224 | default: 225 | break; 226 | 227 | } 228 | 229 | if (result) { 230 | 231 | $this.touchPosX = null; 232 | $this.touchPosY = null; 233 | $this._hide(); 234 | 235 | return false; 236 | 237 | } 238 | 239 | } 240 | 241 | // Prevent vertical scrolling past the top or bottom. 242 | if (($this.scrollTop() < 0 && diffY < 0) 243 | || (ts > (th - 2) && ts < (th + 2) && diffY > 0)) { 244 | 245 | event.preventDefault(); 246 | event.stopPropagation(); 247 | 248 | } 249 | 250 | }); 251 | 252 | // Event: Prevent certain events inside the panel from bubbling. 253 | $this.on('click touchend touchstart touchmove', function(event) { 254 | event.stopPropagation(); 255 | }); 256 | 257 | // Event: Hide panel if a child anchor tag pointing to its ID is clicked. 258 | $this.on('click', 'a[href="#' + id + '"]', function(event) { 259 | 260 | event.preventDefault(); 261 | event.stopPropagation(); 262 | 263 | config.target.removeClass(config.visibleClass); 264 | 265 | }); 266 | 267 | // Body. 268 | 269 | // Event: Hide panel on body click/tap. 270 | $body.on('click touchend', function(event) { 271 | $this._hide(event); 272 | }); 273 | 274 | // Event: Toggle. 275 | $body.on('click', 'a[href="#' + id + '"]', function(event) { 276 | 277 | event.preventDefault(); 278 | event.stopPropagation(); 279 | 280 | config.target.toggleClass(config.visibleClass); 281 | 282 | }); 283 | 284 | // Window. 285 | 286 | // Event: Hide on ESC. 287 | if (config.hideOnEscape) 288 | $window.on('keydown', function(event) { 289 | 290 | if (event.keyCode == 27) 291 | $this._hide(event); 292 | 293 | }); 294 | 295 | return $this; 296 | 297 | }; 298 | 299 | /** 300 | * Apply "placeholder" attribute polyfill to one or more forms. 301 | * @return {jQuery} jQuery object. 302 | */ 303 | $.fn.placeholder = function() { 304 | 305 | // Browser natively supports placeholders? Bail. 306 | if (typeof (document.createElement('input')).placeholder != 'undefined') 307 | return $(this); 308 | 309 | // No elements? 310 | if (this.length == 0) 311 | return $this; 312 | 313 | // Multiple elements? 314 | if (this.length > 1) { 315 | 316 | for (var i=0; i < this.length; i++) 317 | $(this[i]).placeholder(); 318 | 319 | return $this; 320 | 321 | } 322 | 323 | // Vars. 324 | var $this = $(this); 325 | 326 | // Text, TextArea. 327 | $this.find('input[type=text],textarea') 328 | .each(function() { 329 | 330 | var i = $(this); 331 | 332 | if (i.val() == '' 333 | || i.val() == i.attr('placeholder')) 334 | i 335 | .addClass('polyfill-placeholder') 336 | .val(i.attr('placeholder')); 337 | 338 | }) 339 | .on('blur', function() { 340 | 341 | var i = $(this); 342 | 343 | if (i.attr('name').match(/-polyfill-field$/)) 344 | return; 345 | 346 | if (i.val() == '') 347 | i 348 | .addClass('polyfill-placeholder') 349 | .val(i.attr('placeholder')); 350 | 351 | }) 352 | .on('focus', function() { 353 | 354 | var i = $(this); 355 | 356 | if (i.attr('name').match(/-polyfill-field$/)) 357 | return; 358 | 359 | if (i.val() == i.attr('placeholder')) 360 | i 361 | .removeClass('polyfill-placeholder') 362 | .val(''); 363 | 364 | }); 365 | 366 | // Password. 367 | $this.find('input[type=password]') 368 | .each(function() { 369 | 370 | var i = $(this); 371 | var x = $( 372 | $('
') 373 | .append(i.clone()) 374 | .remove() 375 | .html() 376 | .replace(/type="password"/i, 'type="text"') 377 | .replace(/type=password/i, 'type=text') 378 | ); 379 | 380 | if (i.attr('id') != '') 381 | x.attr('id', i.attr('id') + '-polyfill-field'); 382 | 383 | if (i.attr('name') != '') 384 | x.attr('name', i.attr('name') + '-polyfill-field'); 385 | 386 | x.addClass('polyfill-placeholder') 387 | .val(x.attr('placeholder')).insertAfter(i); 388 | 389 | if (i.val() == '') 390 | i.hide(); 391 | else 392 | x.hide(); 393 | 394 | i 395 | .on('blur', function(event) { 396 | 397 | event.preventDefault(); 398 | 399 | var x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]'); 400 | 401 | if (i.val() == '') { 402 | 403 | i.hide(); 404 | x.show(); 405 | 406 | } 407 | 408 | }); 409 | 410 | x 411 | .on('focus', function(event) { 412 | 413 | event.preventDefault(); 414 | 415 | var i = x.parent().find('input[name=' + x.attr('name').replace('-polyfill-field', '') + ']'); 416 | 417 | x.hide(); 418 | 419 | i 420 | .show() 421 | .focus(); 422 | 423 | }) 424 | .on('keypress', function(event) { 425 | 426 | event.preventDefault(); 427 | x.val(''); 428 | 429 | }); 430 | 431 | }); 432 | 433 | // Events. 434 | $this 435 | .on('submit', function() { 436 | 437 | $this.find('input[type=text],input[type=password],textarea') 438 | .each(function(event) { 439 | 440 | var i = $(this); 441 | 442 | if (i.attr('name').match(/-polyfill-field$/)) 443 | i.attr('name', ''); 444 | 445 | if (i.val() == i.attr('placeholder')) { 446 | 447 | i.removeClass('polyfill-placeholder'); 448 | i.val(''); 449 | 450 | } 451 | 452 | }); 453 | 454 | }) 455 | .on('reset', function(event) { 456 | 457 | event.preventDefault(); 458 | 459 | $this.find('select') 460 | .val($('option:first').val()); 461 | 462 | $this.find('input,textarea') 463 | .each(function() { 464 | 465 | var i = $(this), 466 | x; 467 | 468 | i.removeClass('polyfill-placeholder'); 469 | 470 | switch (this.type) { 471 | 472 | case 'submit': 473 | case 'reset': 474 | break; 475 | 476 | case 'password': 477 | i.val(i.attr('defaultValue')); 478 | 479 | x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]'); 480 | 481 | if (i.val() == '') { 482 | i.hide(); 483 | x.show(); 484 | } 485 | else { 486 | i.show(); 487 | x.hide(); 488 | } 489 | 490 | break; 491 | 492 | case 'checkbox': 493 | case 'radio': 494 | i.attr('checked', i.attr('defaultValue')); 495 | break; 496 | 497 | case 'text': 498 | case 'textarea': 499 | i.val(i.attr('defaultValue')); 500 | 501 | if (i.val() == '') { 502 | i.addClass('polyfill-placeholder'); 503 | i.val(i.attr('placeholder')); 504 | } 505 | 506 | break; 507 | 508 | default: 509 | i.val(i.attr('defaultValue')); 510 | break; 511 | 512 | } 513 | }); 514 | 515 | }); 516 | 517 | return $this; 518 | 519 | }; 520 | 521 | /** 522 | * Moves elements to/from the first positions of their respective parents. 523 | * @param {jQuery} $elements Elements (or selector) to move. 524 | * @param {bool} condition If true, moves elements to the top. Otherwise, moves elements back to their original locations. 525 | */ 526 | $.prioritize = function($elements, condition) { 527 | 528 | var key = '__prioritize'; 529 | 530 | // Expand $elements if it's not already a jQuery object. 531 | if (typeof $elements != 'jQuery') 532 | $elements = $($elements); 533 | 534 | // Step through elements. 535 | $elements.each(function() { 536 | 537 | var $e = $(this), $p, 538 | $parent = $e.parent(); 539 | 540 | // No parent? Bail. 541 | if ($parent.length == 0) 542 | return; 543 | 544 | // Not moved? Move it. 545 | if (!$e.data(key)) { 546 | 547 | // Condition is false? Bail. 548 | if (!condition) 549 | return; 550 | 551 | // Get placeholder (which will serve as our point of reference for when this element needs to move back). 552 | $p = $e.prev(); 553 | 554 | // Couldn't find anything? Means this element's already at the top, so bail. 555 | if ($p.length == 0) 556 | return; 557 | 558 | // Move element to top of parent. 559 | $e.prependTo($parent); 560 | 561 | // Mark element as moved. 562 | $e.data(key, $p); 563 | 564 | } 565 | 566 | // Moved already? 567 | else { 568 | 569 | // Condition is true? Bail. 570 | if (condition) 571 | return; 572 | 573 | $p = $e.data(key); 574 | 575 | // Move element back to its original location (using our placeholder). 576 | $e.insertAfter($p); 577 | 578 | // Unmark element as moved. 579 | $e.removeData(key); 580 | 581 | } 582 | 583 | }); 584 | 585 | }; 586 | 587 | })(jQuery); -------------------------------------------------------------------------------- /webroot/assets/css/font-awesome.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.6.3 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.6.3');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.6.3') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.6.3') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.6.3') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.6.3') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.6.3#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.fa-pied-piper:before{content:"\f2ae"}.fa-first-order:before{content:"\f2b0"}.fa-yoast:before{content:"\f2b1"}.fa-themeisle:before{content:"\f2b2"}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:"\f2b3"}.fa-fa:before,.fa-font-awesome:before{content:"\f2b4"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto} 5 | -------------------------------------------------------------------------------- /webroot/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Future Imperfect by HTML5 UP 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 48 | 49 | 50 | 97 | 98 | 99 |
100 | 101 | 102 |
103 |
104 |
105 |

Magna sed adipiscing

106 |

Lorem ipsum dolor amet nullam consequat etiam feugiat

107 |
108 |
109 | 110 | Jane Doe 111 |
112 |
113 | 114 |

Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl. Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper. Praesent tincidunt sed tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla.

115 | 125 |
126 | 127 | 128 |
129 |
130 |
131 |

Ultricies sed magna euismod enim vitae gravida

132 |

Lorem ipsum dolor amet nullam consequat etiam feugiat

133 |
134 |
135 | 136 | Jane Doe 137 |
138 |
139 | 140 |

Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl. Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper.

141 | 151 |
152 | 153 | 154 |
155 |
156 |
157 |

Euismod et accumsan

158 |

Lorem ipsum dolor amet nullam consequat etiam feugiat

159 |
160 |
161 | 162 | Jane Doe 163 |
164 |
165 | 166 |

Mauris neque quam, fermentum ut nisl vitae, convallis maximus nisl. Sed mattis nunc id lorem euismod placerat. Vivamus porttitor magna enim, ac accumsan tortor cursus at. Phasellus sed ultricies mi non congue ullam corper. Praesent tincidunt sed tellus ut rutrum. Sed vitae justo condimentum, porta lectus vitae, ultricies congue gravida diam non fringilla. Cras vehicula tellus eu ligula viverra, ac fringilla turpis suscipit. Quisque vestibulum rhoncus ligula.

167 | 177 |
178 | 179 | 180 | 493 | 494 | 495 | 499 | 500 |
501 | 502 | 503 | 634 | 635 |
636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | --------------------------------------------------------------------------------