Initial commit
This commit is contained in:
commit
4e24c0742b
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/build_local/
|
||||
/node_modules/
|
||||
/vendor/
|
||||
_tmp
|
||||
source/_posts/
|
||||
source/css/*.css
|
||||
source/css/*.map
|
||||
config.ini
|
4
bootstrap.php
Normal file
4
bootstrap.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
/** @var $container \Illuminate\Container\Container */
|
||||
/** @var $jigsaw \TightenCo\Jigsaw\Jigsaw */
|
15
composer.json
Normal file
15
composer.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"tightenco/jigsaw": "^1.0",
|
||||
"directus/sdk": "^0.2.0",
|
||||
"cocur/slugify": "^2.5",
|
||||
"intervention/image": "^2.3"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/wellingguzman/zend-db"
|
||||
}
|
||||
]
|
||||
}
|
1956
composer.lock
generated
Normal file
1956
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
4
config.ini.example
Normal file
4
config.ini.example
Normal file
|
@ -0,0 +1,4 @@
|
|||
DIRECTUS_TOKEN = "directus-token-here"
|
||||
DIRECTUS_URL = "directus-selfhosted-url-here"
|
||||
DIRECTUS_STORAGE = "storage/uploads"
|
||||
IMAGE_DIR = "images"
|
149
config.php
Normal file
149
config.php
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
require_once "vendor/autoload.php";
|
||||
require_once "download.php";
|
||||
use Cocur\Slugify\Slugify;
|
||||
use \Intervention\Image\ImageManagerStatic as Image;
|
||||
|
||||
$config = parse_ini_file("config.ini");
|
||||
|
||||
$client = \Directus\SDK\ClientFactory::create($config['DIRECTUS_TOKEN'], [
|
||||
'base_url' => $config['DIRECTUS_URL'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$posts = $client->getItems('blog');
|
||||
if (!file_exists('source/_posts')) {
|
||||
mkdir('source/_posts');
|
||||
}
|
||||
$slugify = new Slugify();
|
||||
$tidy = new tidy();
|
||||
foreach($posts as $post) {
|
||||
if ($post->active !== 1) { // skip drafts or deleted
|
||||
continue;
|
||||
}
|
||||
if (!file_exists('source/_posts/')) {
|
||||
mkdir('source/_posts');
|
||||
}
|
||||
$day = date('Y-m-d', strtotime($post->date_published));
|
||||
if (!file_exists('source/_posts/'.$day)) {
|
||||
mkdir('source/_posts/'.$day);
|
||||
}
|
||||
$filename = 'source/_posts/'.$day.'/'.$slugify->slugify($post->title).'.md';
|
||||
$content = str_replace("\r", "", $post->content);
|
||||
$content = $tidy->repairString(trim($content), [
|
||||
'show-body-only' => true
|
||||
]);
|
||||
$page = '---'.PHP_EOL.
|
||||
'extends: _layouts.post'.PHP_EOL.
|
||||
'title: '.$post->title.PHP_EOL.
|
||||
'date: '.$day.PHP_EOL.
|
||||
'feature: _'.$post->feature->name.PHP_EOL.
|
||||
'---'.PHP_EOL.
|
||||
$content;
|
||||
download_file(
|
||||
$config['DIRECTUS_URL'].'/'.$config['DIRECTUS_STORAGE'].'/'.$post->feature->name,
|
||||
'source/_posts/'.$day.'/_'.$post->feature->name
|
||||
);
|
||||
$file = fopen($filename, 'w');
|
||||
fwrite($file, $page);
|
||||
fclose($file);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
return [
|
||||
'baseUrl' => '/',
|
||||
'production' => true,
|
||||
'collections' => [
|
||||
'posts' => [
|
||||
'path' => 'blog/{date|Y-m-d}/{filename}',
|
||||
'sort' => '-date'
|
||||
]
|
||||
],
|
||||
'title' => "K.lee Studio", // site title
|
||||
'description' => "",
|
||||
'generator' => "Jigsaw",
|
||||
|
||||
/**
|
||||
* Helpers start here
|
||||
*/
|
||||
|
||||
'normalizeUrl' => function($page, $target) {
|
||||
if ($target[0] === '/') {
|
||||
$target = ltrim($target, '/');
|
||||
}
|
||||
if (strpos($target, 'http:') === FALSE && strpos($target, 'https:') === FALSE) {
|
||||
$target = $page->baseUrl.$target;
|
||||
}
|
||||
return $target;
|
||||
},
|
||||
'css' => function($page, $target){
|
||||
return '<link rel="stylesheet" href="'.$page->normalizeUrl($target).'" />';
|
||||
},
|
||||
'js' => function($page, $target) {
|
||||
return '<script src="'.$page->normalizeUrl($target).'"></script>';
|
||||
},
|
||||
'prevnext' => function($page, $previous = '', $next = '', $classname = '') {
|
||||
$out = '<ul class="nav '.$classname.'">';
|
||||
if (!empty($previous)) {
|
||||
$out .= '<li><a href="'.$page->url($previous).'"><strong>↑PREVIOUS</strong></a></li>';
|
||||
if (!empty($next)) {
|
||||
$out .= '<li> — </li>';
|
||||
}
|
||||
}
|
||||
if (!empty($next)) {
|
||||
$out .= '<li><a href="'.$page->url($next).'"><strong>NEXT↓</strong></a></li>';
|
||||
}
|
||||
$out .= '</ul>';
|
||||
return $out;
|
||||
},
|
||||
'thumbnail' => function($page, $image, $title, $subtitle) {
|
||||
$slugify = new Slugify();
|
||||
$imagefile = __DIR__ . '/source/_posts/' . $date . '/' . $image;
|
||||
$outdir = __DIR__ . '/build_local/blog/' . $date . '/' . $slugify->slugify($title);
|
||||
if (!file_exists($outdir)) {
|
||||
mkdir($outdir, 0755, true);
|
||||
}
|
||||
$imagep = Image::make($imagefile);
|
||||
if (!file_exists($outdir.'/_small'.$image)) {
|
||||
$imagep->resize(300, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
})->save($outdir.'/thumb'.$image);
|
||||
}
|
||||
return '<div class="thumbnail">'.
|
||||
$page->img($image, $title).
|
||||
'<p><strong>'.$title.'</strong><br>'.$subtitle.'</p>'.
|
||||
'</div>';
|
||||
},
|
||||
'imgurl' => function($page, $url) {
|
||||
return $page->baseUrl.$config['IMAGE_DIR']."/".ltrim($url, '/');
|
||||
},
|
||||
'img' => function($page, $url, $title) {
|
||||
return '<img src="'.$page->imgurl($url).'" alt="'.$title.'">';
|
||||
},
|
||||
'url' => function($page, $url) {
|
||||
return $page->normalizeUrl($url);
|
||||
},
|
||||
'firstwords' => function($page, $text, $limit = 20) {
|
||||
$text = preg_replace('/\s+/', ' ', trim($text));
|
||||
$words = explode(" ", $text); // an array
|
||||
|
||||
// if number of words you want to get is greater than number of words in the string
|
||||
if ($limit > count($words)) {
|
||||
// then use number of words in the string
|
||||
$limit = count($words);
|
||||
}
|
||||
|
||||
$new_string = "";
|
||||
for ($i = 0; $i < $limit; $i++) {
|
||||
$new_string .= $words[$i] . " ";
|
||||
}
|
||||
|
||||
$tidy = new tidy();
|
||||
|
||||
return $tidy->repairString(trim($new_string), [
|
||||
'show-body-only' => true
|
||||
]);
|
||||
}
|
||||
];
|
14
download.php
Normal file
14
download.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
function download_file($url, $out) {
|
||||
set_time_limit(0);
|
||||
$fp = fopen ($out, 'w+');
|
||||
$ch = curl_init(str_replace(" ","%20",$url));
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
|
||||
// write curl response to file
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
// get curl response
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
fclose($fp);
|
||||
}
|
21
gulpfile.js
Normal file
21
gulpfile.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
var gulp = require('gulp');
|
||||
var elixir = require('laravel-elixir');
|
||||
var argv = require('yargs').argv;
|
||||
var bin = require('./tasks/bin');
|
||||
|
||||
elixir.config.assetsPath = 'source/_assets';
|
||||
elixir.config.publicPath = 'source';
|
||||
|
||||
elixir(function(mix) {
|
||||
var env = argv.e || argv.env || 'local';
|
||||
var port = argv.p || argv.port || 3000;
|
||||
|
||||
mix.sass('style.scss')
|
||||
.exec(bin.path() + ' build ' + env, ['./source/*', './source/**/*', '!./source/_assets/**/*'])
|
||||
.browserSync({
|
||||
port: port,
|
||||
server: { baseDir: 'build_' + env },
|
||||
proxy: null,
|
||||
files: [ 'build_' + env + '/**/*' ]
|
||||
});
|
||||
});
|
15
package.json
Normal file
15
package.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"gulp": "^3.8.8",
|
||||
"hasbin": "^1.2.3",
|
||||
"laravel-elixir": "^6.0.0-15",
|
||||
"laravel-elixir-browsersync-official": "^1.0.0",
|
||||
"yargs": "^4.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"hasbin": "^1.2.3",
|
||||
"laravel-elixir": "^6.0.0-15",
|
||||
"yargs": "^4.8.1"
|
||||
}
|
||||
}
|
9
source/404.blade.php
Normal file
9
source/404.blade.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
pretty: false
|
||||
---
|
||||
@extends('_layouts.master')
|
||||
|
||||
@section('contents')
|
||||
<h1>404: Страница не найдена</h1>
|
||||
<p>Возможно, вы ошиблись адресом.</p>
|
||||
@endsection
|
1877
source/_assets/sass/style.scss
Normal file
1877
source/_assets/sass/style.scss
Normal file
File diff suppressed because it is too large
Load diff
15
source/_layouts/master.blade.php
Normal file
15
source/_layouts/master.blade.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
@include('_partial.head')
|
||||
|
||||
<body>
|
||||
|
||||
@include('_partial.nav')
|
||||
|
||||
<main>
|
||||
@yield('contents')
|
||||
</main>
|
||||
|
||||
@include('_partial.footer')
|
||||
</body>
|
||||
</html>
|
30
source/_layouts/post.blade.php
Normal file
30
source/_layouts/post.blade.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
@extends('_layouts.master')
|
||||
|
||||
@section('contents')
|
||||
<section class="main">
|
||||
<div class="post-header">
|
||||
<div class="post-headerimage">
|
||||
{!! $page->img($page->feature, $page->title) !!}
|
||||
</div>
|
||||
<div class="post-headertext">
|
||||
<h2>{{ $page->title }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@yield('content')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($page->getPrevious())
|
||||
<p>Read the previous post:
|
||||
<a href="{{ $page->getPrevious()->path }}">{{ $page->getPrevious()->title }}</a>
|
||||
</p>
|
||||
@endif
|
||||
@if ($page->getNext())
|
||||
<p>Read the next post:
|
||||
<a href="{{ $page->getNext()->path }}">{{ $page->getNext()->title }}</a>
|
||||
</p>
|
||||
@endif
|
||||
</section>
|
||||
@endsection
|
0
source/_partial/footer.blade.php
Normal file
0
source/_partial/footer.blade.php
Normal file
9
source/_partial/head.blade.php
Normal file
9
source/_partial/head.blade.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ $page->title }}</title>
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="generator" content="{{ $page->generator }}">
|
||||
<meta name="description" content="{{ $page->description }}">
|
||||
{!! $page->css('/css/style.css') !!}
|
||||
</head>
|
22
source/_partial/nav.blade.php
Normal file
22
source/_partial/nav.blade.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<ul class="nav nav_small @if ($page->getPath() == '/') nav_hidden @endif">
|
||||
<li><a href="{!! $page->url('/') !!}">K.LEE STUDIO</a></li>
|
||||
<li><a href="{!! $page->url('/work/') !!}">WORK</a></li>
|
||||
{{-- <li><a href="{!! $page->url('/services-unknown/') !!}">CAPABILITIES</a></li> --}}
|
||||
<li><a href="{!! $page->url('/archive/') !!}">ARCHIVE</a></li>
|
||||
<li><a href="{!! $page->url('/info/') !!}">INFO</a></li>
|
||||
<li>© {{ date('Y') }}</li>
|
||||
</ul>
|
||||
<ul class="nav nav_full @if ($page->getPath() == '/') nav_hidden @endif">
|
||||
<li><a href="/">K.LEE STUDIO</a></li>
|
||||
<li>© {{ date('Y') }}</li>
|
||||
<li><a href="{!! $page->url('/services-unknown/') !!}">CAPABILITIES</a></li>
|
||||
<li><a href="{!! $page->url('/info/') !!}">INFO</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="{!! $page->url('/work/') !!}">WORK</a>
|
||||
<ul class="dropdown__menu">
|
||||
<li><a href="{!! $page->url('/work/') !!}">SELECT</a></li>
|
||||
<li><a href="{!! $page->url('/archive/') !!}">ARCHIVE</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
0
source/css/.keep
Normal file
0
source/css/.keep
Normal file
12
source/index.blade.php
Normal file
12
source/index.blade.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
@extends('_layouts.master')
|
||||
|
||||
@section('contents')
|
||||
<div class="cover">
|
||||
<a href="/toc">
|
||||
{--
|
||||
{!! $page->img($page->feature, $page->title) !!}
|
||||
--}
|
||||
<img src="http://lorempixel.com/800/600" alt="Cover">
|
||||
</a>
|
||||
</img>
|
||||
@endsection
|
18
source/toc.blade.php
Normal file
18
source/toc.blade.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
threed: true
|
||||
---
|
||||
@extends('_layouts.master')
|
||||
|
||||
@section('contents')
|
||||
<div class="toc">
|
||||
@foreach ($posts as $post)
|
||||
<a href="{!! $post->getPath() !!}">
|
||||
{!! $page->thumbnail(
|
||||
$post->feature,
|
||||
$post->title,
|
||||
$page->firstwords($post->content))
|
||||
!!}
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
@endsection
|
Loading…
Reference in a new issue