1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

Rawilum init commit

This commit is contained in:
Awilum
2018-03-09 13:11:52 +03:00
parent 45919fe09e
commit 47ee8ce50b
34 changed files with 1294 additions and 1 deletions

6
.gitignore vendored Executable file
View File

@@ -0,0 +1,6 @@
.idea
.DS_Store
composer.phar
composer.lock
vendor
site-katerinasitnikova

63
.htaccess Executable file
View File

@@ -0,0 +1,63 @@
#
# This file is part of the Rawilum.
#
# (c) Romanenko Sergey / Awilum <awilum@msn.com>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# Set default charset utf-8
AddDefaultCharset UTF-8
# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag magic_quotes_sybase off
php_flag register_globals off
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Rawilum
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Rewrite rules for Rawilum
RewriteBase /rawilum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
## End - Rewrite rules for Rawilum
## Begin - Rewrite rules for SEO improvements.
# RewriteCond %{HTTP_HOST} ^www.example.org [NC]
# RewriteRule ^(.*)$ http://example.org/$1 [R=301,L]
# Redirect 301 /index http://example.org/
## End - Rewrite rules for SEO improvements.
</IfModule>
# Prevent visitors from viewing files directly.
<FilesMatch "(^#.*#|\.(md|txt|html|tpl|yml|yaml)|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes

2
CHANGELOG.md Executable file
View File

@@ -0,0 +1,2 @@
# Rawilum 0.0.0, 2018-03-30
*

21
LICENSE.md Executable file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Rawilum Content Management
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

48
README.md Normal file → Executable file
View File

