Git Product home page Git Product logo

tapestry-cloud / tapestry Goto Github PK

View Code? Open in Web Editor NEW
32.0 5.0 1.0 939 KB

PHP static site generator using the plates template system

Home Page: https://www.tapestry.cloud/

License: MIT License

PHP 94.99% Batchfile 0.01% JavaScript 0.30% CSS 0.09% HTML 4.05% Shell 0.56% Hack 0.01%
php static-site-generator php-plates thephpleague-plates tapestry static-site-generation static-website static-site command-line-tool

tapestry's Introduction

Tapestry

Plates PHP Static Site Generator

Build Status Test Coverage Latest Stable Version License

About Tapestry

Tapestry is a static site generator that uses the plates template system by the league of extraordinary packages. Tapestry aims to be fast, easy to use and easy to extend. It has been inspired by similar generators Sculpin and Jigsaw. Tapestry is designed for developers who prefer to use native PHP templates over compiled template languages such as Twig or Blade.

Highlights

  • Native PHP templates with the use of the plates template system
  • Blog aware out of the box
  • Built to be extendable with plugins

Learning Tapestry

The Tapestry documentation provides a thorough insight into the inner workings of Tapestry. Making it as easy as possible to get started generating your sites.

Installing Tapestry

The recommended method for installing Tapestry is to grab the latest zipped release here and unzip the contents into your $PATH to make it globally available from your command line.

For Windows environments a .bat file is included so that you do not have to type php tapestry.phar to run Tapestry; for it to work ensure it is kept in the same folder as the .phar.

For alternative methods of installing Tapestry see the install documentation here.

License

Tapestry is open sourced software licensed under the MIT License.

Not invented here

StaticGen has a list of other static site generators available, although to my knowledge Tapestry is the only one to use the PHPPlates template engine.

tapestry's People

Contributors

carbontwelve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

mishin

tapestry's Issues

TaxonomyArchiveGenerator doesn't pass taxonomy siblings list

Using a Taxonomy archive page with the following frontmatter:

---
title: Category Archive
use:
    - blog_categories
generator:
    - TaxonomyArchiveGenerator
    - PaginationGenerator
pagination:
    provider: blog_categories
    perPage: 3
---

You would expect to be able to see a list of taxonomy siblings passed through to the view being able to be displayed via $blog_categories with the current pages items being displayed via $blog_categories_items. This is a side effect of me attempting to keep the use system simple.

A workable fix should be by adding a Taxonomy view helper class that gets attached the view containing all the taxonomy siblings and the items requested for the current page.

Create a base Filesystem class

FileCopier, FileIgnored and FileWriter all have duplicate code, create a base class with the shared functionality to remove duplication.

General tidy up of the codebase

  • Remove deprecated lines from ArrayContainer
  • Remove obsolete RemoveDrafts module
  • Remove obsolete ParseFileTemplates module
  • Remove obsolete todos
  • Run phpmd and clean up all possible problems
  • Attempt to reduce cyclomatic complexity across all files to 10 or less if at all possible

Draft posts are published

Currently posts marked as drafts are published. Configuration needs adding that enables/disabled their generation.

ViewFile helpers

The ViewFile entity should have some helpers attached which aid in outputting a files taxonomy and date.

e.g.

// Current method
$item->getData('date')->format('F jS Y');

// Proposed date helper (with optional format argument)
$item->getDate('F jS Y');

Markdown files defining their own layout do not get rendered within that layout

Steps to reproduce:

Create the file source\test.md with the following content:

---
layout: page
title: "Test"
---

Test Content

Create the file source\_templates\page.phtml with the following content:

<h1><?= (isset($title) ? $title : ''); ?></h1>
<div><?= $this->section('content') ?></div>

Expected outcome is that upon building you end up with the file test.html with the following content:

<h1>Test</h1>
<div><p>Test Content</p></div>

What you actually get is <div><p>Test Content</p></div> the markdown is rendered out to .html and never gets passed through to a phtml template, defined or otherwise.

When a file has its date set in frontmatter ContentType breaks

When a file has date set in its frontmatter e.g:

---
title: test
date: 11/09/2016
---

