Giter Club home page Giter Club logo

webgen's Introduction

Webgen

Build Status

Simple PHP CLI generator of static web sites.

Become a Patron! Buy me a coffee

Features

Usage

$ cd examples/basic
$ php -f ../../webgen.php -- --run
$ cd output
$ ls
articles  index.html

Note: Webgen ignores files with @ on start of filename.

Templating

Texy in Latte template

{block |texy}
This is **Texy** snippet.
{/block}


{texy}
This is "Texy":https://texy.info snippet too.
{/texy}

Get name of current generated file

{$webgen->currentFile} {* prints for example: 'articles/article-2.texy' *}

Get relative path from currentFile to a file

{$webgen->createRelativeLink('articles/article-1.html')}
{* prints:
'article-1.html'          for currentFile = 'articles/article-2.texy'
'articles/article-1.html' for currentFile = 'index.texy'
*}

Shortcuts (output for currentFile = 'articles/article-2.texy')

{link articles/article-1.html} {* prints article-1.html *}

<a n:href="articles/article-1.html">Article #1</a>
{* prints *}
<a href="article-1.html">Article #1</a>


<link rel="stylesheet" n:href="css/style.css" type="text/css">
{* prints *}
<link rel="stylesheet" href="../css/style.css" type="text/css">


<img n:src="images/photo.jpg">
{* prints *}
<img src="../images/photo.jpg">

<img n:image="images/photo.jpg">
{* prints (image file must exist) *}
<img src="../images/photo.jpg" width="1024" height="768">

Relative paths in Texy:

"Article #1":@articles/article-1.html

[* @images/photo.jpg *]

Highlight current page in menu (is link current?)

<div id="menu">
    <a n:href="/" n:class="$webgen->isLinkCurrent('index.texy') ? current">Homepage</a>
    <a n:href="about-us/" n:class="$webgen->isLinkCurrent('about-us/**') ? current">About us</a>
    <a n:href="contact.html" n:class="$webgen->isLinkCurrent('contact.*') ? current">Contact</a>
</div>

In mask ** means everything, * means everything except /.

Variables in Texy document

{{$var}}

{{$var = value}}

{{$var: value}}

Configuration

Configuration is stored in file named config.neon. NEON is format very similar to YAML, see https://ne-on.org/.

Change name of source or output directory

input:
	dir: <new-source-dir-name>

output:
	dir: <new-output-dir-name>

Change name of layout template

input:
	layout: @my-layout-name.latte

Copy files from source directory into output directory (CSS & JS files, images,...)

Boolean value (yes/no) or filemask(s):

input:
    copy: yes
input:
    copy:
        - *.js
        - *.css

Change default output file extension

output:
    ext: php

File-specific change:

{webgen ext => php}   ## in Latte template
{{webgen: ext: php}}  ## in Texy file

Change output filename

## changes output file extension
{webgen ext => php}

## changes output basename of file
{webgen name => my-first-page}

## changes output filename (ignores 'ext' option)
{webgen filename => my-first-page.html}

Pagination

See example pagination-repeated-generating.

Who uses Webgen?

Articles:


License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/

webgen's People

Contributors

janpecha avatar

Stargazers

 avatar Craig Davison avatar

Watchers

 avatar James Cloos avatar

webgen's Issues

Lepší lastModified

Nespoléhat se na čas poslední modifikace, ale konkrolovat na základě hashů.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.