@@ -1 +1,47 @@
# rawilum
# Rawilum
[![Join the chat at https://gitter.im/Rawilum/Rawilum](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Rawilum/Rawilum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Rawilum is Modern Open Source Flat-File Content Management site.
Content in Rawilum is just a simple files written with markdown syntax in pages folder.
You simply create markdown files in the pages folder and that becomes a page.
## Requirements
PHP 5.5.9 or higher with PHP's [Multibyte String module](http://php.net/mbstring)
Apache with [Mod Rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html)
## Installation
#### Using (S)FTP
[Download the latest version.](http://rawilum.org/download)
Unzip the contents to a new folder on your local computer, and upload to your webhost using the (S)FTP client of your choice. After youve done this, be sure to chmod the following directories (with containing files) to 777, so they are readable and writable by Rawilum:
* `cache/`
* `config/`
* `storage/`
* `themes/`
* `plugins/`
#### Using Composer
You can easily install Rawilum with Composer.
```
composer create-project rawilum-cms/rawilum
```
## Contributing
1. Help on the [Forum.](http://forum.Rawilum.org)
2. Develop a new plugin.
3. Create a new theme.
4. Find and [report issues.](https://github.com/Rawilum/Rawilum/issues)
5. Link back to [Rawilum](http://rawilum.org).
## Links
- [Site](http://rawilum.org)
- [Forum](http://forum.Rawilum.org)
- [Documentation](http://rawilum.org/documentation)
- [Github Repository](https://github.com/Rawilum/Rawilum)
## License
See [LICENSE](https://github.com/Rawilum/Rawilum/blob/master/LICENSE.md)

46
composer.json Executable file
View File

@@ -0,0 +1,46 @@
{
"name": "rawilum-cms/rawilum",
"type": "library",
"description": "Rawilum is Modern Open Source Flat-File Content Management System",
"keywords": ["Rawilum", "php", "cms", "flat-file", "markdown"],
"homepage": "http://rawilum.org",
"license": "MIT",
"authors": [
{
"name": "Sergey Romanenko",
"email": "awilum@msn.com",
"homepage": "https://github.com/Awilum"
}
],
"support": {
"issues": "https://github.com/rawilum-cms/rawilum/issues"
},
"require": {
"php": ">=7.1.3",
"erusev/parsedown": "1.7.0",
"erusev/parsedown-extra": "0.7.1",
"doctrine/cache": "1.7.1",
"symfony/yaml": "4.0.4",
"symfony/console": "4.0.4",
"symfony/filesystem": "4.0.4",
"symfony/finder": "4.0.4",
"symfony/event-dispatcher": "4.0.5",
"pimple/pimple": "3.2.3",
"klein/klein": "2.1.2",
altorouter/altorouter: "",
"force/session" : "*",
"force/shortcode" : "*",
"force/arr" : "*",
"force/http" : "*",
"force/token" : "*",
"force/url" : "*"
},
"autoload": {
"classmap": [
"Rawilum"
],
"files": [
"rawilum/boot/defines.php"
]
}
}

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

29
index.php Executable file
View File

@@ -0,0 +1,29 @@
<?php
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Rawilum;
// Register the auto-loader.
$autoload = __DIR__ . '/vendor/autoload.php';
// Ensure vendor libraries exist
!is_file($autoload) and exit("Please run: <i>composer install</i>");
// Register the auto-loader.
$loader = require_once $autoload;
// Check PHP Version
version_compare($ver = PHP_VERSION, $req = '7.1.3', '<') and exit(sprintf('You are running PHP %s, but Rawilum needs at least <strong>PHP %s</strong> to run.', $ver, $req));
// Get Rawilum Instance
$app = Rawilum::instance();
// Run Rawilum Application
$app->run();

242
monstra/Cache.php Executable file
View File

@@ -0,0 +1,242 @@
<?php
namespace Rawilum;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Cache
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* Unique cache key
*
* @var string Cache key.
*/
protected static $key;
/**
* Lifetime
*
* @var int Lifetime.
*/
protected static $lifetime;
/**
* Current time
*
* @var int Current time.
*/
protected static $now;
/**
* Cache Driver
*
* @var DoctrineCache
*/
protected static $driver;
/**
* Constructor.
*
* @access protected
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
// Set current time
static::$now = time();
// Cache key allows us to invalidate all cache on configuration changes.
static::$key = ($this->rawilum['config']->get('site.cache.prefix') ? $this->rawilum['config']->get('site.cache.prefix') : 'rawilum') . '-' . md5(ROOT_DIR . 'Rawilum::VERSION');
// Get Cache Driver
static::$driver = $this->getCacheDriver();
// Set the cache namespace to our unique key
static::$driver->setNamespace(static::$key);
// Return
return static::$driver;
}
/**
* Get Cache Driver
*
* @access public
* @return object
*/
public function getCacheDriver()
{
$driver_name = $this->rawilum['config']->get('site.cache.driver');
if (!$driver_name || $driver_name == 'auto') {
if (extension_loaded('apc')) {
$driver_name = 'apc';
} elseif (extension_loaded('wincache')) {
$driver_name = 'wincache';
} elseif (extension_loaded('xcache')) {
$driver_name = 'xcache';
}
} else {
$driver_name = 'file';
}
switch ($driver_name) {
case 'apc':
$driver = new \Doctrine\Common\Cache\ApcCache();
break;
case 'wincache':
$driver = new \Doctrine\Common\Cache\WinCacheCache();
break;
case 'xcache':
$driver = new \Doctrine\Common\Cache\XcacheCache();
break;
case 'memcache':
$memcache = new \Memcache();
$memcache->connect($this->rawilum['config']->get('site.cache.memcache.server', 'localhost'),
$this->rawilum['config']->get('site.cache.memcache.port', 11211));
$driver = new \Doctrine\Common\Cache\MemcacheCache();
$driver->setMemcache($memcache);
break;
case 'redis':
$redis = new \Redis();
$redis->connect($this->rawilum['config']->get('site.cache.redis.server', 'localhost'),
$this->rawilum['config']->get('site.cache.redis.port', 6379));
$driver = new \Doctrine\Common\Cache\RedisCache();
$driver->setRedis($redis);
break;
default:
// Create doctrine cache directory if its not exists
!$this->rawilum['filesystem']->exists($cache_directory = CACHE_PATH . '/doctrine/') and $this->rawilum['filesystem']->mkdir($cache_directory);
$driver = new \Doctrine\Common\Cache\FilesystemCache($cache_directory);
break;
}
return $driver;
}
/**
* Returns driver variable
*
* @access public
* @return object
*/
public function driver()
{
return static::$driver;
}
/**
* Get cache key.
*
* @access public
* @return string
*/
public function getKey()
{
return static::$key;
}
/**
* Fetches an entry from the cache.
*
* @access public
* @param string $id The id of the cache entry to fetch.
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
*/
public function fetch($id)
{
if ($this->rawilum['config']->get('site.cache.enabled')) {
return static::$driver->fetch($id);
} else {
return false;
}
}
/**
* Puts data into the cache.
*
* @access public
* @param string $id The cache id.
* @param mixed $data The cache entry/data.
* @param int $lifeTime The lifetime in number of seconds for this cache entry.
* If zero (the default), the entry never expires (although it may be deleted from the cache
* to make place for other entries).
*/
public function save($id, $data, $lifetime = null)
{
if ($this->rawilum['config']->get('site.cache.enabled')) {
if ($lifetime === null) {
$lifetime = static::getLifetime();
}
static::$driver->save($id, $data, $lifetime);
}
}
/**
* Clear Cache
*/
public function clear()
{
$this->rawilum['filesystem']->remove(CACHE_PATH . '/doctrine/');
}
/**
* Set the cache lifetime.
*
* @access public
* @param int $future timestamp
*/
public function setLifetime($future)
{
if (!$future) {
return;
}
$interval = $future - $this->now;
if ($interval > 0 && $interval < static::getLifetime()) {
static::$lifetime = $interval;
}
}
/**
* Retrieve the cache lifetime (in seconds)
*
* @access public
* @return mixed
*/
public function getLifetime()
{
if (static::$lifetime === null) {
static::$lifetime = $this->rawilum['config']->get('site.cache.lifetime') ?: 604800;
}
return static::$lifetime;
}
/**
* Initialize Rawilum Cache
*
* <code>
* Cache::init();
* </code>
*
* @access public
* @return object
*/
public function init()
{
}
}

82
monstra/Config.php Executable file
View File

@@ -0,0 +1,82 @@
<?php
namespace Rawilum;
use Arr;
use Symfony\Component\Yaml\Yaml;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Config
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* Config
*
* @var array
* @access protected
*/
protected static $config = [];
/**
* Constructor.
*
* @access protected
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
if ($this->rawilum['filesystem']->exists($site_config = CONFIG_PATH . '/' . 'site.yml')) {
self::$config['site'] = Yaml::parse(file_get_contents($site_config));
} else {
throw new RuntimeException("Rawilum site config file does not exist.");
}
}
/**
* Set new or update existing config variable
*
* @access public
* @param string $key Key
* @param mixed $value Value
*/
public function set($key, $value)
{
Arr::set(self::$config, $key, $value);
}
/**
* Get config variable
*
* @access public
* @param string $key Key
* @param mixed $default Default value
* @return mixed
*/
public function get($key, $default = null)
{
return Arr::get(self::$config, $key, $default);
}
/**
* Get config array
*
* @access public
* @return array
*/
public function getConfig()
{
return self::$config;
}
}

128
monstra/Filter.php Executable file
View File

@@ -0,0 +1,128 @@
<?php
namespace Rawilum;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Filter
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* Filters
*
* @var array
* @access protected
*/
protected static $filters = [];
/**
* Construct
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
}
/**
* Apply filters
*
* <code>
* Filter::apply('content', $content);
* </code>
*
* @access public
* @param string $filter_name The name of the filter hook.
* @param mixed $value The value on which the filters hooked.
* @return mixed
*/
public function dispatch($filter_name, $value)
{
// Redefine arguments
$filter_name = (string) $filter_name;
$args = array_slice(func_get_args(), 2);
if (! isset(static::$filters[$filter_name])) {
return $value;
}
foreach (static::$filters[$filter_name] as $priority => $functions) {
if (! is_null($functions)) {
foreach ($functions as $function) {
$all_args = array_merge(array($value), $args);
$function_name = $function['function'];
$accepted_args = $function['accepted_args'];
if ($accepted_args == 1) {
$the_args = array($value);
} elseif ($accepted_args > 1) {
$the_args = array_slice($all_args, 0, $accepted_args);
} elseif ($accepted_args == 0) {
$the_args = null;
} else {
$the_args = $all_args;
}
$value = call_user_func_array($function_name, $the_args);
}
}
}
return $value;
}
/**
* Add filter
*
* <code>
* Filter::add('content', 'replacer');
*
* function replacer($content) {
* return preg_replace(array('/\[b\](.*?)\[\/b\]/ms'), array('<strong>\1</strong>'), $content);
* }
* </code>
*
* @access public
* @param string $filter_name The name of the filter to hook the $function_to_add to.
* @param string $function_to_add The name of the function to be called when the filter is applied.
* @param integer $priority Function to add priority - default is 10.
* @param integer $accepted_args The number of arguments the function accept default is 1.
* @return boolean
*/
public function addListener($filter_name, $function_to_add, $priority = 10, $accepted_args = 1)
{
// Redefine arguments
$filter_name = (string) $filter_name;
$function_to_add = $function_to_add;
$priority = (int) $priority;
$accepted_args = (int) $accepted_args;
//die($function_to_add);
// Check that we don't already have the same filter at the same priority. Thanks to WP :)
if (isset(static::$filters[$filter_name]["$priority"])) {
foreach (static::$filters[$filter_name]["$priority"] as $filter) {
if ($filter['function'] == $function_to_add) {
return true;
}
}
}
static::$filters[$filter_name]["$priority"][] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
// Sort
ksort(static::$filters[$filter_name]["$priority"]);
return true;
}
}

141
monstra/Monstra.php Executable file
View File

@@ -0,0 +1,141 @@
<?php
namespace Rawilum;
use Pimple\Container as Container;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use \Klein\Klein;
use ParsedownExtra;
/**
* Rawilum
*
* @package Rawilum
* @author Romanenko Sergey / Awilum <awilum@msn.com>
* @link http://rawilum.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Rawilum extends Container
{
/**
* An instance of the Rawilum class
*
* @var object
* @access protected
*/
protected static $instance;
/**
* The version of Rawilum
*
* @var string
*/
const VERSION = 'X.X.X alfa';
/**
* Init Rawilum Application
*/
protected static function init()
{
$container = new static();
$container['filesystem'] = function ($c) {
return new Filesystem();
};
$container['finder'] = function ($c) {
return new Finder();
};
$container['cache'] = function ($c) {
return new Cache($c);
};
$container['config'] = function ($c) {
return new Config($c);
};
$container['router'] = function ($c) {
return new \Klein\Klein();
};
// Start the session
//\Session::start();
$container['events'] = function ($c) {
return new EventDispatcher();
};
$container['filters'] = function ($c) {
return new Filter($c);
};
$container['plugins'] = function ($c) {
return new Plugins($c);
};
$container['plugins']->init();
$container['markdown'] = function ($c) {
return new ParsedownExtra();
};
$container['pages'] = function ($c) {
return new Pages($c);
};
$container['themes'] = function ($c) {
return new Themes($c);
};
$container['router']->dispatch();
return $container;
}
/**
* Run Rawilum Application
*/
public function run()
{
// Turn on output buffering
ob_start();
// Display Errors
$this['config']->get('site.errors.display') and error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED);
// Set internal encoding
function_exists('mb_language') and mb_language('uni');
function_exists('mb_regex_encoding') and mb_regex_encoding($this['config']->get('site.charset'));
function_exists('mb_internal_encoding') and mb_internal_encoding($this['config']->get('site.charset'));
// Set default timezone
date_default_timezone_set($this['config']->get('site.timezone'));
// Render page
$this['pages']->renderPage($this['pages']->getPage(\Url::getUriString()));
// Flush (send) the output buffer and turn off output buffering
ob_end_flush();
}
/**
* Get Rawilum Application Instance
*
* @access public
* @return object
*/
public static function instance()
{
if (!self::$instance) {
self::$instance = static::init();
RawilumTrait::setRawilum(self::$instance);
}
return self::$instance;
}
}

31
monstra/MonstraTrait.php Executable file
View File

@@ -0,0 +1,31 @@
<?php
namespace Rawilum;
trait RawilumTrait
{
/**
* @var Rawilum
*/
protected static $rawilum;
/**
* @return Rawilum
*/
public static function getRawilum()
{
if (!self::$rawilum) {
self::$rawilum = Rawilum::instance();
}
return self::$rawilum;
}
/**
* @param Rawilum $rawilum
*/
public static function setRawilum(Rawilum $rawilum)
{
self::$rawilum = $rawilum;
}
}

136
monstra/Page.php Executable file
View File

@@ -0,0 +1,136 @@
<?php
namespace Rawilum;
use Url;
use Response;
use Symfony\Component\Yaml\Yaml;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Page
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* __construct
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
}
/**
* Get page
*/
public function getPage($url = '', $raw = false, $url_abs = false)
{
$file = $this->finder($url, $url_abs);
if ($raw) {
$page = trim(file_get_contents($file));
} else {
$page = $this->parse($file);
$page_frontmatter = $page['frontmatter'];
$page_content = $page['content'];
$page = $page_frontmatter;
// Parse page for summary <!--more-->
if (($pos = strpos($page_content, "<!--more-->")) === false) {
$page_content = $this->rawilum['filters']->dispatch('content', $page_content);
} else {
$page_content = explode("<!--more-->", $page_content);
$page['summary'] = $this->rawilum['filters']->dispatch('content', $page_content[0]);
$page['content'] = $this->rawilum['filters']->dispatch('content', $page_content[0].$page_content[1]);
}
if (is_array($page_content)) {
$page['summary'] = $this->rawilum['markdown']->text($page['summary']);
$page['content'] = $this->rawilum['markdown']->text($page['content']);
} else {
$page['content'] = $this->rawilum['markdown']->text($page_content);
}
}
return $page;
}
/**
* Page finder
*/
public function finder($url = '', $url_abs = false)
{
// If url is empty that its a homepage
if ($url_abs) {
if ($url) {
$file = $url;
} else {
$file = CONTENT_PATH . '/pages/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md';
}
} else {
if ($url) {
$file = CONTENT_PATH . '/pages/' . $url . '/index.md';
} else {
$file = CONTENT_PATH . '/pages/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md';
}
}
// Get 404 page if file not exists
if ($this->rawilum['filesystem']->exists($file)) {
$file = $file;
} else {
$file = CONTENT_PATH . '/pages/404/index.md';
Response::status(404);
}
return $file;
}
/**
* Render page
*/
public function renderPage($page)
{
$template_ext = '.php';
$template_name = empty($page['template']) ? 'index' : $page['template'];
include THEMES_PATH . '/' . $this->rawilum['config']->get('site.theme') . '/' . $template_name . $template_ext;
}
/**
* Page parser
*/
public function parse($file)
{
$page = trim(file_get_contents($file));
$page = explode('---', $page, 3);
$frontmatter = Yaml::parse($page[1]);
$content = $page[2];
$url = str_replace(CONTENT_PATH . '/pages', Url::getBase(), $file);
$url = str_replace('index.md', '', $url);
$url = str_replace('.md', '', $url);
$url = str_replace('\\', '/', $url);
$url = rtrim($url, '/');
$frontmatter['url'] = $url;
$frontmatter['slug'] = basename($file, '.md');
return ['frontmatter' => $frontmatter, 'content' => $content];
}
}

54
monstra/Pages.php Executable file
View File

@@ -0,0 +1,54 @@
<?php
namespace Rawilum;
use Arr;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Pages extends Page
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* Construct
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
}
/**
* getPage
*/
public function getPages($url = '', $raw = false, $order_by = 'date', $order_type = 'DESC', $ignore = ['404', 'index'], $limit = null)
{
// Get pages list for current $url
$pages_list = $this->rawilum['finder']->files()->name('*.md')->in(CONTENT_PATH . '/pages/' . $url);
// Go trough pages list
foreach ($pages_list as $key => $page) {
$pages[$key] = $this->getPage($page->getPathname(), $raw, true);
}
// Sort and Slice pages if !$raw
if (!$raw) {
$pages = Arr::subvalSort($pages, $order_by, $order_type);
if ($limit != null) {
$pages = array_slice($_pages, null, $limit);
}
}
return $pages;
}
}

28
monstra/Plugin.php Executable file
View File

@@ -0,0 +1,28 @@
<?php
namespace Rawilum;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Plugin
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* __construct
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
}
}

