Commit f5b876a1 authored by Artemis's avatar Artemis 🐱

Base commit

parents
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
.idea/
vendor/
resources/config.php
data/
# Pix website
## Routes
Every controller should be created in `src/Controller/`,
extend the `Pix\Core\BaseController` class and
be in the namespace `Pix\Controller`.
When calling `$resolve('MyController', 'myMethod')`,
if the class name doesn't start with `\\`,
it'll automatically be prefixed by the namespace
defined in the configuration.
## Errors
All error codes are defined in the `resources/errors.php` file.
Every recognized error should have its code,
and its error definition in the file.
Every error should have a message in at least
the default translation,
`resources/translations/error/en.ini`.
### Default parameters
A few parameters are set by default and will override
the ones you set, if they have the same key.
|Code|Description
|----|-----------
|`_request_code`|The current request's code. Usually a 13-digit code.
### Global parameters
The error printer also merges the global values set in the configuration.
It will only take the values whose keys starts with `_`, to avoid
swapping common words with global values.
The default configuration sets a few available global variables.
|Code|Description
|----|-----------
|`_email`|The administrator's e-mail, an email to contact in case of error
{
"name": "artemis/blog",
"description": "My blog",
"type": "project",
"license": "GPL-3.0",
"authors": [
{
"name": "Artemix",
"email": "artemix@artemix.org"
}
],
"require": {
"suin/php-rss-writer": "^1.6",
"cocur/slugify": "^3.0",
"leocavalcante/siler": "^1.0",
"twig/twig": "^2.4",
"apix/log": "^1.2",
"paragonie/easydb": "^2.6"
},
"scripts": {
"serve": "php -S 127.0.0.1:7000 -t public/"
},
"autoload": {
"psr-4": {
"Blog\\": "src/"
}
}
}
This diff is collapsed.
../uglifycss/uglifycss
\ No newline at end of file
{
"systemParams": "linux-x64-59",
"modulesFolders": [
"node_modules"
],
"flags": [],
"linkedModules": [],
"topLevelPatterns": [
"uglifycss@^0.0.28"
],
"lockfileEntries": {
"uglifycss@^0.0.28": "https://registry.yarnpkg.com/uglifycss/-/uglifycss-0.0.28.tgz#b865ae5f66e4fcec6ea1d979e150dc5bf37ceb1c"
},
"files": [],
"artifacts": {}
}
\ No newline at end of file
Copyright (c) Franck Marcia
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.
\ No newline at end of file
UglifyCSS is a port of [YUI Compressor](https://github.com/yui/yuicompressor) to [NodeJS](http://nodejs.org) for its CSS part. Its name is a reference to the awesome [UglifyJS](https://github.com/mishoo/UglifyJS) but UglifyCSS is not a CSS parser. Like YUI CSS Compressor, it applies many regexp replacements. Note that a [port to JavaScript](https://github.com/yui/ycssmin) is also available in the YUI Compressor repository.
UglifyCSS passes successfully the test suite of YUI compressor CSS.
Be sure to submit valid CSS to UglifyCSS or you could get weird results.
### Installation
For a command line usage:
```sh
$ npm install uglifycss -g
```
For API usage:
```sh
$ npm install uglifycss
```
From Github:
```sh
$ git clone git://github.com/fmarcia/UglifyCSS.git
```
### Command line
```sh
$ uglifycss [options] [filename] [...] > output
```
Options:
* `--max-line-len n` adds a newline (approx.) every `n` characters; `0` means no newline and is the default value
* `--expand-vars` expands variables; by default, `@variables` blocks are preserved and `var(x)`s are not expanded
* `--ugly-comments` removes newlines within preserved comments; by default, newlines are preserved
* `--cute-comments` preserves newlines within and around preserved comments
* `--convert-urls d` converts relative urls using the `d` directory as location target
* `--debug` prints full error stack on error
* `--output f` puts the result in `f` file
If no file name is specified, input is read from stdin.
### API
2 functions are provided:
* `processString( content, options )` to process a given string
* `processFiles( [ filename1, ... ], options )` to process the concatenation of given files
Options are identical to the command line:
* `<int> maxLineLen` for `--max-line-len n`
* `<bool> expandVars` for `--expand-vars`
* `<bool> uglyComments` for `--ugly-comments`
* `<bool> cuteComments` for `--cute-comments`
* `<string> convertUrls` for `--convert-urls d`
* `<bool> debug` for `--debug`
Both functions return uglified css.
#### Example
```js
var uglifycss = require('uglifycss');
var uglified = uglifycss.processFiles(
[ 'file1', 'file2' ],
{ maxLineLen: 500, expandVars: true }
);
console.log(uglified);
```
### License
UglifyCSS is MIT licensed.
/**
* UglifyCSS
* Port of YUI CSS Compressor to NodeJS
* Author: Franck Marcia - https://github.com/fmarcia
* MIT licenced
*/
/**
* cssmin.js
* Author: Stoyan Stefanov - http://phpied.com/
* This is a JavaScript port of the CSS minification tool
* distributed with YUICompressor, itself a port
* of the cssmin utility by Isaac Schlueter - http://foohack.com/
* Permission is hereby granted to use the JavaScript version under the same
* conditions as the YUICompressor (original YUICompressor note below).
*/
/**
* YUI Compressor
* http://developer.yahoo.com/yui/compressor/
* Author: Julien Lecomte - http://www.julienlecomte.net/
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
* The copyrights embodied in the content of this file are licensed
* by Yahoo! Inc. under the BSD (revised) open source license.
*/
module.exports = require('./uglifycss-lib')
{
"author": "Franck Marcia <franck.marcia@gmail.com> (https://github.com/fmarcia)",
"name": "uglifycss",
"description": "Port of YUI CSS Compressor to NodeJS",
"version": "0.0.28",
"keywords": [
"css",
"stylesheet",
"uglify",
"minify"
],
"license": "MIT",
"homepage": "https://github.com/fmarcia/UglifyCSS",
"repository": {
"type": "git",
"url": "git://github.com/fmarcia/UglifyCSS.git"
},
"main": "./index.js",
"bin": {
"uglifycss" : "./uglifycss"
}
}
#!/usr/bin/env node
/**
* UglifyCSS
* Port of YUI CSS Compressor to NodeJS
* Author: Franck Marcia - https://github.com/fmarcia
* MIT licenced
*/
/**
* cssmin.js
* Author: Stoyan Stefanov - http://phpied.com/
* This is a JavaScript port of the CSS minification tool
* distributed with YUICompressor, itself a port
* of the cssmin utility by Isaac Schlueter - http://foohack.com/
* Permission is hereby granted to use the JavaScript version under the same
* conditions as the YUICompressor (original YUICompressor note below).
*/
/**
* YUI Compressor
* http://developer.yahoo.com/yui/compressor/
* Author: Julien Lecomte - http://www.julienlecomte.net/
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
* The copyrights embodied in the content of this file are licensed
* by Yahoo! Inc. under the BSD (revised) open source license.
*/
const { defaultOptions, processString, processFiles } = require('./')
const { writeFileSync } = require('fs')
const UGLIFYCSS_VERSION = '0.0.28'
// Info namespace
const info = {}
// Print usage
info.help = _ => {
console.log(`
Usage: uglifycss [options] file1.css [file2.css [...]] > output
options:
--max-line-len n add a newline every n characters
--expand-vars expand variables
--ugly-comments remove newlines within preserved comments
--cute-comments preserve newlines within and around preserved comments
--convert-urls d convert relative urls using the d directory as location target
--debug print full error stack on error
--output f put the result in f file
--help show this help
--version display version number`
.replace(/^\s+/gm, '')
)
}
// Print version
info.version = _ => {
console.log(`uglifycss ${UGLIFYCSS_VERSION}`)
}
// Transform strings like "the-parameter" to "theParameter"
const par2var = param =>
param.replace(
/-(.)/g,
(_, ch) => ch === '-' ? '' : ch.toUpperCase()
)
// Parse parameters from command line
const parseArguments = argv => {
const params = {
options: defaultOptions,
files: []
}
const len = argv.length
for (let i = 2; i < len; i += 1) {
// get "propertyName" from "--argument-name"
let v = par2var(argv[i])
// boolean parameters
if (typeof params.options[v] === 'boolean') {
params.options[v] = true
// string parameter
} else if (typeof params.options[v] === 'string') {
params.options[v] = argv[i + 1] || ''
i += 1
// integer parameter
} else if (typeof params.options[v] !== 'undefined') {
params.options[v] = parseInt(argv[i + 1], 10)
i += 1
// help
} else if (argv[i] === '--help') {
return 'help'
// version
} else if (argv[i] === '--version') {
return 'version'
// file
} else {
params.files.push(argv[i])
}
}
return params
}
// Entry
{
// parameters
const params = parseArguments(process.argv)
// info
if (params === 'help' || params === 'version') {
return info[params]()
}
// files
if (params.files.length) {
const ugly = processFiles(params.files, params.options)
if (params.options.output) {
return writeFileSync(params.options.output, ugly)
} else {
return console.log(ugly)
}
}
// no file, no stdin: help
if (process.stdin.isTTY) {
return info.help()
}
// stdin
if (params.options.convertUrls) {
return console.error('uglifycss: stdin input and --convert-urls are not compatible')
}
let content = ''
process.stdin.on('data', part => content += part)
process.stdin.on('end', _ =>
console.log(processString(content, params.options))
)
}
This diff is collapsed.
{
"name": "blog",
"version": "1.0.0",
"description": "Yarn config for front-end of my blog",
"repository": "git@gitlab.com:Artemix/Blog-Story-Design.git",
"author": "Artemix <artemix@artemix.org>",
"license": "GPL-3.0",
"devDependencies": {
"uglifycss": "^0.0.28"
},
"scripts": {
"build": "uglifycss resources/assets/style.css > public/assets/style.css"
}
}
body{margin:0;background-color:#DDD;margin-bottom:2em;text-rendering:optimizeLegibility}p{color:#333}a{color:#1976d2;text-decoration:none}a:hover{border-bottom:1px solid #1565c0}h1,h2,h3,h4,h5,h6{font-weight:normal}h2.title{line-height:1em}form{text-align:center}form>*{padding-top:1em}header{box-shadow:0 0 .2em #1565c0}header>*{background-color:#1565c0;margin:0;padding:.5em 5%;font-family:'Helvetica','Arial',sans-serif}header>h1>a{color:#EEE}.pagination{text-align:center}.pagination>a{padding:.4em}.pagination>a.current{color:#333}p.no-.article-error{text-align:center;font-size:1.6em;color:#b71c1c;padding:1.2em;border:1px solid #e53935}section{line-height:1.7em;font-family:'Open Sans','Arial',sans-serif;background-color:#eee;padding:2em}li:not(:last-of-type){margin-bottom:1em}section>.header{line-height:2.6em}section>.header,section>.title{border-bottom:1px solid #999;padding-bottom:1.2em;line-height:1.3em}section>.header>*,section>.title{text-align:center}section>.header>.title,section>.title{margin-bottom:.5em;font-size:2.6em}section>.header>.subtitle{padding-top:.2em;color:#666;font-size:1.4em;margin:.2em auto 0}section>.header>.metadata{margin-top:0;font-size:.8em}section>.content{text-align:left;font-size:1.2em;line-height:1.3em}.article:not(:first-of-type){border-top:1px solid #999}.article>p.title{margin-top:1.2em;font-size:1.7em;margin-bottom:0}.article>p.title>a{color:#333}.article>p.subtitle{margin:0}.article>p.metadata{font-size:.7em;margin-top:0}img,iframe{border-top:1px solid #888;border-bottom:1px solid #888;padding:1em;display:block;margin:0 auto;width:90%}iframe{max-height:30em}pre{padding:1em;color:#DDD;background-color:#333;box-shadow:0 0 .2em #333;white-space:pre-wrap}:not(pre)>code{margin:0;padding:.2em;border:1px solid #616161;border-radius:2px;color:#e0e0e0;background-color:#424242}blockquote{border-left:4px solid #673ab7;margin-left:0;margin-right:0;padding:0 1.2em;font-style:italic}.footer{border-top:1px solid #888;text-align:center;padding-top:1em;overflow:hidden}.footer>*>.author{width:10em;height:10em;border-radius:50%;border:0}.footer>.right{text-align:left}.footer>.right>*{padding-left:1em}.footer>.right>ul{list-style:none}nav>a{color:#EEE}nav>a:not(:last-of-type){padding-right:2em}nav>a:hover{border-bottom:0;color:#BBB}nav>a:before{content:''}@media screen and (max-width:720px){nav>a{display:block;line-height:1.5em}}@media screen and (max-width:1280px){section>.content{font-size:1.6em}section>.article{line-height:1.8em;font-size:1.4em}.footer>.left{border-bottom:1px solid #888}}@media screen and (min-width:1280px){section{box-shadow:0 0 .3em #d2d2d2;border:1px solid #CCC;margin:1.6em auto;width:1100px}.footer>.left{width:50%;border-right:1px solid #888;float:left}.footer>.right{width:49.9%;float:right}}
<?php
// Assert conditions
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_QUIET_EVAL, 1);
function assert_handler($file, $line, $code, $desc = null) {
if (empty($code)) { $code = "no code"; }
http_response_code(500);
echo "<hr />Assertion failed at $file:$line ($code)<br />";
if (null !== $desc) { echo "Description: $desc<br />"; }
echo "<hr />";
die();
}
assert_options(ASSERT_CALLBACK, 'assert_handler');
function startsWith($needle, $haystack)
{
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
define('REQUEST_CODE', uniqid());
use Blog\Core\Rl;
define('ROOT_DIR', realpath(__DIR__.'/..'));
function resolvePath(string $path): string { return realpath(rtrim(ROOT_DIR, '/').'/'.ltrim($path, '/')); }
require_once '../vendor/autoload.php';
Rl::initialize(ROOT_DIR);
$config = Rl::i()('config');
$logger = new \Blog\Log\LoggerHandler(
$config['flags']['debug'],
$config['paths']['log'],
REQUEST_CODE
);
$logger->traceRequest();
Rl::i()->register('log', function() use ($logger) { return $logger; });
$logger->i('Loading services');
require_once resolvePath('resources/services.php');
$logger->i('Loading errors');
require_once resolvePath('resources/errors.php');
// No composer dependency installed, weird.
// Or, the env is down
if (!is_dir(resolvePath('vendor')) || \Blog\Core\Helper::isDown()) {
$logger->i('Environment is down, loading static down page and dying');
echo file_get_contents(resolvePath('static/down.html'));
die();
}
$logger->i('Environment is up, continuing');
try {
$logger->i('Loading routes');
require_once $rl('config')['paths']['routes'];
} catch (Exception $e) {
$logger->error($e);
if (!$e instanceof \Blog\Error\ToResolveException) {
$e = new \Blog\Error\ToResolveException(ERROR_INTERNAL_ERROR);
}
$rl = Rl::i();
/** @var \Blog\Error\ErrorManager $errMgr */
$errMgr = $rl('error-manager');
$params = array_merge($e->params, ['_request_code' => REQUEST_CODE]);
$params = array_merge(
$params,
array_filter(
$rl('config')['global-values'],
function($k) { return startsWith('_', $k); },
ARRAY_FILTER_USE_KEY
) ?? []
);
[$statusCode, $message] = $errMgr->get($e->resolvCode, $params);
http_response_code($statusCode);
echo $message;
}
body {
margin: 0;
background-color: #DDD;
margin-bottom: 2em;
text-rendering: optimizeLegibility;
}
p { color: #333; }
a {
color: #1976D2;
text-decoration: none;
}
a:hover { border-bottom: 1px solid #1565C0; }
h1, h2, h3, h4, h5, h6 {
font-weight: normal;
}
h2.title {
line-height: 1em;
}
form {
text-align: center;
}
form > * {
padding-top: 1em;
}
header { box-shadow: 0 0 0.2em #1565C0; }
header > * {
background-color: #1565C0;
margin: 0;
padding: 0.5em 5%;
font-family: 'Helvetica', 'Arial', sans-serif;
}
header > h1 > a { color: #EEE; }
.pagination { text-align: center; }
.pagination > a { padding: 0.4em; }
.pagination > a.current { color: #333; }
p.no-.article-error {
text-align: center;
font-size: 1.6em;
color: #B71C1C;
padding: 1.2em;
border: 1px solid #E53935;
}
section {
line-height: 1.7em;
font-family: 'Open Sans', 'Arial', sans-serif;
background-color: #EEEEEE;
padding: 2em;
}
li:not(:last-of-type) {
margin-bottom: 1em;
}
section > .header { line-height: 2.6em; }
section > .header, section > .title {
border-bottom: 1px solid #999;
padding-bottom: 1.2em;
line-height: 1.3em;
}
section > .header > *, section > .title { text-align: center; }
section > .header > .title, section > .title {
margin-bottom: 0.5em;
font-size: 2.6em;
}
section > .header > .subtitle {
padding-top: 0.2em;
color: #666;
font-size: 1.4em;
margin: 0.2em auto 0;
}
section > .header > .metadata {
margin-top: 0;
font-size: 0.8em;
}
section > .content {
text-align: left;
font-size: 1.2em;
line-height: 1.3em;
}
.article:not(:first-of-type) { border-top: 1px solid #999; }
.article > p.title {
margin-top: 1.2em;
font-size: 1.7em;
margin-bottom: 0;
}
.article > p.title > a { color: #333; }
.article > p.subtitle { margin: 0; }
.article > p.metadata {
font-size: 0.7em;
margin-top: 0;
}
img, iframe {
border-top: 1px solid #888;
border-bottom: 1px solid #888;
padding: 1em;
display: block;
margin: 0 auto;
width: 90%;
}
iframe { max-height: 30em; }
pre {
padding: 1em;
color: #DDD;
background-color: #333;
box-shadow: 0 0 0.2em #333;
white-space: pre-wrap;
}
:not(pre) > code {
margin: 0;
padding: 0.2em;
border: 1px solid #616161;
border-radius: 2px;
color: #E0E0E0;
background-color: #424242;
}
blockquote {
border-left: 4px solid #673AB7;
margin-left: 0;
margin-right: 0;
padding: 0 1.2em;
font-style: italic;
}
.footer {
border-top: 1px solid #888888;
text-align: center;
padding-top: 1em;
overflow: hidden;
}
.footer > * > .author {
width: 10em;
height: 10em;
border-radius: 50%;
border: 0;
}
.footer > .right { text-align: left; }
.footer > .right > * { padding-left: 1em; }
.footer > .right > ul { list-style: none; }
nav > a {
color: #EEE;
}
nav > a:not(:last-of-type) {
padding-right: 2em;
}
nav > a:hover {
border-bottom: 0;
color: #BBB;
}
nav > a:before { content: ''; }
@media screen and (max-width: 720px) {
nav > a {
display: block;
line-height: 1.5em;
}
}
@media screen and (max-width: 1280px) {
section > .content { font-size: 1.6em; }
section > .article {
line-height: 1.8em;
font-size: 1.4em;
}
.footer > .left { border-bottom: 1px solid #888888; }
}
@media screen and (min-width: 1280px) {
section {
box-shadow: 0 0 0.3em #D2D2D2;
border: 1px solid #CCC;
margin: 1.6em auto;
width: 1100px;
}
.footer > .left {
width: 50%;
border-right: 1px solid #888888;
float: left;
}
.footer > .right {
width: 49.9%; /* Cannot do 50%... */
float: right;
}
}
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
function isDown(array $config): bool {
return $config['flags']['down'];