diff --git a/composer.json b/composer.json index bdc3889..dc2d4b1 100644 --- a/composer.json +++ b/composer.json @@ -10,16 +10,16 @@ }, "require": { "slim/slim": "~3.7", - "twig/twig": "~1.18", - "slim/twig-view": "~2.3", - "slim/flash": "~0.4", + "twig/twig": "~1.18", + "slim/twig-view": "~2.3", + "slim/flash": "~0.4", "slim/csrf": "~0.8", "symfony/yaml": "~2.8", - "symfony/event-dispatcher": "~3.3", - "erusev/parsedown": "~1.4", - "erusev/parsedown-extra": "dev-master", - "jbroadway/urlify": "1.1.3", - "vlucas/valitron": "dev-master", + "symfony/event-dispatcher": "~3.3", + "erusev/parsedown": "~1.4", + "erusev/parsedown-extra": "dev-master", + "jbroadway/urlify": "1.1.3", + "vlucas/valitron": "dev-master", "laminas/laminas-permissions-acl": "^2.7", "akrabat/proxy-detection-middleware": "^0.4.0" }, diff --git a/content/00-welcome/00-setup.md b/content/00-welcome/00-setup.md index 8edd144..afd7322 100644 --- a/content/00-welcome/00-setup.md +++ b/content/00-welcome/00-setup.md @@ -2,8 +2,6 @@ Congratulations! If you see this page, then the setup of the system has worked successfully!! You can now login (/tm/login) and configure your system, your themes and your plugins. You will find all settings in the settings-area (/tm/settings). -## If it does not work - If you face any problems during the installation, then please make sure, that your system supports these features: - PHP version 7+. diff --git a/media/custom/pexels-bugra-dogan-3561946-100x100.jpeg b/media/custom/pexels-bugra-dogan-3561946-100x100.jpeg deleted file mode 100644 index f37b86b..0000000 Binary files a/media/custom/pexels-bugra-dogan-3561946-100x100.jpeg and /dev/null differ diff --git a/media/custom/pexels-bugra-dogan-3561946-250x250.jpeg b/media/custom/pexels-bugra-dogan-3561946-250x250.jpeg deleted file mode 100644 index e5b4cfa..0000000 Binary files a/media/custom/pexels-bugra-dogan-3561946-250x250.jpeg and /dev/null differ diff --git a/media/custom/union-berlin-100x100.jpeg b/media/custom/union-berlin-100x100.jpeg deleted file mode 100644 index 3ca58ff..0000000 Binary files a/media/custom/union-berlin-100x100.jpeg and /dev/null differ diff --git a/media/live/example-1.webp b/media/live/example-1.webp deleted file mode 100644 index d32eb7a..0000000 Binary files a/media/live/example-1.webp and /dev/null differ diff --git a/media/live/example.webp b/media/live/example.webp deleted file mode 100644 index d32eb7a..0000000 Binary files a/media/live/example.webp and /dev/null differ diff --git a/media/live/pexels-bugra-dogan-3561946.jpeg b/media/live/pexels-bugra-dogan-3561946.jpeg deleted file mode 100644 index 3840135..0000000 Binary files a/media/live/pexels-bugra-dogan-3561946.jpeg and /dev/null differ diff --git a/media/live/procontra.png b/media/live/procontra.png deleted file mode 100644 index 1f03bf2..0000000 Binary files a/media/live/procontra.png and /dev/null differ diff --git a/media/live/streetstyle-nyc16.jpeg b/media/live/streetstyle-nyc16.jpeg deleted file mode 100644 index 8d0cea6..0000000 Binary files a/media/live/streetstyle-nyc16.jpeg and /dev/null differ diff --git a/media/original/example-1.webp b/media/original/example-1.webp deleted file mode 100644 index 89e6075..0000000 Binary files a/media/original/example-1.webp and /dev/null differ diff --git a/media/original/example.webp b/media/original/example.webp deleted file mode 100644 index 89e6075..0000000 Binary files a/media/original/example.webp and /dev/null differ diff --git a/media/original/pexels-bugra-dogan-3561946.jpeg b/media/original/pexels-bugra-dogan-3561946.jpeg deleted file mode 100644 index 4c5bfe9..0000000 Binary files a/media/original/pexels-bugra-dogan-3561946.jpeg and /dev/null differ diff --git a/media/original/procontra.png b/media/original/procontra.png deleted file mode 100644 index 66223d1..0000000 Binary files a/media/original/procontra.png and /dev/null differ diff --git a/media/original/streetstyle-nyc16.jpeg b/media/original/streetstyle-nyc16.jpeg deleted file mode 100644 index ca46ab8..0000000 Binary files a/media/original/streetstyle-nyc16.jpeg and /dev/null differ diff --git a/media/thumbs/example-1.webp b/media/thumbs/example-1.webp deleted file mode 100644 index bce1841..0000000 Binary files a/media/thumbs/example-1.webp and /dev/null differ diff --git a/media/thumbs/example.webp b/media/thumbs/example.webp deleted file mode 100644 index bce1841..0000000 Binary files a/media/thumbs/example.webp and /dev/null differ diff --git a/media/thumbs/pexels-bugra-dogan-3561946.jpeg b/media/thumbs/pexels-bugra-dogan-3561946.jpeg deleted file mode 100644 index 0f634fe..0000000 Binary files a/media/thumbs/pexels-bugra-dogan-3561946.jpeg and /dev/null differ diff --git a/media/thumbs/procontra.png b/media/thumbs/procontra.png deleted file mode 100644 index e7b86d0..0000000 Binary files a/media/thumbs/procontra.png and /dev/null differ diff --git a/media/thumbs/streetstyle-nyc16.jpeg b/media/thumbs/streetstyle-nyc16.jpeg deleted file mode 100644 index c9f9f6a..0000000 Binary files a/media/thumbs/streetstyle-nyc16.jpeg and /dev/null differ diff --git a/system/Assets.php b/system/Assets.php index ad7e83e..1773f3a 100644 --- a/system/Assets.php +++ b/system/Assets.php @@ -6,7 +6,7 @@ use Typemill\Models\ProcessImage; class Assets { - protected $baseUrl; + public $baseUrl; public function __construct($baseUrl) { @@ -22,6 +22,16 @@ class Assets $this->imageFolder = 'original'; } + public function setUri($uri) + { + $this->uri = $uri; + } + + public function setBaseUrl($baseUrl) + { + $this->baseUrl = $baseUrl; + } + public function image($url) { $this->imageUrl = $url; @@ -151,6 +161,8 @@ class Assets { $this->JS[] = ''; } + +# print_r($this->JS); } public function addInlineJS($JS) diff --git a/system/Controllers/ArticleApiController.php b/system/Controllers/ArticleApiController.php index 351a9de..c0deeca 100644 --- a/system/Controllers/ArticleApiController.php +++ b/system/Controllers/ArticleApiController.php @@ -39,6 +39,9 @@ class ArticleApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson($this->errors, 404); } + # set information for homepage + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -72,7 +75,7 @@ class ArticleApiController extends ContentController if(is_array($this->content)) { # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # turn markdown into an array of markdown-blocks $this->content = $parsedown->arrayBlocksToMarkdown($this->content); @@ -125,6 +128,9 @@ class ArticleApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson($this->errors, 404); } + # set information for homepage + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -151,7 +157,7 @@ class ArticleApiController extends ContentController if(!$this->setContent()){ return $response->withJson($this->errors, 404); } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # turn markdown into an array of markdown-blocks $contentArray = $parsedown->markdownToArrayBlocks($this->content); @@ -219,6 +225,9 @@ class ArticleApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson($this->errors, 404); } + # set information for homepage + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -237,7 +246,7 @@ class ArticleApiController extends ContentController # set redirect url to edit page $url = $this->uri->getBaseUrl() . '/tm/content/' . $this->settings['editor']; - if(isset($this->item->urlRelWoF)) + if(isset($this->item->urlRelWoF) && $this->item->urlRelWoF != '/' ) { $url = $url . $this->item->urlRelWoF; } @@ -276,6 +285,9 @@ class ArticleApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson($this->errors, 404); } + # set information for homepage + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -351,6 +363,9 @@ class ArticleApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson($this->errors, 404); } + # set information for homepage + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -371,7 +386,7 @@ class ArticleApiController extends ContentController $updatedContent = '# ' . $this->params['title'] . "\r\n\r\n" . $this->params['content']; # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # turn markdown into an array of markdown-blocks $contentArray = $parsedown->markdownToArrayBlocks($updatedContent); @@ -829,7 +844,7 @@ class ArticleApiController extends ContentController if(!$this->setStructure($draft = true, $cache = false)){ return $response->withJson(array('data' => false, 'errors' => $this->errors, 'url' => $url), 404); } # set information for homepage - $this->setHomepage(); + $this->setHomepage($args = false); # get item for url and set it active again if(isset($this->params['url'])) @@ -854,6 +869,9 @@ class ArticleApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson(array('data' => false, 'errors' => $this->errors), 404); } + + # set information for homepage + $this->setHomepage($args = false); /* set item */ if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -888,7 +906,7 @@ class ArticleApiController extends ContentController if(!is_array($content)) { # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # turn markdown into an array of markdown-blocks $content = $parsedown->markdownToArrayBlocks($content); @@ -916,6 +934,9 @@ class ArticleApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson(array('data' => false, 'errors' => $this->errors), 404); } + + # set information for homepage + $this->setHomepage($args = false); /* set item */ if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -947,7 +968,7 @@ class ArticleApiController extends ContentController } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # fix footnotes in parsedown, might break with complicated footnotes $parsedown->setVisualMode(); diff --git a/system/Controllers/BlockApiController.php b/system/Controllers/BlockApiController.php index 73b3be6..a9ea0f3 100644 --- a/system/Controllers/BlockApiController.php +++ b/system/Controllers/BlockApiController.php @@ -33,6 +33,8 @@ class BlockApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson(array('data' => false, 'errors' => $this->errors), 404); } + $this->setHomepage($args = false); + /* set item */ if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -72,7 +74,7 @@ class BlockApiController extends ContentController } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # if content is not an array, then transform it if(!is_array($pageMarkdown)) @@ -170,7 +172,7 @@ class BlockApiController extends ContentController } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # if content is not an array, then transform it if(!is_array($content)) @@ -229,6 +231,8 @@ class BlockApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson(array('data' => false, 'errors' => $this->errors), 404); } + $this->setHomepage($args = false); + /* set item */ if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -268,7 +272,7 @@ class BlockApiController extends ContentController } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); $parsedown->setVisualMode(); # if content is not an array, then transform it @@ -384,6 +388,8 @@ class BlockApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson(array('data' => false, 'errors' => $this->errors), 404); } + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -415,7 +421,7 @@ class BlockApiController extends ContentController } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # if content is not an array, then transform it if(!is_array($pageMarkdown)) @@ -490,6 +496,8 @@ class BlockApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson(array('data' => false, 'errors' => $this->errors), 404); } + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -521,7 +529,7 @@ class BlockApiController extends ContentController } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # if content is not an array, then transform it if(!is_array($this->content)) diff --git a/system/Controllers/ContentBackendController.php b/system/Controllers/ContentBackendController.php index 9a637ea..9b67d9d 100644 --- a/system/Controllers/ContentBackendController.php +++ b/system/Controllers/ContentBackendController.php @@ -28,7 +28,7 @@ class ContentBackendController extends ContentController if(!$this->setStructure($draft = true)){ return $this->renderIntern404($response, array( 'navigation' => true, 'content' => $this->errors )); } # set information for homepage - $this->setHomepage(); + $this->setHomepage($args); # set item if(!$this->setItem()){ return $this->renderIntern404($response, array( 'navigation' => $this->structure, 'settings' => $this->settings, 'content' => $this->errors )); } @@ -44,7 +44,7 @@ class ContentBackendController extends ContentController # set path $this->setItemPath($this->item->fileType); - + # add the modified date for the file $this->item->modified = ($this->item->published OR $this->item->drafted) ? filemtime($this->settings['contentFolder'] . $this->path) : false; @@ -58,7 +58,7 @@ class ContentBackendController extends ContentController if(is_array($content)) { # transform array to markdown - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); $content = $parsedown->arrayBlocksToMarkdown($content); } @@ -108,7 +108,7 @@ class ContentBackendController extends ContentController if(!$this->setStructure($draft = true)){ return $this->renderIntern404($response, array( 'navigation' => true, 'content' => $this->errors )); } # set information for homepage - $this->setHomepage(); + $this->setHomepage($args); # set item if(!$this->setItem()){ return $this->renderIntern404($response, array( 'navigation' => $this->structure, 'settings' => $this->settings, 'content' => $this->errors )); } @@ -136,7 +136,7 @@ class ContentBackendController extends ContentController } # initialize parsedown extension - $parsedown = new ParsedownExtension(); + $parsedown = new ParsedownExtension($this->uri->getBaseUrl()); # to fix footnote-logic in parsedown, set visual mode to true $parsedown->setVisualMode(); diff --git a/system/Controllers/ContentController.php b/system/Controllers/ContentController.php index fe10875..1e2e3b2 100644 --- a/system/Controllers/ContentController.php +++ b/system/Controllers/ContentController.php @@ -62,6 +62,8 @@ abstract class ContentController $this->settings = $this->c->get('settings'); $this->structureLiveName = 'structure.txt'; $this->structureDraftName = 'structure-draft.txt'; + + $this->c->dispatcher->dispatch('onTwigLoaded'); } # admin ui rendering @@ -275,7 +277,8 @@ abstract class ContentController } } - protected function setHomepage() + # this is only set by content backend controller + protected function setHomepage($args) { $contentFolder = Folder::scanFolderFlat($this->settings['rootPath'] . $this->settings['contentFolder']); @@ -295,7 +298,7 @@ abstract class ContentController } $active = false; - if($this->params['url'] == '/' || $this->params['url'] == $this->uri->getBasePath() ) + if($this->params['url'] == '/' || (is_array($args) && empty($args))) { $active = 'active'; } @@ -305,8 +308,11 @@ abstract class ContentController protected function setItem() { + # home is only set by backend controller, not by api calls + $home = isset($this->homepage['active']) ? $this->homepage['active'] : false; + # search for the url in the structure - $item = Folder::getItemForUrl($this->structure, $this->params['url'], $this->uri->getBasePath()); + $item = Folder::getItemForUrl($this->structure, $this->params['url'], $this->uri->getBaseUrl(), NULL, $home); if($item) { diff --git a/system/Controllers/Controller.php b/system/Controllers/Controller.php index 6dcad45..7dc2064 100644 --- a/system/Controllers/Controller.php +++ b/system/Controllers/Controller.php @@ -15,7 +15,8 @@ abstract class Controller public function __construct(ContainerInterface $c) { - $this->c = $c; + $this->c = $c; + $this->c->dispatcher->dispatch('onTwigLoaded'); } # frontend rendering @@ -23,7 +24,7 @@ abstract class Controller { # why commented this out?? $data = $this->c->dispatcher->dispatch('onPageReady', new OnPageReady($data))->getData(); - + if(isset($_SESSION['old'])) { unset($_SESSION['old']); diff --git a/system/Controllers/MetaApiController.php b/system/Controllers/MetaApiController.php index 05dd392..113235e 100644 --- a/system/Controllers/MetaApiController.php +++ b/system/Controllers/MetaApiController.php @@ -72,6 +72,9 @@ class MetaApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson($this->errors, 404); } + # set information for homepage + $this->setHomepage($args = false); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } @@ -153,6 +156,9 @@ class MetaApiController extends ContentController # set structure if(!$this->setStructure($draft = true)){ return $response->withJson($this->errors, 404); } + # set information for homepage + $this->setHomepage($args); + # set item if(!$this->setItem()){ return $response->withJson($this->errors, 404); } diff --git a/system/Controllers/PageController.php b/system/Controllers/PageController.php index 62bd779..1e22421 100644 --- a/system/Controllers/PageController.php +++ b/system/Controllers/PageController.php @@ -106,10 +106,11 @@ class PageController extends Controller } # if the user is on startpage + $home = false; if(empty($args)) { $home = true; - $item = Folder::getItemForUrl($navigation, $uri->getBasePath(), $uri->getBasePath()); + $item = Folder::getItemForUrl($navigation, $uri->getBasePath(), $uri->getBaseUrl(), NULL, $home); $urlRel = $uri->getBasePath(); } else @@ -178,7 +179,7 @@ class PageController extends Controller if(isset($item->hide) && !$item->hide) { # use the navigation instead of the structure so that hidden elements are erased - $item = Folder::getItemForUrl($navigation, $urlRel, $uri->getBasePath()); + $item = Folder::getItemForUrl($navigation, $urlRel, $uri->getBaseUrl(), NULL, $home); } } @@ -200,7 +201,7 @@ class PageController extends Controller $itemUrl = isset($item->urlRel) ? $item->urlRel : false; /* initialize parsedown */ - $parsedown = new ParsedownExtension($settings['headlineanchors']); + $parsedown = new ParsedownExtension($base_url, $settings['headlineanchors']); /* set safe mode to escape javascript and html in markdown */ $parsedown->setSafeMode(true); diff --git a/system/Extensions/ParsedownExtension.php b/system/Extensions/ParsedownExtension.php index e38d6bc..65a28bb 100644 --- a/system/Extensions/ParsedownExtension.php +++ b/system/Extensions/ParsedownExtension.php @@ -6,7 +6,7 @@ use \URLify; class ParsedownExtension extends \ParsedownExtra { - function __construct($showAnchor = NULL, $skipAbsoluteUrls = NULL) + function __construct($baseUrl = '', $showAnchor = NULL) { parent::__construct(); @@ -14,7 +14,7 @@ class ParsedownExtension extends \ParsedownExtra $this->showAnchor = $showAnchor; # base url is needed for media/images and relative links (e.g. if www.mydomain.com/mywebsite) - $this->baseUrl = $skipAbsoluteUrls ? '' : TM_BASE_URL; + $this->baseUrl = $baseUrl; # math support $this->BlockTypes['\\'][] = 'Math'; diff --git a/system/Middleware/assetMiddleware.php b/system/Middleware/assetMiddleware.php new file mode 100644 index 0000000..46b9dfc --- /dev/null +++ b/system/Middleware/assetMiddleware.php @@ -0,0 +1,40 @@ +view = $view; + $this->container = $container; + } + + public function __invoke(Request $request, Response $response, $next) + { + + # get the uri after proxy detection + $uri = $request->getUri()->withUserInfo(''); + + # update the asset object in the container (for plugins) with the new url + $this->container->assets->setBaseUrl($uri->getBaseUrl()); + + # add the asset object to twig-frontend for themes + $this->container['view']->getEnvironment()->addGlobal('assets', $this->container['assets']); + + # use {{ base_url() }} in twig templates + $this->container['view']['base_url'] = $uri->getBaseUrl(); + $this->container['view']['current_url'] = $uri->getPath(); + + $response = $next($request, $response); + + return $response; + } +} \ No newline at end of file diff --git a/system/Models/Folder.php b/system/Models/Folder.php index 53e2541..1df2d86 100644 --- a/system/Models/Folder.php +++ b/system/Models/Folder.php @@ -267,11 +267,11 @@ class Folder } } - public static function getItemForUrl($folderContentDetails, $url, $baseUrl, $result = NULL) + public static function getItemForUrl($folderContentDetails, $url, $baseUrl, $result = NULL, $home = NULL ) { # if we are on the homepage - if($url == '/' OR $url == $baseUrl) + if($home) { # return a standard item-object $item = new \stdClass; diff --git a/system/Plugin.php b/system/Plugin.php index 2ec3eaa..329e0e5 100644 --- a/system/Plugin.php +++ b/system/Plugin.php @@ -49,7 +49,7 @@ abstract class Plugin implements EventSubscriberInterface ->withHeader("Content-Type", "application/json") ->withStatus(400) ->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); - } + } protected function getSettings() { diff --git a/system/Settings.php b/system/Settings.php index 6119810..f29aa05 100644 --- a/system/Settings.php +++ b/system/Settings.php @@ -82,7 +82,7 @@ class Settings 'editor' => 'visual', 'formats' => ['markdown', 'headline', 'ulist', 'olist', 'table', 'quote', 'notice', 'image', 'video', 'file', 'toc', 'hr', 'definition', 'code'], 'contentFolder' => 'content', - 'version' => '1.3.8', + 'version' => '1.4.0', 'setup' => true, 'welcome' => true, 'images' => ['live' => ['width' => 820], 'thumbs' => ['width' => 250, 'height' => 150]], diff --git a/system/author/languages/en.yaml b/system/author/languages/en.yaml index 466252c..55145d4 100644 --- a/system/author/languages/en.yaml +++ b/system/author/languages/en.yaml @@ -227,3 +227,19 @@ CONFIGURE_YOUR_WEBSITE: Configure your website GIVE_YOUR_NEW_WEBSITE_A_NAME__ADD_THE_AUTHOR_AND_CHOOSE_A_COPYRIGHT_: Give your new website a name, add the author and choose a copyright. CHOOSE_A_THEME_FOR_YOUR_WEBSITE_AND_CONFIGURE_THE_THEME_DETAILS_: Choose a theme for your website and configure the theme details. ADD_NEW_FEATURES_TO_YOUR_WEBSITE_WITH_PLUGINS_AND_CONFIGURE_THEM_: Add new features to your website with plugins and configure them. + +DEVELOPER: Developer +THE_FOLLOWING_OPTIONS_ARE_ONLY_FOR_DEVELOPERS: The following options are only for developers and experienced administrators. Only change the options if you really understand them. For example: Never activate the error reporting for a live website, use this option only for bug-fixing. +ERROR_REPORTING: Error Reporting +DISPLAY_APPLICATION_ERRORS: Display Application Errors +TWIG_CACHE: Twig Cache +ACTIVATE_CACHE_FOR_TWIG_TEMPLATES: Activate Cache for Twig Templates +DELETE_ALL_CACHE_FILES: Delete all cache files +CLEAR_CACHE: Clear Cache +STANDARD_WIDTH_FOR_IMAGES: Standard width for images +THIS_APPLIES_ONLY_FOR_FUTURE_IMAGES_IN_THE_CONTENT_AREA_: This applies only for future images in the content area. +STANDARD_HEIGHT_FOR_IMAGES: Standard height for images +IF_YOU_ADD_A_VALUE_FOR_THE_HEIGHT__THEN_THE_IMAGE_WILL_BE_CROPPED_: If you add a value for the height, then the image will be cropped. +PROXY: Proxy +USE_X_FORWARDED_HEADERS: Use X-Forwarded Headers +TRUSTED_IPS_FOR_PROXY_(COMMA_SEPARATED): Trusted IPs for proxy (comma separated) diff --git a/system/author/languages/it.yaml b/system/author/languages/it.yaml index 02da3ff..5bf045a 100644 --- a/system/author/languages/it.yaml +++ b/system/author/languages/it.yaml @@ -227,3 +227,19 @@ CONFIGURE_YOUR_WEBSITE: Configura il tuo sito GIVE_YOUR_NEW_WEBSITE_A_NAME__ADD_THE_AUTHOR_AND_CHOOSE_A_COPYRIGHT_: Dai un nome al tuo nuovo sito, aggiungi l'autore e scegli un diritto d'autore. CHOOSE_A_THEME_FOR_YOUR_WEBSITE_AND_CONFIGURE_THE_THEME_DETAILS_: Scegli un tema per il tuo sito e configura i dettagli del tema. ADD_NEW_FEATURES_TO_YOUR_WEBSITE_WITH_PLUGINS_AND_CONFIGURE_THEM_: Aggiungi nuove funzionalità al tuo sito mediante plugin e configurali. + +DEVELOPER: Sviluppatore +THE_FOLLOWING_OPTIONS_ARE_ONLY_FOR_DEVELOPERS: Le seguenti opzioni sono solo per sviluppatori e amministratori esperti. Cambia le opzioni solo se le capisci davvero. Ad esempio: non attivare mai la segnalazione degli errori per un sito Web live, utilizzare questa opzione solo per la correzione dei bug. +ERROR_REPORTING: Segnalazione errori +DISPLAY_APPLICATION_ERRORS: Visualizza errori dell'applicazione +TWIG_CACHE: Twig Cache +ACTIVATE_CACHE_FOR_TWIG_TEMPLATES: Attiva la cache per i modelli Twig +DELETE_ALL_CACHE_FILES: Elimina tutti i file della cache +CLEAR_CACHE: Cancella cache +STANDARD_WIDTH_FOR_IMAGES: Larghezza standard per le immagini +THIS_APPLIES_ONLY_FOR_FUTURE_IMAGES_IN_THE_CONTENT_AREA_: Questo vale solo per le immagini future nell'area del contenuto. +STANDARD_HEIGHT_FOR_IMAGES: Altezza standard per le immagini +IF_YOU_ADD_A_VALUE_FOR_THE_HEIGHT__THEN_THE_IMAGE_WILL_BE_CROPPED_: Se aggiungi un valore per l'altezza, l'immagine verrà ritagliata. +PROXY: Proxy +USE_X_FORWARDED_HEADERS: Usa intestazioni con X-Forwarded +TRUSTED_IPS_FOR_PROXY_(COMMA_SEPARATED): IP affidabili per proxy (separati da virgole) diff --git a/system/author/layouts/layout.twig b/system/author/layouts/layout.twig index b63a8af..31aa1b6 100644 --- a/system/author/layouts/layout.twig +++ b/system/author/layouts/layout.twig @@ -17,8 +17,8 @@ - - + + {{ assets.renderCSS() }} @@ -41,16 +41,16 @@ - + - - - - - + + + + + diff --git a/system/author/layouts/layoutAuth.twig b/system/author/layouts/layoutAuth.twig index 24ce000..7d2790b 100644 --- a/system/author/layouts/layoutAuth.twig +++ b/system/author/layouts/layoutAuth.twig @@ -18,7 +18,7 @@ - + {{ assets.renderCSS() }} @@ -32,6 +32,6 @@ {% block content %}{% endblock %} - + \ No newline at end of file diff --git a/system/author/layouts/layoutBlank.twig b/system/author/layouts/layoutBlank.twig index 55a25e2..031193a 100644 --- a/system/author/layouts/layoutBlank.twig +++ b/system/author/layouts/layoutBlank.twig @@ -17,7 +17,7 @@ - + diff --git a/system/author/layouts/layoutBlox.twig b/system/author/layouts/layoutBlox.twig index 8e68602..51fc28e 100644 --- a/system/author/layouts/layoutBlox.twig +++ b/system/author/layouts/layoutBlox.twig @@ -18,7 +18,7 @@ - + {{ assets.renderCSS() }} @@ -46,28 +46,28 @@ const myaxios = axios.create(); myaxios.defaults.baseURL = "{{ base_url }}"; - - - - - - + + + + + + {{ assets.renderEditorJS() }} - - - - - - - + + + + + + + {{ assets.renderJS() }} diff --git a/system/author/layouts/layoutEditor.twig b/system/author/layouts/layoutEditor.twig index c50f816..460b9fc 100644 --- a/system/author/layouts/layoutEditor.twig +++ b/system/author/layouts/layoutEditor.twig @@ -17,7 +17,7 @@ - + {{ assets.renderCSS() }} @@ -39,16 +39,16 @@ - + - - - - - + + + + + - - - + + + + {{ assets.renderJS() }} diff --git a/system/author/settings/system.twig b/system/author/settings/system.twig index 3779cb5..48a5659 100644 --- a/system/author/settings/system.twig +++ b/system/author/settings/system.twig @@ -151,7 +151,7 @@