63
monstra/Plugins.php Executable file
View File

@@ -0,0 +1,63 @@
<?php
namespace Rawilum;
use Symfony\Component\Yaml\Yaml;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Plugins
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* __construct
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
$rawilum = $this->rawilum;
$plugin_manifest = [];
// Get Plugins List
$plugins_list = $this->rawilum['config']->get('site.plugins');
// @TODO THIS with cache then
// If Plugins List isnt empty
if (is_array($plugins_list) && count($plugins_list) > 0) {
// Go through...
foreach ($plugins_list as $plugin) {
if (file_exists($_plugin_manifest = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yml')) {
$plugin_manifest = Yaml::parse(file_get_contents($_plugin_manifest));
}
$_plugins_config[basename($_plugin_manifest)] = array_merge($plugin_manifest, $plugin_settings);
}
}
if (is_array($this->rawilum['config']->get('site.plugins')) && count($this->rawilum['config']->get('site.plugins')) > 0) {
foreach ($this->rawilum['config']->get('site.plugins') as $plugin_id => $plugin_name) {
//echo '@@@'.$plugins;
//if ($this->rawilum['config']->get('plugins.'.$plugin_name.'.enabled')) {
//echo $plugin_name;
include_once PLUGINS_PATH .'/'. $plugin_name .'/'. $plugin_name . '.php';
}
}
}
public function init() {
}
}

