Skip to content

Commit

Permalink
fix: repair download, update libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Florens Verschelde committed May 3, 2018
1 parent 4eb2aa4 commit 053943f
Show file tree
Hide file tree
Showing 241 changed files with 1,793 additions and 877 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Remove PHP source from zip downloads,
# only keeping twigexpress.phar, doc & test folders
/dev export-ignore
# only keeping twigexpress.phar|json and demo folder
/doc export-ignore
/src export-ignore
/test export-ignore
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.1.3

- Fix main download by removing test-specific config in `twigexpress.json`.
- Update Twig lib to 1.35.3.

## 2.1.2

- Remove separate 'download' branch, in favour of 'master'.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016-2017 Kaliop
Copyright (c) 2016-2018 Kaliop

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
78 changes: 48 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
TwigExpress
===========

TwigExpress packages the [Twig templating engine][TWIG_HOME], and a few other tools, in a single file. Our goal is to make it easy to get started with Twig if you’re a designer or a front-end developer, without having to install a big PHP framework or a CMS.
TwigExpress packages the [Twig templating engine][TWIG_HOME], and a few other tools, in a single file.

Our goal is to make it easy to get started with Twig if you’re a designer or a front-end developer, without having to install a heavy PHP framework or CMS.

Main features:

- Browse and serve files
- Browse and serve files (⚠ only for development!)
- Render Twig templates
- Error pages with code excerpt, source view
- And a few extra tools for prototyping (dummy text, Markdown to HTML…):

**⚠ Do not use in production ⚠**<br>
We recommend using TwigExpress for:

1. discovering (or play with) Twig;
2. building HTML prototypes with Twig, CSS and JS.

Table of contents
-----------------