or

---
title: test
date: 1451606400
---

Then it's not converted to an instance of DateTime which is what line 119 of ContentType is expecting. Expected behavior is that the date is always an instance of DateTime with front matter input being injected.

In the future the frontmatter date property will be used for scheduling posts to become published at a certain time and so should accept either a date in the format DD/MM/YYYY or as a unix timestamp.

Complete functionality for --clear flag

It would appear that the --clear flag as defined within the BuildCommand is not used.

The following todo within the Clean Step points to it being unfinished/forgotten functionality that needs completing:

this should be refactored into two steps, clear and clean. Clean will remove the .tmp folder while clear will remove the destination folder if asked by --clear cli flag

Add command line api command

For use with anvil, I need the current state of the workspace as parsed by Tapestry, preferably in the form of json.

Self-update should only work on phar

Currently there is nothing to stop the self-update tool from working if the user has installed via composer. Not that you can install via composer as per issue #11 unless you know how to force it.

Refactor Tapestry class constructor to accept Input

The Tapestry/Tapestry class constructor should accept an instance of Symfony\Component\Console\Input\Input rather than an array to remove the implicit usage of Symfony\Component\Console\Input\ArgvInput within its constructor.

1.0.4 Release is broken

The .phar is using DIR rather than $include for the require path ensuring the entire thing is broken...

Add stopwatch

TAPESTRY_START is set upon bootstrapping, the app should listen for --stopwatch and return how long execution took.

ViewFile helpers accessible via $this in views

An issue raised in both #32 and #30 is that the ViewFile class which is passed to the view within a collection which the view has asked for via use frontmatter, contains helper methods that are not available within the context of $this for each page.