35
monstra/Themes.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
namespace Rawilum;
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Themes
{
/**
* @var Rawilum
*/
protected $rawilum;
/**
* __construct
*/
public function __construct(Rawilum $c)
{
$this->rawilum = $c;
}
public function getTemplate($template_name)
{
$template_ext = '.php';
include THEMES_PATH . '/' . $this->rawilum['config']->get('site.theme') . '/' . $template_name . $template_ext;
}
}

31
monstra/boot/defines.php Executable file
View File

@@ -0,0 +1,31 @@
<?php
/**
* This file is part of the Rawilum.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// Define the path to the root directory (without trailing slash).
define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
// Define the path to the site directory (without trailing slash).
define('SITE_PATH', ROOT_DIR . '/site-katerinasitnikova');
// Define the path to the content directory (without trailing slash).
define('CONTENT_PATH', SITE_PATH . '/content');
// Define the path to the themes directory (without trailing slash).
define('THEMES_PATH', SITE_PATH . '/themes');
// Define the path to the plugins directory (without trailing slash).
define('PLUGINS_PATH', SITE_PATH . '/plugins');
// Define the path to the config directory (without trailing slash).
define('CONFIG_PATH', SITE_PATH . '/config');
// Define the path to the cache directory (without trailing slash).
define('CACHE_PATH', SITE_PATH . '/cache');

5
robots.txt Executable file
View File

@@ -0,0 +1,5 @@
User-agent: *
Disallow: /rawilum/
Disallow: /site/plugins/
Disallow: /site/config/
Disallow: /vendor/

0
site/cache/.gitkeep vendored Executable file
View File

28
site/config/site.yml Executable file
View File

@@ -0,0 +1,28 @@
# Site configuration
title: 'Rawilum'
description: 'Modern Open Source Flat-File Content Management System'
author:
email: ''
# System Configuration
timezone: UTC
charset: UTF-8
theme: default
plugins:
pages:
flush_cache: false
errors:
display: false
cache:
enabled: false
prefix: Rawilum
driver: auto
lifetime: 604800

View File

@@ -0,0 +1 @@
Check **Rawilum** documentation for more details: http://rawilum.org/documentation

View File

@@ -0,0 +1,7 @@
---
title: Error 404
robots: noindex,nofollow
---
## Error 404
We're sorry but the page you are looking for doesn't appear to exist!

View File

@@ -0,0 +1,15 @@
---
title: Contact
description: Rawilum is a simple and light-weighted Content Management System
---
## Stay in touch
[Rawilum official site](http://Rawilum.org/)
[Rawilum forum](http://forum.Rawilum.org/)
[Rawilum on Github](https://github.com/Rawilum/Rawilum)
[Rawilum Gitter chat room](https://gitter.im/Rawilum/Rawilum)
## Follow us on Twitter
Follow Rawilum on Twitter [@Rawilum_cms](https://twitter.com/Rawilum_cms)

View File

@@ -0,0 +1,7 @@
---
title: Главная страница
description: страница
template: home
---
home

0
site/plugins/.gitkeep Executable file
View File

View File

13
site/themes/default/default.yml Executable file
View File

@@ -0,0 +1,13 @@
name: Default
version: 1.0.0
description: Default Rawilum theme
author:
name: Sergey Romanenko
email: awilum@msn.com
url: https://github.com/Awilum
homepage: https://github.com/Rawilum/Rawilum
bugs: https://github.com/Rawilum/Rawilum/issues
license: MIT
# Theme settings
enabled: true

3
site/themes/default/index.php Executable file
View File

@@ -0,0 +1,3 @@
<?php Theme::getTemplate('partials/head'); ?>
<?php echo Pages::getCurrentPage()['content']; ?>
<?php Theme::getTemplate('partials/footer'); ?>

View File

@@ -0,0 +1,3 @@
<?php Theme::getTemplate('partials/tail'); ?>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<?php Action::run('theme_meta'); ?>
<link rel="shortcut icon" href="<?php echo Url::getBase(); ?>/favicon.ico">
<title><?php echo Config::get('site.title'); ?> | <?php echo Pages::getCurrentPage()['title']; ?></title>
<!-- Bootstrap core CSS -->
<link href="<?php echo Url::getBase(); ?>/site/themes/<?php echo Config::get('site.theme'); ?>/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="<?php echo Url::getBase(); ?>/site/themes/<?php echo Config::get('site.theme'); ?>/assets/css/theme.css" rel="stylesheet">
<?php Action::run('theme_header'); ?>
</head>
<body>
<?php Theme::getTemplate('partials/navigation'); ?>

View File

@@ -0,0 +1 @@
navigation here

View File

@@ -0,0 +1,3 @@
<script src="<?php echo Url::getBase(); ?>/site-katerinasitnikova/themes/<?php echo Config::get('site.theme'); ?>/node_modules/jquery/dist/jquery.slim.min.js"></script>
<script src="<?php echo Url::getBase(); ?>/site-katerinasitnikova/themes/<?php echo Config::get('site.theme'); ?>/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<?php Action::run('theme_footer'); ?>