1. [Installation](#installation)
1. [Running TwigExpress](#running-twigexpress)
2. [Adding content](#adding-content)
3. [Writing Twig templates](#writing-twig-templates)<br>
[Getting Started with Twig][DOC_INTRO]<br>
[TwigExpress-specific features][DOC_EXTRAS]
4. [Configuration](#configuration)<br>
[TwigExpress configuration reference][DOC_CONFIG]
[TwigExpress configuration reference][DOC_CONFIG]<br>
[Using TwigExpress with Apache][DOC_APACHE]
5. [Library and license info](#library-and-license-info)

Installation
------------
Running TwigExpress
-------------------

### Requirements

- PHP 5.4+ available on the command line.<br>
On macOS, you should have PHP installed already.<br>
On Windows, one easy way to install PHP (and other tools) is [XAMPP](https://www.apachefriends.org/download.html).
PHP 5.4+ available on the command line.

- On macOS, you should have PHP installed already.
- On Windows, one easy way to install PHP (and other tools) is [XAMPP](https://www.apachefriends.org/download.html).

### Installation and usage
### Download TwigExpress

1. [Download a ZIP of this repo][DOWNLOAD] and unzip it.
2. Open a Terminal or Command Prompt *in that folder*, and run:<br>
`php --server localhost:8000 twigexpress.phar`.
3. Load `http://localhost:8000/` in a web browser to browse files.<br>
Any file ending in `.twig` will be interpreted as a Twig template.
- [Download a ZIP of this repo][DOWNLOAD] and unzip.
- Recommended: rename `twig-express-master` to your project’s name.

### Usage

Open your project folder in a Terminal or Command Prompt and run this command:

```sh
php --server localhost:8000 twigexpress.phar
```

Now load [http://localhost:8000/](http://localhost:8000/) in a web browser to browse your files.

Any file ending in `.twig` will be interpreted as a Twig template. You can check out the example pages in the `demo` directory.

Adding content
--------------
Expand All @@ -60,22 +66,34 @@ myproject/
twigexpress.phar
```

If you don’t care about the test and info files, you can remove them, keeping only this:
If you don’t care about the demo and read-me, you can keep these only:

```
myproject/
twigexpress.json
twigexpress.phar
```

You can add your own content anywhere. By content we mean: Twig templates (which must have the `.twig` extension), CSS, scripts, images, etc. File names and URLs will match, but you should omit the `.twig` extension in URLs. We’re also using `index.twig` and `index.html` files as directory index, if they exist. For example:

- `myproject/index.twig` → can be accessed at `http://localhost:8000/`
- `myproject/some/page.twig``http://localhost:8000/some/page`
- `myproject/css/styles.css``http://localhost:8000/css/styles.css`

There is no enforced convention for where to place stylesheets, JavaScript, etc. Feel free to organize your static assets and templates however you want.

You can add your own content anywhere. This content can be Twig templates (which must have the `.twig` extension), CSS, scripts, images, etc.

<table>
<tr>
<th scope="col">Example file path</th>
<th scope="col">Corresponding URL</th>
</tr>
<tr>
<td><code>myproject/index.twig</code></td>
<td><code>http://localhost:8000/</code></td>
</tr>
<tr>
<td><code>myproject/some/page.twig</code></td>
<td><code>http://localhost:8000/some/page</code></td>
</tr>
<tr>
<td><code>myproject/css/styles.css</code></td>
<td><code>http://localhost:8000/css/styles.css</code></td>
</tr>
</table>

Writing Twig templates
----------------------
Expand Down
55 changes: 30 additions & 25 deletions demo/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,35 @@

{% block content %}

<h1>{{ metaTitle|raw }}</h1>

<figure>
<img src="/demo/image.jpg" alt="[Cool doge]">
<figcaption>Just discovering Twig? Read <a href="https://github.com/gradientz/twig-express/blob/master/doc/intro.md">our short introduction</a></figcaption>
</figure>

<h2>Variables in <code>_context</code></h2>
<table>
<tr><th>Key</th><th>Value</th></tr>
{% for key,val in _context if key != '_parent' %}
<tr><td>{{ key }}</td><td>{{ val|json_encode|replace({'\\/':'/'}) }}</td></tr>
{% endfor %}
</table>

<h2>Including a template</h2>
<pre>{% verbatim %}{% include 'demo/test.json.twig' with {hello:'goodbye'} %}{% endverbatim %}</pre>
<p>Output:</p>
<pre>{% include 'demo/test.json.twig' with {hello:'goodbye'} %}</pre>
<p>Or load this template directly: <a href="/demo/test.json">demo/test.json</a></p>

<h2>Reading a file</h2>
<pre>{% verbatim %}{{ source('LICENSE', ignore_missing=true) }}{% endverbatim %}</pre>
<p>Output:</p>
<pre style="font-size:80%">{{ source('LICENSE', ignore_missing=true) }}</pre>
<h1>{{ metaTitle|raw }}</h1>

<figure>
<img src="/demo/image.jpg" alt="[Cool doge]">
<figcaption>Just discovering Twig? Read <a href="https://github.com/gradientz/twig-express/blob/master/doc/intro.md">our short introduction</a></figcaption>
</figure>

<h2>Look at this page’s source!</h2>
<p>It’s split in two files:</p>
<ul>
<li><a href="/demo/layout.twig"><code>demo/layout.twig</code></a></li>
<li><a href="/demo/index.twig"><code>demo/index.twig</code></a></li>
</ul>

<h2>Variables in <code>_context</code></h2>
<table>
<tr><th>Key</th><th>Value</th></tr>
{% for key,val in _context if key != '_parent' %}
<tr><td>{{ key }}</td><td>{{ val|json_encode|replace({'\\/':'/'}) }}</td></tr>
{% endfor %}
</table>

<h2>Including templates and files</h2>
<p>Including a template (interpreted as Twig):</p>
<pre>{% verbatim %}{% include 'demo/test.json.twig' with {hello:'goodbye'} %}{% endverbatim %}</pre>
<pre>{% include 'demo/test.json.twig' with {hello:'goodbye'} %}</pre>

<p>Including a file (not interpreted):</p>
<pre>{% verbatim %}{{ source('demo/test.json.twig') }}{% endverbatim %}</pre>
<pre>{{ source('demo/test.json.twig') }}</pre>

{% endblock %}
3 changes: 1 addition & 2 deletions demo/test.json.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% set hello = hello|default('world') %}
{
"hello": "{{ hello }}",
"hello": "{{ hello|default('world') }}",
"list": [{% for value in 1..20 %}"value = {{ value }}"{% if not loop.last %}, {% endif %}{% endfor %}]
}
13 changes: 0 additions & 13 deletions dev/package.json

This file was deleted.

6 changes: 3 additions & 3 deletions dev/README-DEV.md → src/README-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Building TwigExpress
## Minify CSS and JS

```
$ cd dev
# From the 'src' directory
$ npm install
$ npm run build
$ npm start
```

## Making the PHAR

The command should already be included in `npm run build`, but you can run manually:
The command should already be included in `npm start`, but you can run manually:

```
php makephar.php
Expand Down
10 changes: 4 additions & 6 deletions dev/css/1-core.css → src/css/1-core.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@
}

::selection {
text-decoration: none;
color: #fff;
background-color: #579;
color: var(--white, #fff);
background-color: var(--dark-red, #579);
background-color: #d85b5c;
}

::-moz-selection {
text-decoration: none;
color: #fff;
background-color: #579;
color: var(--white, #fff);
background-color: var(--dark-red, #579);
background-color: #d85b5c;
}

body {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 0 additions & 57 deletions src/lib/Parsedown/README.md

This file was deleted.

6 changes: 2 additions & 4 deletions dev/makephar.php → src/makephar.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

$ROOT = dirname(__DIR__);

$NAME = $ROOT . '/twigexpress.phar';
$SRC = $ROOT . '/src';
$NAME = dirname(__DIR__) . '/twigexpress.phar';
$SRC = __DIR__ . '/php';

if (PHP_SAPI !== 'cli') {
echo 'This script can only run on the CLI.' . PHP_EOL;
Expand Down
Loading

0 comments on commit 053943f

Please sign in to comment.