mirror of
https://github.com/flextype/flextype.git
synced 2025-01-17 20:58:29 +01:00
Using Flextype Components
This commit is contained in:
parent
50df760b2e
commit
06d544a2cd
@ -13,7 +13,7 @@
|
||||
namespace Flextype;
|
||||
|
||||
use Symfony\Component\{Filesystem\Filesystem, Finder\Finder};
|
||||
use Flextype\Component\{Url\Url, Session\Session};
|
||||
use Flextype\Component\{Http\Http, Session\Session};
|
||||
|
||||
class Flextype
|
||||
{
|
||||
@ -157,12 +157,13 @@ class Flextype
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype Application
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
* Return the Flextype instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new Flextype();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\{Arr\Arr, Url\Url, Response\Response};
|
||||
use Flextype\Component\{Arr\Arr, Http\Http};
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Pages
|
||||
@ -53,7 +53,7 @@ class Pages
|
||||
Events::dispatch('onPageBeforeRender');
|
||||
|
||||
// Get current page
|
||||
static::$page = static::getPage(Url::getUriString());
|
||||
static::$page = static::getPage(Http::getUriString());
|
||||
|
||||
// Display page for current requested url
|
||||
static::renderPage(static::$page);
|
||||
@ -90,7 +90,7 @@ class Pages
|
||||
$file = $file;
|
||||
} else {
|
||||
$file = PAGES_PATH . '/404/index.md';
|
||||
Response::status(404);
|
||||
Http::setResponseStatus(404);
|
||||
}
|
||||
|
||||
return $file;
|
||||
@ -125,7 +125,7 @@ class Pages
|
||||
$result_page = Yaml::parse($frontmatter);
|
||||
|
||||
// Get page url
|
||||
$url = str_replace(PAGES_PATH, Url::getBase(), $file);
|
||||
$url = str_replace(PAGES_PATH, Http::getBaseUrl(), $file);
|
||||
$url = str_replace('index.md', '', $url);
|
||||
$url = str_replace('.md', '', $url);
|
||||
$url = str_replace('\\', '/', $url);
|
||||
@ -138,10 +138,10 @@ class Pages
|
||||
$result_page['url'] = $url;
|
||||
|
||||
// Get page slug
|
||||
$url = str_replace(Url::getBase(), '', $url);
|
||||
$url = str_replace(Http::getBaseUrl(), '', $url);
|
||||
$url = ltrim($url, '/');
|
||||
$url = rtrim($url, '/');
|
||||
$result_page['slug'] = str_replace(Url::getBase(), '', $url);
|
||||
$result_page['slug'] = str_replace(Http::getBaseUrl(), '', $url);
|
||||
|
||||
// Set page date
|
||||
$result_page['date'] = $result_page['date'] ?? date(Config::get('site.date_format'), filemtime($file));
|
||||
|
@ -13,7 +13,7 @@
|
||||
namespace Flextype;
|
||||
|
||||
use Thunder\Shortcode\ShortcodeFacade;
|
||||
use Flextype\Component\Url\Url;
|
||||
use Flextype\Component\Http\Http;
|
||||
|
||||
class Shortcodes
|
||||
{
|
||||
@ -76,7 +76,7 @@ class Shortcodes
|
||||
protected static function registerDefaultShortcodes() : void
|
||||
{
|
||||
static::driver()->addHandler('site_url', function() {
|
||||
return Url::getBase();
|
||||
return Http::getBaseUrl();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -25,4 +25,4 @@ version_compare($ver = PHP_VERSION, $req = FLEXTYPE_MINIMUM_PHP, '<') and exit(s
|
||||
$loader = require_once $autoload;
|
||||
|
||||
// Init Flextype
|
||||
Flextype::init();
|
||||
Flextype::instance();
|
||||
|
@ -26,4 +26,5 @@ Creating a new page is very simple in Flextype.
|
||||
|
||||
2. Save this file in the `/site/pages/my-new-page/` folder as `index.md` and its will be available by this url: [site_url]/my-new-page
|
||||
|
||||
|
||||
That is it!
|
||||
|
@ -13,13 +13,12 @@
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="<?php echo Flextype\Component\Url\Url::getBase(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Custom styles for this template -->
|
||||
<link href="<?php echo Flextype\Component\Url\Url::getBase(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/assets/css/theme.css" rel="stylesheet">
|
||||
<link href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/assets/css/theme.css" rel="stylesheet">
|
||||
<?php Flextype\Events::dispatch('onThemeHeader'); ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php Flextype\Templates::display('partials/navigation'); ?>
|
||||
<main role="main" class="container content">
|
||||
<?php Flextype\Component\Http\Request\Request::redirect('test'); ?>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom box-shadow">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="<?php echo Flextype\Component\Url\Url::getBase(); ?>"><?php echo Flextype\Config::get('site.title'); ?></a>
|
||||
<a class="navbar-brand" href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>"><?php echo Flextype\Config::get('site.title'); ?></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse justify-content-end" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (Flextype\Component\Url\Url::getUriSegment(0) == 'home' || Flextype\Component\Url\Url::getUriSegment(0) == '') echo 'active'; ?>" href="<?php echo Flextype\Component\Url\Url::getBase(); ?>">Home</a>
|
||||
<a class="nav-link <?php if (Flextype\Component\Http\Http::getUriSegment(0) == 'home' || Flextype\Component\Http\Http::getUriSegment(0) == '') echo 'active'; ?>" href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>">Home</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user