diff --git a/composer.json b/composer.json index 1ebd4303..576f1a24 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "type": "library", "license":"BSD-3-Clause", "require": { - "php": ">=5.6.0", + "php": ">=7.4.0", "symfony/yaml": "2.7.*" }, "autoload": { diff --git a/example/site/assets/default/css/styles.css b/example/site/assets/default/css/styles.css new file mode 100644 index 00000000..0a7fffdd --- /dev/null +++ b/example/site/assets/default/css/styles.css @@ -0,0 +1,500 @@ +body { + background:#fff; + color:#5F5C52; + font-size:1.25em; + margin:0; + padding:0; +} + +html, button, input, select, textarea, +.pure-g [class *= "pure-u"] { + /* Set your content font stack here: */ + font-family: 'Open Sans', sans-serif; +} + +/* Typo */ +a { + /*color:#00CA4C;*/ + color:#bb2222; + text-decoration:none; +} +a:hover { + /*color:#059129;*/ + color:#660000; +} +h1,h2,h3,h4,h5,h6 { + color:#423F37; +} +h1 { + font-size:2em; + font-weight:normal; + margin-top:0; +} +h2 { + font-size: 1.2em; + margin: 2em 0 1.2em 0; +} +p { + /*margin: 0 0 2.2em 0;*/ + margin: 0 0 1.4em 0; + font-size: 1em; + line-height:1.6em; +} +p + ul { + margin-top:-0.5em; +} +code { + color:#000; + font-weight:normal; +} +pre { + background: none repeat scroll 0 0 #e9e6e2; + font-family: "Courier 10 Pitch",Courier,monospace; + font-size: 0.9em; + line-height: 1.3; + margin-bottom: 2em; + padding: 30px; + color:#222; + overflow: auto; + word-wrap: normal; + white-space: pre; +} +table { + margin-bottom:2.6em; + font-size:0.88em; +} + +/* Container */ +.container { + max-width:1260px; + margin:0 auto; + padding:0 20px; +} + +/* Header */ +.header .pure-u-1 { + text-align:right; +} +.header .inner-container { + border-bottom:1px solid #E3E0D8; + padding-top:50px; + padding-bottom:48px; +} +.header .pure-menu li { + font-size:0.9em; +} +.header .pure-menu a { + color:#000000; +} +.header .pure-menu .active a { + background-color: #eee; +} + +/* Brand */ +.brand-title { + font-size:110%; + font-weight:bold; + text-transform:uppercase; + margin:0 0 0 0; + padding:0.21em 0; +} +.brand-title a { + color:#29251F; +} +.brand-tagline { + color:#ffffff; + font-size:2em; + font-weight: 300; + margin:1.5em auto 1.8em auto; + line-height:1.4em; + max-width:970px; + text-align:center; +} + +/* Footer */ +.footer { + background-color:#2D3138; + margin-top:75px; + font-size:0.8em; + color:rgba(255, 255, 255, 0.7); + padding-top:5em; + padding-bottom:3em; +} +.footer a { + color:#ffffff; +} +.footer a:hover { + color:#cccccc; +} +.footer ul { + list-style-type:none; + margin:0; + padding:0; +} +.footer li { + line-height:1.6em; +} +.footer h3 { + color:#ffffff; +} +.footer p { + padding-right:1em; +} +.footer hr { + margin-top:5em; + margin-bottom:3em; + background-color:#ccc; + border:none; + height:1px; +} + +/* Content */ +.content { + padding-right:55px; +} +.content li { + display: list-item; + line-height: 1.8; + padding: 0; +} +.content-container { + margin-top:75px; +} + +/* Sidebar */ +.sidebar { + border-left:1px solid #E3E0D8; + padding-left:55px; +} +.sidebar h4 { + margin-top:0; +} +.sidebar ul { + list-style-type:none; + margin:0; + padding:0; +} +.sidebar li { + font-size:0.8945em; + line-height:1.7; +} +.sidebar .widget-blog { + padding-bottom:50px; +} +.sidebar a { + color:#57534A; +} +.sidebar a:hover { + /*color:#00CA4C;*/ + color:#bb2222; +} +.sidebar ul ul { + margin-bottom:1em; +} +.sidebar .menu li a { + font-weight:bold; +} +.sidebar .menu li li a { + font-weight:normal; +} +.sidebar .menu li.active > a { + color:#bb2222; +} + +div.highlight pre { + font-size:1.1em; +} + +.slider { + background:#3abac4; +} + +/* Page Index */ +.page-index .header .inner-container { + border-bottom:none; +} +.page-index .content { + padding-right:0; +} + +/* Pure */ +.pure-button { + background-color:#3BB8E6; + color:#ffffff; +} +.pure-button:hover { + color:#ffffff; +} +.pure-button i.fa { + padding-left:0.5em; + padding-right:0.5em; +} +.pure-button i.fa-chevron-left { + padding-left:0; +} +.pure-button i.fa-chevron-right { + padding-right:0; +} +.button-xsmall { + font-size: 70%; +} + +.button-small { + font-size: 85%; +} + +.button-large { + font-size: 110%; +} + +.button-xlarge { + font-size: 125%; +} + +/* Pagination */ +.pagination { + text-align:center; + margin:80px 0 0 0; + clear:both; +} +.pagination a { + font-size:1.1em; + padding-left:1em; + padding-right:1em; +} + +span.e { + color:#fff; + background:#bb4444; + padding:0px 10px; + display:inline-block; + margin:0; +} + +.text-right { + text-align:right; +} + +.menu-link { + position: absolute; + display: block; /* show this only on small screens */ + top: 9px; + right: 0; /* "#menu width" */ + background: #fff; + font-size: 10px; /* change this value to increase/decrease button size */ + z-index: 10; + width: 2em; + height: auto; + padding: 2.1em 1.6em; +} + +.menu-link:hover, +.menu-link:focus { + background: #fff; +} + +.menu-link span { + position: relative; + display: block; +} + +.menu-link span, +.menu-link span:before, +.menu-link span:after { + background-color: #bbb; + width: 100%; + height: 0.3em; +} + +.menu-link span:before, +.menu-link span:after { + position: absolute; + margin-top: -0.6em; + content: " "; +} + +.menu-link span:after { + margin-top: 0.6em; +} + +/* Mobile Menu */ +#mobile-menu ul { + list-style-type:none; + margin:0; + padding:0; +} +#mobile-menu a { + display:block; + color:white; + background-color:#2d3138; + padding:0.5em 1em; + border-bottom:1px solid #ccc; + text-align:center; + text-transform:uppercase; +} +#mobile-menu .pure-menu-selected a, +#mobile-menu a:hover { + background-color:#4d5158; +} + +.doc-function table { + width:100%; +} +.doc-function td { + vertical-align:top; +} +.doc-function tr.code td { + background-color:#eee; +} +.doc-function tr.param td:first-child { + color:#000000; +} + +.gallery figure { + float:left; + margin-right:1em; + margin-bottom:1em; +} +.gallery figcaption { + font-size:0.8em; +} + +.video { + margin-bottom:2em; +} + +/* Plugin Simplesearch */ +.plugin-simplesearch-form { + margin-bottom:1.6em; +} +.plugin-simplesearch-results p { + font-size: 0.9em; + margin-bottom:0.8em; +} +.plugin-simplesearch-results .result { + margin-bottom: 0.8em; +} +.plugin-simplesearch-results .title { +} +.plugin-simplesearch-results .url { + font-size: 0.9em; +} +.plugin-simplesearch-results .date { + font-size: 0.9em; +} + + +/* Media Queries */ +@media (min-width:980px) { +} + +@media (min-width:768px) and (max-width:979px) { + body { + font-size:1.1em; + } + .content { + padding-right:25px; + } + .sidebar { + padding-left:25px; + } +} + +@media (max-width:767px) { + body { + font-size:1.1em; + } + .content { + padding-right:0; + } + .sidebar { + border-left:none; + padding-left:0; + padding-top:60px; + display:none; + } + .brand-tagline { + font-size:1.1em; + margin:1.5em auto 1.8em auto; + } + .content-container { + margin-top:2em; + } + .container { + padding:0 15px; + } + .header .inner-container { + padding-top:25px; + padding-bottom:23px; + } + .box div { + margin-right:0; + margin-left:0; + } +} + +@media (max-width:480px) { + body { + font-size:1em !important; + } + h1, h2.post-title { + font-size:1.4em; + } + .container { + padding:0 10px; + } + .header .inner-container { + padding-top:15px; + padding-bottom:13px; + } + pre { + padding:10px; + } + .pagination span { + display:none; + } + .pagination .pure-button i.fa { + padding:0; + } +} + +@media (min-width: 980px) { + .pure-visible-phone { + display: none; + } + .pure-visible-tablet { + display: none; + } + .pure-hidden-desktop { + display: none; + } +} + +@media (max-width: 480px) { + .pure-g-r > .pure-u, + .pure-g-r > [class *= "pure-u-"] { + width: 100%; + } +} + +@media (max-width: 767px) { + .pure-g-r > .pure-u, + .pure-g-r > [class *= "pure-u-"] { + width: 100%; + } + .pure-hidden-phone { + display: none; + } + .pure-visible-desktop { + display: none; + } +} + +@media (min-width: 768px) and (max-width: 979px) { + .pure-hidden-tablet { + display: none; + } + .pure-visible-desktop { + display: none; + } +} diff --git a/example/site/assets/default/js/scripts.js b/example/site/assets/default/js/scripts.js new file mode 100644 index 00000000..9fdf644f --- /dev/null +++ b/example/site/assets/default/js/scripts.js @@ -0,0 +1,34 @@ +function toggleClass(element, className) { + if (!element || !className) { + return; + } + + var classString = element.className, nameIndex = classString.indexOf(className); + if (nameIndex == -1) { + classString += ' ' + className; + } + else { + classString = classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length); + } + element.className = classString; +} + +document.getElementById('menuLink').addEventListener('click', function() { + toggleClass(document.getElementById('mobile-menu'), 'pure-hidden-phone'); +}); + +/* +(function(i, s, o, g, r, a, m) { + i['GoogleAnalyticsObject'] = r; + i[r] = i[r] || function() { + (i[r].q = i[r].q || []).push(arguments) + }, i[r].l = 1 * new Date(); + a = s.createElement(o), + m = s.getElementsByTagName(o)[0]; + a.async = 1; + a.src = g; + m.parentNode.insertBefore(a, m) +})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); +ga('create', 'UA-XXXX', 'example.com'); +ga('send', 'pageview'); +*/ diff --git a/example/site/config/main.yml b/example/site/config/main.yml new file mode 100644 index 00000000..f823d1a6 --- /dev/null +++ b/example/site/config/main.yml @@ -0,0 +1,6 @@ +nice_urls: false + +plugins: + enable: + - simplecontact + - simplesearch diff --git a/example/site/data/.gitkeep b/example/site/data/.gitkeep new file mode 100644 index 00000000..7737c39d --- /dev/null +++ b/example/site/data/.gitkeep @@ -0,0 +1 @@ +# keep empty folder diff --git a/example/site/layouts/default/default.html b/example/site/layouts/default/default.html new file mode 100644 index 00000000..b2272b12 --- /dev/null +++ b/example/site/layouts/default/default.html @@ -0,0 +1,22 @@ +{% extends "main.html" %} + +{% block content %} + +
+
+
+
+
+ {{ content() }} +
+
+
+ +
+
+
+
+{% endblock %} diff --git a/example/site/layouts/default/error.html b/example/site/layouts/default/error.html new file mode 100644 index 00000000..140fe5d2 --- /dev/null +++ b/example/site/layouts/default/error.html @@ -0,0 +1,41 @@ +{% extends "main.html" %} + +{% block content %} +
+
+
+
+ {% if error.page.code == 404 %} +

Seite nicht gefunden

+

Uups, da ist was schief gelaufen. Die aufgerufene Seite oder Resource wurde nicht gefunden.

+ {% else %} +

Fehler

+

Es ist ein Fehler aufgetreten.

+ + + + + + + + + + + + + + + + + + + + + +
Code{{ error.page.code }}
Message{{ error.page.message }}
Datei{{ error.page.file }}
Zeile{{ error.page.line }}
Trace{{ page.error.trace|nl2br }}
+ {% endif %} +
+
+
+
+{% endblock %} diff --git a/example/site/layouts/default/home.html b/example/site/layouts/default/home.html new file mode 100644 index 00000000..34956bc5 --- /dev/null +++ b/example/site/layouts/default/home.html @@ -0,0 +1,36 @@ +{% extends "main.html" %} + +{% block content %} + +
+
+
+
+

Deine neue Herbie-Website läuft!

+
+
+
+
+ +
+
+
+
+ {{ content() }} +
+
+ +
+
{{ content('left') }}
+
{{ content('right') }}
+
+ +
+
+ {{ content('footer') }} +
+
+
+
+ +{% endblock %} diff --git a/example/site/layouts/default/includes/simplesearch.html b/example/site/layouts/default/includes/simplesearch.html new file mode 100644 index 00000000..746184f4 --- /dev/null +++ b/example/site/layouts/default/includes/simplesearch.html @@ -0,0 +1,25 @@ + + \ No newline at end of file diff --git a/example/site/layouts/default/main.html b/example/site/layouts/default/main.html new file mode 100644 index 00000000..710d2b39 --- /dev/null +++ b/example/site/layouts/default/main.html @@ -0,0 +1,99 @@ +{% spaceless %} +{{ addcss([ + '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css', + 'http://fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C700italic%2C400%2C300%2C700%2C800&ver=3.8.1', + 'http://yui.yahooapis.com/pure/0.5.0/pure-min.css', + '@asset/default/css/styles.css', + ], [], null, false, 0) }} +{{ addjs('@asset/default/js/scripts.js') }} +{% endspaceless %} + + + + + + + {{ pagetitle({delim:' / ', siteTitle:'Herbie Flat-File CMS & Blog', rootTitle: 'Herbie - Einfaches Flat-File CMS- und Blogsystem', reverse:true}) }} + + {{ outputcss() }} + + + + + + +
+
+
+ +
+
+

{{ link('index', 'DEIN LOGO') }}

+
+
+
+
+ {{ menu({class:"pure-menu pure-menu-open pure-menu-horizontal"}) }} +
+
+
+
+
+
+
+ +
+ +
+ + {% block content %}{% endblock %} + + + {{ outputjs() }} + + \ No newline at end of file diff --git a/example/site/pages/1-kontakt.md b/example/site/pages/1-kontakt.md new file mode 100644 index 00000000..42bc303e --- /dev/null +++ b/example/site/pages/1-kontakt.md @@ -0,0 +1,45 @@ +--- +title: Kontakt +nocache: 1 +simplecontact: + subject: "Kontaktanfrage deiner Herbie-Website!" + recipient: "blackhole@example.com" + fields: + name: + label: "Dein Name" + placeholder: + email: + label: "Deine E-Mail" + placeholder: + message: + label: "Deine Nachricht" + placeholder: + antispam: + label: "Antispam" + placeholder: + submit: + label: "Formular absenden" + messages: + success: "Vielen Dank! Deine Nachricht wurde versendet." + error: "Uups! Da gibt's ein Problem. Bitte vervollständige das Formular und probier's nochmal." + fail: "Uups! Etwas ist schief gegangen. Das Nachricht konnte nicht übermittelt werden." + errors: + empty_field: "Dies ist ein Pflichtfeld" + invalid_email: "Die eingegebene E-Mail ist ungültig" +--- + +

Kontakt

+ +[simplecontact] + + +--- sidebar --- + +### Adresse + +Hans Muster +Musterstrasse 43 +3020 Mustern + + + \ No newline at end of file diff --git a/example/site/pages/2-dienstleistung.md b/example/site/pages/2-dienstleistung.md new file mode 100644 index 00000000..9da053ac --- /dev/null +++ b/example/site/pages/2-dienstleistung.md @@ -0,0 +1,9 @@ +--- +title: Dienstleistung +--- + +# Vivamus sit amet libero in dolor euismod bibendum + +Duis sed nisl ac mauris semper cursus. Vivamus sit amet libero in dolor euismod bibendum sed in massa. Nulla iaculis bibendum tempus. Pellentesque condimentum turpis nec tortor interdum ut blandit mauris vehicula. Fusce scelerisque odio vel dui luctus vel viverra odio semper. Nunc euismod luctus sapien, eu euismod lorem iaculis id. Pellentesque suscipit, lectus id volutpat posuere, nulla risus egestas erat, vitae cursus orci augue eu tellus. + +Etiam erat mauris, ullamcorper quis fringilla at, venenatis sed eros. Mauris et nisl non libero scelerisque volutpat. Mauris luctus metus quis odio sagittis luctus. Pellentesque et arcu congue tortor tincidunt venenatis. Praesent eget diam sed nunc vulputate fringilla. Pellentesque sit amet quam vel mi tristique tristique. Praesent dictum gravida dolor vitae pulvinar. In hac habitasse platea dictumst. Integer sit amet feugiat erat. Integer vitae lacus suscipit dolor adipiscing egestas sed sed libero. diff --git a/example/site/pages/3-produkte.md b/example/site/pages/3-produkte.md new file mode 100644 index 00000000..40c642a5 --- /dev/null +++ b/example/site/pages/3-produkte.md @@ -0,0 +1,9 @@ +--- +title: Produkte +--- + +# In mollis luctus libero nec euismod + +Etiam erat mauris, ullamcorper quis fringilla at, venenatis sed eros. Mauris et nisl non libero scelerisque volutpat. Mauris luctus metus quis odio sagittis luctus. Pellentesque et arcu congue tortor tincidunt venenatis. Praesent eget diam sed nunc vulputate fringilla. Pellentesque sit amet quam vel mi tristique tristique. Praesent dictum gravida dolor vitae pulvinar. In hac habitasse platea dictumst. Integer sit amet feugiat erat. Integer vitae lacus suscipit dolor adipiscing egestas sed sed libero. + +Duis sed nisl ac mauris semper cursus. Vivamus sit amet libero in dolor euismod bibendum sed in massa. Nulla iaculis bibendum tempus. Pellentesque condimentum turpis nec tortor interdum ut blandit mauris vehicula. Fusce scelerisque odio vel dui luctus vel viverra odio semper. Nunc euismod luctus sapien, eu euismod lorem iaculis id. Pellentesque suscipit, lectus id volutpat posuere, nulla risus egestas erat, vitae cursus orci augue eu tellus. Donec quis elit in neque vulputate dignissim a eu justo. Ut tempus magna non tellus ultrices rhoncus. Duis sagittis blandit ultricies. diff --git a/example/site/pages/3-ueber.md b/example/site/pages/3-ueber.md new file mode 100644 index 00000000..f2eb04d2 --- /dev/null +++ b/example/site/pages/3-ueber.md @@ -0,0 +1,9 @@ +--- +title: Über uns +--- + +# Duis sed nisl ac mauris semper cursus + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed blandit tempus molestie. In pretium iaculis lorem id ultricies. Curabitur lobortis sapien ac magna ullamcorper faucibus. Aenean ac nibh diam. Donec id felis nunc, et bibendum erat. Nulla faucibus, lacus iaculis aliquet ultricies, diam nibh auctor risus, eget placerat est orci sed arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam diam tellus, scelerisque ut imperdiet eget, faucibus vel sapien. Sed vitae libero vel nisl tincidunt sodales. + +In mollis luctus libero nec euismod. Proin pellentesque rutrum tortor id venenatis. Integer eu lorem quis odio lacinia sollicitudin. Aenean leo urna, dictum at adipiscing et, posuere eget ipsum. Cras id dolor est. Curabitur at lorem eget neque gravida imperdiet nec quis lacus. Proin et facilisis justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse ut mauris vel est cursus ornare non id nisl. Aenean porttitor fringilla lectus, vitae lobortis nisi interdum id. Nullam semper, ante id dictum consectetur, elit velit accumsan urna, eu faucibus lectus justo id nibh. diff --git a/example/site/pages/index.md b/example/site/pages/index.md new file mode 100644 index 00000000..92c898fe --- /dev/null +++ b/example/site/pages/index.md @@ -0,0 +1,20 @@ +--- +title: Übersicht +layout: home.html +--- + +# Deine neue Herbie-Website läuft! + + +--- left --- + +## Vestibulum ut eros id diam viverra malesuada + +In mollis luctus libero nec euismod. Proin pellentesque rutrum tortor id venenatis. Integer eu lorem quis odio lacinia sollicitudin. Aenean leo urna, dictum at adipiscing et, posuere eget ipsum. Cras id dolor est. Curabitur at lorem eget neque gravida imperdiet nec quis lacus. Proin et facilisis justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse ut mauris vel est cursus ornare non id nisl. Aenean porttitor fringilla lectus, vitae lobortis nisi interdum id. Nullam semper, ante id dictum consectetur, elit velit accumsan urna, eu faucibus lectus justo id nibh. + +--- right --- + +## Pellentesque mi mi, pretium in scelerisque nec, facilisis id massa + +Vestibulum ut eros id diam viverra malesuada. Praesent vel odio odio. Nulla molestie, lectus ut vulputate posuere, sapien felis pretium magna, feugiat laoreet arcu mauris a nibh. Etiam sed tellus metus. Nam vehicula justo in odio venenatis lobortis et vel ipsum. Fusce facilisis sem non sem dictum eu congue diam euismod. Aenean at lectus nulla, nec dignissim elit. Donec viverra nunc sed tortor vehicula eu feugiat dui varius. Aenean orci tellus, adipiscing consequat bibendum placerat, molestie eu lectus. Nulla quis nunc orci. + diff --git a/example/site/posts/.gitkeep b/example/site/posts/.gitkeep new file mode 100644 index 00000000..9a67bdee --- /dev/null +++ b/example/site/posts/.gitkeep @@ -0,0 +1 @@ +# keep empty folder \ No newline at end of file diff --git a/example/site/runtime/cache/data/.gitignore b/example/site/runtime/cache/data/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/example/site/runtime/cache/data/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/example/site/runtime/cache/page/.gitignore b/example/site/runtime/cache/page/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/example/site/runtime/cache/page/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/example/site/runtime/cache/twig/.gitignore b/example/site/runtime/cache/twig/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/example/site/runtime/cache/twig/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/example/site/runtime/log/.gitignore b/example/site/runtime/log/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/example/site/runtime/log/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/log/.gitignore b/example/web/assets/.gitignore similarity index 83% rename from log/.gitignore rename to example/web/assets/.gitignore index 5e7d2734..86d0cb27 100644 --- a/log/.gitignore +++ b/example/web/assets/.gitignore @@ -1,4 +1,4 @@ # Ignore everything in this directory * # Except this file -!.gitignore +!.gitignore \ No newline at end of file diff --git a/example/web/cache/.gitignore b/example/web/cache/.gitignore new file mode 100644 index 00000000..86d0cb27 --- /dev/null +++ b/example/web/cache/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/example/web/index.php b/example/web/index.php new file mode 100644 index 00000000..f242e191 --- /dev/null +++ b/example/web/index.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Herbie\Application; + +if (php_sapi_name() == 'cli-server') { + if (preg_match('/\.(?:js|css|gif|jpg|jpeg|png)$/', $_SERVER["REQUEST_URI"])) { + return false; + } +} + +require_once(dirname(__DIR__, 2) . '/vendor/autoload.php'); + +define('HERBIE_DEBUG', true); + +$app = new Application( + dirname(__DIR__) . '/site/', + dirname(__DIR__, 2) . '/vendor/' +); + +$app->run(); diff --git a/src/config/defaults.example.yml b/src/config/defaults.example.yml index 640ce0d6..e88851e2 100644 --- a/src/config/defaults.example.yml +++ b/src/config/defaults.example.yml @@ -54,11 +54,11 @@ twig: cache: page: enable: false - dir: SITE_PATH/cache/page + dir: SITE_PATH/runtime/cache/page expire: 86400 data: enable: false - dir: SITE_PATH/cache/data + dir: SITE_PATH/runtime/cache/data expire: 86400 language: de diff --git a/src/config/defaults.php b/src/config/defaults.php index 6d15ebe5..1026a7d0 100644 --- a/src/config/defaults.php +++ b/src/config/defaults.php @@ -64,12 +64,12 @@ 'cache' => [ 'page' => [ 'enable' => false, - 'dir' => $SITE_PATH . '/cache/page', + 'dir' => $SITE_PATH . '/runtime/cache/page', 'expire' => 86400 ], 'data' => [ 'enable' => false, - 'dir' => $SITE_PATH . '/cache/data', + 'dir' => $SITE_PATH . '/runtime/cache/data', 'expire' => 86400 ] ], diff --git a/src/plugins/twig/twig.php b/src/plugins/twig/twig.php index fa5b918d..4f40376e 100644 --- a/src/plugins/twig/twig.php +++ b/src/plugins/twig/twig.php @@ -21,8 +21,7 @@ public function initTwig() $config = DI::get('Config'); // Add custom namespace path to Imagine lib - $vendorDir = $config->get('site.path') . '/../vendor'; - $autoload = require($vendorDir . '/autoload.php'); + $autoload = require($config->vendorPath . '/autoload.php'); $autoload->add('Twig_', __DIR__ . '/vendor/twig/twig/lib'); $this->twig = new Twig($config); diff --git a/src/system/Application.php b/src/system/Application.php index ef980839..19532f8c 100644 --- a/src/system/Application.php +++ b/src/system/Application.php @@ -51,9 +51,15 @@ public function __construct($sitePath, $vendorDir = '../vendor') */ private function init() { - + $logDir = $this->sitePath . '/runtime/log'; // NOTE kind of hard-coded, I know + if (!is_dir($logDir)) { + die("Logdir {$logDir} does not exist"); + } elseif (!is_writable($logDir)) { + die("Logdir {$logDir} is not writable"); + } + $errorHandler = new ErrorHandler(); - $errorHandler->register(); + $errorHandler->register($logDir); static::$DI = $DI = DI::instance(); @@ -61,7 +67,8 @@ private function init() $DI['Config'] = $config = new Config( $this->sitePath, dirname($_SERVER['SCRIPT_FILENAME']), - $request->getBaseUrl() + $request->getBaseUrl(), + $this->vendorDir ); $DI['Alias'] = new Alias([ diff --git a/src/system/Config.php b/src/system/Config.php index 2beec7e3..24e20eb7 100644 --- a/src/system/Config.php +++ b/src/system/Config.php @@ -38,17 +38,24 @@ class Config */ private $sitePath; + /** + * @var string + */ + public $vendorPath; + /** * @param string $sitePath * @param string $webPath * @param string $webUrl + * @param string $vendorPath */ - public function __construct($sitePath, $webPath, $webUrl) + public function __construct($sitePath, $webPath, $webUrl, $vendorPath) { $this->appPath = realpath(__DIR__); $this->sitePath = $sitePath; $this->webPath = $webPath; $this->webUrl = preg_replace('#\/?index.php#', '', $webUrl); + $this->vendorPath = $vendorPath; $this->items = []; $this->cache = []; $this->loadConfig(false); @@ -203,12 +210,16 @@ private function loadMainFile() $WEB_PATH = $this->webPath; $WEB_URL = $this->webUrl; - $defaults = require(__DIR__ . '/../config/defaults.php'); - if (is_file($this->sitePath . '/config/main.php')) { - $userConfig = require($this->sitePath . '/config.php'); + $defaultConfig = __DIR__ . '/../config/defaults.php'; + $userPhpConfig = $this->sitePath . '/config/main.php'; + $userYmlConfig = $this->sitePath . '/config/main.yml'; + + $defaults = require($defaultConfig); + if (is_file($userPhpConfig)) { + $userConfig = require($userPhpConfig); $defaults = $this->merge($defaults, $userConfig); - } elseif (is_file($this->sitePath . '/config/main.yml')) { - $content = file_get_contents($this->sitePath . '/config/main.yml'); + } elseif (is_file($userYmlConfig)) { + $content = file_get_contents($userYmlConfig); $content = $this->replaceConstants($content); $userConfig = Yaml::parse($content); $defaults = $this->merge($defaults, $userConfig); diff --git a/src/system/ErrorHandler.php b/src/system/ErrorHandler.php index 3635d763..a10b9b6a 100644 --- a/src/system/ErrorHandler.php +++ b/src/system/ErrorHandler.php @@ -19,11 +19,12 @@ class ErrorHandler /** * Registers this error handler. */ - public function register() + public function register(string $logDir) { + error_reporting(E_ALL); ini_set("display_errors", 0); ini_set("log_errors", 1); - ini_set("error_log", sprintf("%s/log/%s-error.log", dirname(__DIR__), date('Y-m'))); + ini_set("error_log", sprintf("%s/%s-error.log", $logDir, date('Y-m'))); set_exception_handler([$this, 'handleException']); set_error_handler([$this, 'handleError'], error_reporting());