{{ __('Developer') }}

-

The following options are only for developers and experienced administrators. Only change the options if you really understand them. For example: Never activate the error reporting for a live website, use this option only for bug-fixing.

+

{{ __('The following options are only for developers') }}

@@ -169,12 +169,12 @@
{{ __('Delete all cache files') }}
-
+
-
This applies only for future images in the content area.
+
{{ __('This applies only for future images in the content area.') }}
{% if errors.settings.images.live.width %} {{ errors.settings.images.live.width | first }} {% endif %} @@ -182,7 +182,7 @@
-
If you add a value for the height, then the image will be cropped.
+
{{ __('If you add a value for the height, then the image will be cropped.') }}
{% if errors.settings.images.live.height %} {{ errors.settings.images.live.height | first }} {% endif %} diff --git a/system/system.php b/system/system.php index 904f012..afac40e 100644 --- a/system/system.php +++ b/system/system.php @@ -48,11 +48,12 @@ $app = new \Slim\App($settings); $container = $app->getContainer(); -if(isset($settings['settings']['proxy']) && $settings['settings']['proxy']) -{ - $trustedProxies = isset($settings['settings']['trustedproxies']) ? explode(",", $settings['settings']['trustedproxies']) : []; - $app->add(new RKA\Middleware\ProxyDetection($trustedProxies)); -} +/************************ +* Create URI * +************************/ + +# get uri and delete username and password from uri +$uri = \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->withUserInfo(''); /************************ * LOAD & UPDATE PLUGINS * @@ -152,20 +153,6 @@ $container['dispatcher'] = function($container) use ($dispatcher) return $dispatcher; }; -# delete username and password from uri -$uri = $container['request']->getUri()->withUserInfo(''); - -define("TM_BASE_URL", $uri->getBaseUrl()); - -/******************************** -* ADD ASSET-FUNCTION FOR TWIG * -********************************/ - -$container['assets'] = function($c) use ($uri) -{ - return new \Typemill\Assets($uri->getBaseUrl()); -}; - /************************ * DECIDE FOR SESSION * ************************/ @@ -176,20 +163,32 @@ $session_segments = array('setup', 'tm/', 'api/', '/setup', '/tm/', '/api/'); $client_segments = $dispatcher->dispatch('onSessionSegmentsLoaded', new OnSessionSegmentsLoaded([]))->getData(); $session_segments = array_merge($session_segments, $client_segments); -$path = $uri->getPath(); $container['flash'] = false; $container['csrf'] = false; + +/************************************ +* ADD ASSET-FUNCTION FOR PLUGINS * +************************************/ + +$container['assets'] = function($c) use ($uri) +{ + return new \Typemill\Assets($uri->getBaseUrl()); +}; + +/******************************** +* MOVE TO MIDDLEWARE NEXT TIME * +********************************/ + # if website is restricted to registered user if(isset($settings['settings']['access']) && $settings['settings']['access'] == 'registered') { # activate session for all routes - $session_segments = [$path]; + $session_segments = [$uri->getPath()]; } - foreach($session_segments as $segment) { - if(substr( $path, 0, strlen($segment) ) === $segment) + if(substr( $uri->getPath(), 0, strlen($segment) ) === $segment) { // configure session ini_set('session.cookie_httponly', 1 ); @@ -240,9 +239,13 @@ $container['view'] = function ($container) use ($uri) 'debug' => true ]); - // Instantiate and add Slim specific extension - $basePath = rtrim(str_ireplace('index.php', '', $uri->getBasePath()), '/'); - $view->addExtension(new Slim\Views\TwigExtension($container['router'], $basePath)); + # Instantiate and add Slim specific extension + $router = $container->get('router'); + +# $basePath = rtrim(str_ireplace('index.php', '', $uri->getBasePath()), '/'); +# $view->addExtension(new Slim\Views\TwigExtension($container['router'], $basePath)); + + $view->addExtension(new Slim\Views\TwigExtension($router, $uri)); $view->addExtension(new Twig_Extension_Debug()); $view->addExtension(new Typemill\Extensions\TwigUserExtension()); $view->addExtension(new Typemill\Extensions\TwigMarkdownExtension()); @@ -250,34 +253,27 @@ $container['view'] = function ($container) use ($uri) $view->addExtension(new Typemill\Extensions\TwigPagelistExtension()); # use {{ base_url() }} in twig templates - $view['base_url'] = $uri->getBaseUrl(); - $view['current_url'] = $uri->getPath(); +# $view['base_url'] = $uri->getBaseUrl(); +# $view['current_url'] = $uri->getPath(); - /* if session route, add flash messages and csrf-protection */ + # if session route, add flash messages and csrf-protection if($container['flash']) { $view->getEnvironment()->addGlobal('flash', $container->flash); $view->addExtension(new Typemill\Extensions\TwigCsrfExtension($container['csrf'])); } - /* add asset-function to all views */ - $view->getEnvironment()->addGlobal('assets', $container->assets); - /****************************** * LOAD TRANSLATIONS * ******************************/ - $uri = $_SERVER['REQUEST_URI']; - - $base_path = $container['request']->getUri()->getBasePath(); - $uri = str_replace($base_path,'',$uri); - $pieces = explode('/',$uri); - if(isset($uri) && ($pieces[1] === 'tm' OR $pieces[1] === 'setup') ) + $pieces = explode('/',$uri->getPath()); + if( ($pieces[0] === 'tm' OR $pieces[0] === 'setup') ) { - // Admin environment labels + # Admin environment labels $labels = Typemill\Translations::loadTranslations('admin'); } else { - // User environment labels - // For now it is useless, but it will prove useful in the future + # User environment labels + # For now it is useless, but it will prove useful in the future $labels = Typemill\Translations::loadTranslations('user'); } $view['translations'] = $labels; @@ -286,7 +282,7 @@ $container['view'] = function ($container) use ($uri) return $view; }; -$container->dispatcher->dispatch('onTwigLoaded'); +# $container->dispatcher->dispatch('onTwigLoaded'); /*************************** * ADD NOT FOUND HANDLER * @@ -318,6 +314,22 @@ if($container['flash']) $app->add($container->get('csrf')); } +/******************************** +* ASSET MIDDLEWARE FOR TWIG * +********************************/ + +$app->add(new \Typemill\Middleware\assetMiddleware($container)); + +/******************************** +* PROXY DETECTION FOR REQUEST * +********************************/ + +if(isset($settings['settings']['proxy']) && $settings['settings']['proxy']) +{ + $trustedProxies = ( isset($settings['settings']['trustedproxies']) && !empty($settings['settings']['trustedproxies']) ) ? explode(",", $settings['settings']['trustedproxies']) : []; + $app->add(new RKA\Middleware\ProxyDetection($trustedProxies)); +} + /************************ * ADD ROUTES * ************************/ diff --git a/themes/cyanine/home/landingpageNews.twig b/themes/cyanine/home/landingpageNews.twig index 6cf9218..2edc20f 100644 --- a/themes/cyanine/home/landingpageNews.twig +++ b/themes/cyanine/home/landingpageNews.twig @@ -17,7 +17,7 @@
  • - {{ page.meta.heroimagealt }} + {{ page.meta.heroimagealt }}