For example a collection of blog posts passed to a category view will be an array of the ViewFile class (either via use or pagination it doesn't matter) and the ViewFile class contains useful methods such as getDate('d-m-Y') and getUrl().

It may be duplicating code having the same code in a plates extension as well as the ViewFile class so possibly the use of a trait containing the shared methods could work best in this case?

This is marked up as both a bug and an enhancement, the bug is that ViewFile helpers are not available within a view via $this and the enhancement is adding that missed functionality.

Add workspace scaffolders

You should be able to create scaffolds for your content types, for example a blog scaffold would produce a new blog post file with the front matter filled from the users input.

This could be a basic configurable thing, or a base class that project maintainers extend to add their own scaffolds to.

e.g:

$:> tapestry make:blog
Please enter a title: My Blog Post
The file ['_blog/08-03-2017-my-blog-post.md'] was successfully created.
$:>

CollectionItemGenerator should use a populate class

The CollectionItemGenerator should pass to the view the current item using a configurable container class. This way a user can define that they want the CollectionItemGenerator to set item equal to a defined class that gets $this->file passed to it.

Allow configuration via a YAML file

Third party tools such as Anvil should be able to easily configure Tapestry, this can be quite difficult when the configuration files are PHP arrays especially if you want them to remain human readable.

I propose allowing config files to be either a PHP array or a YAML file, with an exception thrown if both exist as the same time.

Split init project into own repository

The init command currently initiates a complex website project where it should just init the basics. The current project scaffold should have its own repository such as tapestry-example-site or some other such repo.

Fix global install via composer

C:\Users\Simon.Dann>composer global require carbontwelve/tapestry
Changed current directory to C:/Users/Simon.Dann/AppData/Roaming/Composer
Using version ^1.0 for carbontwelve/tapestry
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install carbontwelve/tapestry 1.0.6
    - Conclusion: don't install carbontwelve/tapestry 1.0.5
    - Conclusion: don't install carbontwelve/tapestry 1.0.4
    - Conclusion: don't install carbontwelve/tapestry 1.0.3
    - Conclusion: remove symfony/filesystem v3.0.4
    - Installation request for carbontwelve/tapestry ^1.0 -> satisfiable by carb
ontwelve/tapestry[1.0.0, 1.0.3, 1.0.4, 1.0.5, 1.0.6].
    - Conclusion: don't install symfony/filesystem v3.0.4
    - carbontwelve/tapestry 1.0.0 requires symfony/filesystem ^3.1 -> satisfiabl
e by symfony/filesystem[v3.1.0, v3.1.1, v3.1.10, v3.1.2, v3.1.3, v3.1.4, v3.1.5,
 v3.1.6, v3.1.7, v3.1.8, v3.1.9, v3.2.0, v3.2.1, v3.2.2, v3.2.3, v3.2.4, v3.2.5,
 v3.2.6].
    - Can only install one of: symfony/filesystem[v3.1.0, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.1, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.10, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.2, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.3, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.4, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.5, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.6, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.7, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.8, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.1.9, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.2.0, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.2.1, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.2.2, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.2.3, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.2.4, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.2.5, v3.0.4].
    - Can only install one of: symfony/filesystem[v3.2.6, v3.0.4].
    - Installation request for symfony/filesystem (locked at v3.0.4) -> satisfia
ble by symfony/filesystem[v3.0.4].


Installation failed, reverting ./composer.json to its original content.

Package phine/phar is abandoned, use box-project/box2 instead.

Package phine/exception is abandoned, you should avoid using it. No replacement was suggested.
Package phine/path is abandoned, you should avoid using it. No replacement was suggested.
Package phine/observer is abandoned, you should avoid using it. No replacement was suggested.
Package phine/phar is abandoned, you should avoid using it. Use box-project/box2 instead.
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.

If taxonomy not set in blog post, $categories doesn't get set in view

$categories and $tags should always exist (as well as any other taxonomy set for a content type) even if it is not referenced by a file within its front matter.

If a content type has taxonomy and a file within that content types collection does not reference any taxonomy, then that file should have the specific variable set as an empty array for that taxonomy, or else a reasonable default which may be configured - e.g Misc like with Wordpress.

For the time being I have added the method taxonomyList to ViewFileTrait as my views expected $category to exist when it didn't because the blog post in question did not have any categories set.

PaginationGenerator does not generate correctly for blog index

To reproduce create the file source\blog\index.phtml with the below font matter:

---
layout: default
title: Blog Archive
use:
    - blog
    - blog_categories
generator:
    - PaginationGenerator
pagination:
    provider: blog
    perPage: 3
---

Expected behaviour is that the files blog\index.html, blog\1\index.html, etc are generated. What actually happens is blog\index.html gets generated as expected and then index\2.html, index\3.html and so on plus the urls that the pagination pages use are all incorrectly set to blog\index.

ContentType enabled property not used

ContentType configuration can enable/disable a content type, however the property does not appear to be used in Tapestry. It is however used by carbontwelve/tapestry-api and therefore a isDisabled method is needed to provide access to the otherwise private property.

Testing the cli functionality doesn't match real world

Tests that use the Symfony ApplicationTester have to pass the input in the format of:

[
  'command' => 'build',
  0 => '--quiet',
  'env' => 'development'
]

Which does not match the expected input of $_SERVER['argv'] when running on the actual command line:

[
  0 => 'build',
  1 => '--quiet',
  2 => '--env=development'
]

Unit tests need refactoring so that the arguments passed to Tapestry are consistent with what it receives in the real world.

Fatal error: Access level to Tapestry\Plates\Template::section() must be public

It looks as though something has changed with PHP Plates which has made the Tapestry extension of it broken.

Fatal error: Access level to Tapestry\Plates\Template::section() must be public (as in class League\Plates\Template\Template) in C:\Users\Simon\Documents\Projects\tapestry\src\Plates\Template.php on line 16

Call Stack:
    0.0003     124736   1. {main}() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\phpunit:0
    0.0047     408328   2. PHPUnit_TextUI_Command::main() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\phpunit:47
    0.0047     408656   3. PHPUnit_TextUI_Command->run() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\TextUI\Command.php:106
    0.1025    2061024   4. PHPUnit_TextUI_TestRunner->doRun() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\TextUI\Command.php:155
    0.1488    2198744   5. PHPUnit_Framework_TestSuite->run() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:429
    0.1720    2496912   6. PHPUnit_Framework_TestSuite->run() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\Framework\TestSuite.php:747
    0.1787    2501496   7. PHPUnit_Framework_TestCase->run() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\Framework\TestSuite.php:747
    0.1787    2501496   8. PHPUnit_Framework_TestResult->run() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\Framework\TestCase.php:726
    0.1788    2502152   9. PHPUnit_Framework_TestCase->runBare() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\Framework\TestResult.php:685
    0.1789    2518872  10. PHPUnit_Framework_TestCase->runTest() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\Framework\TestCase.php:770
    0.1789    2519376  11. ReflectionMethod->invokeArgs() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\Framework\TestCase.php:910
    0.1789    2519576  12. Tapestry\Tests\BuildCommandTest->testDefaultInit() C:\Users\Simon\Documents\Projects\tapestry\vendor\phpunit\phpunit\src\Framework\TestCase.php:910
    0.2072    2520376  13. Tapestry\Tests\CommandTestBase->runCommand() C:\Users\Simon\Documents\Projects\tapestry\tests\BuildCommandTest.php:19
    0.2282    3541048  14. Symfony\Component\Console\Tester\ApplicationTester->run() C:\Users\Simon\Documents\Projects\tapestry\tests\CommandTestBase.php:114
    0.2310    3690416  15. Symfony\Component\Console\Application->run() C:\Users\Simon\Documents\Projects\tapestry\vendor\symfony\console\Tester\ApplicationTester.php:100
    0.2756    3691640  16. Symfony\Component\Console\Application->doRun() C:\Users\Simon\Documents\Projects\tapestry\vendor\symfony\console\Application.php:122
    0.2760    3692192  17. Symfony\Component\Console\Application->doRunCommand() C:\Users\Simon\Documents\Projects\tapestry\vendor\symfony\console\Application.php:191
    0.2760    3692472  18. Symfony\Component\Console\Command\Command->run() C:\Users\Simon\Documents\Projects\tapestry\vendor\symfony\console\Application.php:830
    0.2763    3694792  19. Tapestry\Console\Commands\Command->execute() C:\Users\Simon\Documents\Projects\tapestry\vendor\symfony\console\Command\Command.php:255
    0.2763    3694960  20. Tapestry\Console\Commands\BuildCommand->fire() C:\Users\Simon\Documents\Projects\tapestry\src\Console\Commands\Command.php:26
    0.2773    3727112  21. Tapestry\Generator->generate() C:\Users\Simon\Documents\Projects\tapestry\src\Console\Commands\BuildCommand.php:72
    0.3050    4518248  22. Tapestry\Modules\Content\Compile->__invoke() C:\Users\Simon\Documents\Projects\tapestry\src\Generator.php:39
    0.3053    4519032  23. Tapestry\Entities\Renderers\PlatesRenderer->render() C:\Users\Simon\Documents\Projects\tapestry\src\Modules\Content\Compile.php:142
    0.3053    4519208  24. Tapestry\Plates\Engine->renderFile() C:\Users\Simon\Documents\Projects\tapestry\src\Entities\Renderers\PlatesRenderer.php:69
    0.3053    4519272  25. Tapestry\Plates\Engine->make() C:\Users\Simon\Documents\Projects\tapestry\src\Plates\Engine.php:36
    0.3053    4519440  26. spl_autoload_call() C:\Users\Simon\Documents\Projects\tapestry\src\Plates\Engine.php:19
    0.3053    4519480  27. Composer\Autoload\ClassLoader->loadClass() C:\Users\Simon\Documents\Projects\tapestry\src\Plates\Engine.php:19
    0.3054    4519592  28. Composer\Autoload\includeFile() C:\Users\Simon\Documents\Projects\tapestry\vendor\composer\ClassLoader.php:301
    0.3056    4532824  29. include('C:\Users\Simon\Documents\Projects\tapestry\src\Plates\Template.php') C:\Users\Simon\Documents\Projects\tapestry\vendor\composer\ClassLoader.php:412

Extending Tapestry Plates doesn't work...

When extending the Tapestry overloading of the Plates Engine from a site Kernel, that extension is not made available to the templates with Tapestry returning a function not found error.

The project specific extension to the plates ExtensionInterface is executed, but doesn't appear to be carried over to rendering; write TTD and investigate why.

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.