GithubHelp home page GithubHelp logo

templer's Issues

When using include files we don't rebuild if they change.

Consider the following page:

   Title: This is my page.
   menu: read_file( "menu.inc" )
    ---
   <p>This is my page</p>

The output should be rebuilt if:

  • The page is edited.
  • The layout is edited.
  • The templer.cfg file is edited.
  • The include file is edited.

Currently only the first two conditions will trigger a rebuild. If you carry out one of the other two actions the page will only be built if you run:

  • rm -rf output && temper
  • templer --force

We should store the mtime of each Templer::Site::Page and query that. This would allow the Templer::Plugin::FileContents plugin to update the mtime of the parent-page based on the filenames it examines.

NOTE: The plugin must be the thing that does the mtime updating, as that is the only location where we know what is included as a dependency.

NOTE: We should make sure shell commands always trigger a rebuild too. That's the safest way.

`make standalone` is broken.

I've just realized version 1.1 and, too late, I see that this doesn't work any more.

Fix this for 1.2 as a matter of some priority.

Variables not replaced with correct value

I have installed templer:

$ g clone https://github.com/skx/templer.git
$ cd templer
$ make
$ sudo make install

... and tested

$ make test
...
All tests successful.
Files=15, Tests=332,  1 wallclock secs ( 0.07 usr  0.02 sys +  0.98 cusr  0.05 csys =  1.12 CPU)
Result: PASS

So, when I build examples:

$ cd examples
$ make rebuild
$ cat simple/output/index.html

output is

$ cat simple/output/index.html
<html>
 <head>
  <title></title> <--- empty title variabile!
 </head>
...

My environment:

$ uname -a
Linux boe 3.12.6-1-ARCH #1 SMP PREEMPT Fri Dec 20 19:39:00 CET 2013 x86_64 GNU/Linux

$ perl -v
This is perl 5, version 18, subversion 1 (v5.18.1) built for x86_64-linux-thread-multi

We shouldn't only run from the top-level directory.

Although this simplified the initial migration and coding it is now painful when I'm working in:

   ~/hg/websites/steve.org.uk/input/Software/templer

I have to keep going back to ~/hg/websites/steve.org.uk to run the rebuild-command.

Suggestion: We keep running "cd .." until we hit a filesystem boundary, before aborting. Exactly like git/mercurial do things.

`templer --manual` is broken.

Because we use Pod::Usage we can embed the man-page inside the script itself, neat.

Unfortunately the main script is comprised of several modules concatenated together, and Pod::Usage shows all of them.

Installation from CPAN fails

If I install App::Templer through CPAN one of the test programs seems to fail, which means I can't install the module (other modules work fine).

I'm running Ubuntu 15.04 and Perl 5.20.2 and using local::lib. Happy to try other distros if that would help narrow down the problem, though there seem to be a lot of failures on CPAN Testers too.

Full error log:

perl -MCPAN -Mlocal::lib -e 'CPAN::install(App::Templer)
Reading '/home/paul/.local/share/.cpan/Metadata'
  Database was generated on Wed, 19 Aug 2015 13:53:35 GMT
Running install for module 'App::Templer'
Checksum for /home/paul/.local/share/.cpan/sources/authors/id/S/SK/SKX/App-Templer-0.9.9.1.tar.gz ok
Configuring S/SK/SKX/App-Templer-0.9.9.1.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for App::Templer
Writing MYMETA.yml and MYMETA.json
  SKX/App-Templer-0.9.9.1.tar.gz
  /usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for S/SK/SKX/App-Templer-0.9.9.1.tar.gz
cp lib/Templer/Timer.pm blib/lib/Templer/Timer.pm
cp lib/Templer/Site/Asset.pm blib/lib/Templer/Site/Asset.pm
cp lib/Templer/Plugin/Redis.pm blib/lib/Templer/Plugin/Redis.pm
cp lib/Templer/Plugin/Hash.pm blib/lib/Templer/Plugin/Hash.pm
cp lib/Templer/Plugin/FileContents.pm blib/lib/Templer/Plugin/FileContents.pm
cp lib/Templer/Plugin/FileGlob.pm blib/lib/Templer/Plugin/FileGlob.pm
cp lib/Templer/Plugin/Strict.pm blib/lib/Templer/Plugin/Strict.pm
cp lib/App/Templer.pm blib/lib/App/Templer.pm
cp lib/Templer/Plugin/Markdown.pm blib/lib/Templer/Plugin/Markdown.pm
cp lib/Templer/Plugin/Factory.pm blib/lib/Templer/Plugin/Factory.pm
cp lib/Templer/Plugin/Breadcrumbs.pm blib/lib/Templer/Plugin/Breadcrumbs.pm
cp lib/Templer/Plugin/Dollar.pm blib/lib/Templer/Plugin/Dollar.pm
cp lib/Templer/Plugin/TimeStamp.pm blib/lib/Templer/Plugin/TimeStamp.pm
cp lib/Templer/Plugin/RootPath.pm blib/lib/Templer/Plugin/RootPath.pm
cp lib/Templer/Plugin/RSS.pm blib/lib/Templer/Plugin/RSS.pm
cp lib/Templer/Plugin/ShellCommand.pm blib/lib/Templer/Plugin/ShellCommand.pm
cp lib/Templer/Site/Page.pm blib/lib/Templer/Site/Page.pm
cp lib/Templer/Site.pm blib/lib/Templer/Site.pm
cp lib/Templer/Global.pm blib/lib/Templer/Global.pm
cp lib/Templer/Site/New.pm blib/lib/Templer/Site/New.pm
cp lib/Templer/Plugin/Textile.pm blib/lib/Templer/Plugin/Textile.pm
cp lib/Templer/Plugin/HTML.pm blib/lib/Templer/Plugin/HTML.pm
cp lib/Templer/Plugin/Perl.pm blib/lib/Templer/Plugin/Perl.pm
cp bin/templer-generate blib/script/templer-generate
"/usr/bin/perl" -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/templer-generate
cp bin/templer blib/script/templer
"/usr/bin/perl" -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/templer
Manifying 2 pod documents
Manifying 23 pod documents
  SKX/App-Templer-0.9.9.1.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/style-no-tabs.t ........................... ok
t/style-no-trailing-whitespace.t ............ ok
t/test-dependencies.t ....................... ok
t/test-pod-syntax.t ......................... ok
t/test-strict.t ............................. ok
t/test-templer-asset-copying.t .............. ok
t/test-templer-page-expansion.t ............. ok
t/test-templer-plugin-factory-formatters.t .. ok
t/test-templer-plugin-factory.t ............. ok
t/test-templer-plugin-filecontents.t ........ ok
t/test-templer-plugin-fileglob.t ............ ok
t/test-templer-plugin-filters.t ............. ok
Use of uninitialized value in string eq at /home/paul/perl5/lib/perl5/Test/More.pm line 1298.
skip() needs to know $how_many tests are in the block at t/test-templer-plugin-redis.t line 60
# Tests were run but no plan was declared and done_testing() was not seen.
t/test-templer-plugin-redis.t ............... 
Dubious, test returned 254 (wstat 65024, 0xfe00)
All 9 subtests passed 
    (less 1 skipped subtest: 8 okay)
t/test-templer-plugin-rootpath.t ............ ok
t/test-templer-plugin-shellcommand.t ........ ok
t/test-templer-plugin-timestamp.t ........... ok
t/test-templer-site-new.t ................... ok
t/test-templer-site.t ....................... ok
t/test-templer-synchronization.t ............ ok

Test Summary Report
-------------------
t/test-templer-plugin-redis.t             (Wstat: 65024 Tests: 9 Failed: 0)
  Non-zero exit status: 254
  Parse errors: No plan found in TAP output
Files=19, Tests=670,  5 wallclock secs ( 0.16 usr  0.00 sys +  3.98 cusr  0.33 csys =  4.47 CPU)
Result: FAIL
Failed 1/19 test programs. 0/670 subtests failed.
Makefile:1042: recipe for target 'test_dynamic' failed
make: *** [test_dynamic] Error 255
  SKX/App-Templer-0.9.9.1.tar.gz
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports SKX/App-Templer-0.9.9.1.tar.gz

.htaccess files are not processed

I've added a .htaccess file to the input directory of one of my Templer sites, but when I run the templer command it's not copied across in the same way as *.pdf files or robots.txt. Is this intentional, or is Templer using something like *.* to get the files under input and therefore missing dotfiles?

Update our plugin-handlers.

I've just added the ability for plugins to have an init-method called, which is useful for my personal website. The reason for this is that you can now define a plugin which has two methods:

sub init {
    my( $self, $site ) = ( @_);
    $self->{ 'site' } ||= $site;
 }

 sub cleanup
 {     my ($self) = (@_);
     my $out   = $self->{ 'site' }->{ 'output' };
     my $pages = $self->{ 'site' }->{ 'output-files' };
      ..
  }

 Templer::Plugin::Factory->new()->register_plugin("Templer::Plugin::sitemap");

This plugin doesn't do anything during the build, but post-build the cleanup method is called and that generates $output/sitemap.xml. Lovely.

The problem is that the register_plugin method assumes there will be an expand_variables method in our plugin - wrap that with a UNIVERSAL->can test.

File inclusion should have a search path.

There are two forms of file inclusion:

  • Inclusion via the HTML::Template facility to use
  • Inclusion via the meta-data: foo: read_file( "path/here" );

Both forms should allow a search-path to be defined. When expanding file-inclusions we should search the directory tree, relative to the source file, as we do now. If that fails search the global-include path(s).

Suggest we allow --include-path=includes/:/home/includes or similar.

Pod::Find dependency not listed

cpanm App::Templer

lead to

Can't locate Pod/Find.pm in @INC (you may need to install the Pod::Find module) (@INC contains: /root/.cpanm/work/1641919760.17441/App-Templer-1.2/blib/lib /root/.cpanm/work/1641919760.17441/App-Templer-1.2/blib/arch /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl . /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl .) at /root/.cpanm/work/1641919760.17441/App-Templer-1.2/t/../bin/templer line 9

It worked after installing Pod-Parser-1.63 with cpanm.

OS: Debian v11.2

As Bruno said the code structure is confusing at times.

Specifically we want to allow defaults to be read from a configuration file, and then overridden by the command line.

To do that we parse the config file - via Templer::Global - and then parse the cmd line flags. These two sets of options (hashes, internally) are merged and then passed to Templer::Site where all the magic happens.

The Templer::Site object thus has all the values it needs for the generation - input path, output path, & etc.

Unfortunately the Templer::Site module continues to refer to the `Templer::Global object, for things like the include-path and passing state to plugins.

We want the plugins to refer to the site-object not the cfg-object, and we want to otherwise remove Templer::Global from Templer::Site.

Conclusion: This will have lots of code-churn, but no functional/visible change - except to the plugin-api. (Move the API to a hash? Instead of named params?)

Output filename should come from the page.

At the moment templer is responsible for converting the input file to the output filename.

We do this by stripping the prefix, and changing the suffix to .html, unconditionally.

If we moved the output-path handling into Templer::Page we'd have the easy ability to allow the output to be changed:

Title: This is my page title
Output: foo.html
----
<p>This is my page content.</p>

This would write to foo.html rather than the expected file.

Release signature invalid

I attempted to follow the instructions at https://packages.steve.org.uk/templer/ but -

# apt-key list steve
pub   dsa1024 2006-02-23 [SC]
      3661 9DAA B8E8 3147 1BB1  A3EF F3E8 C641 DC26 98A1
uid           [ unknown] steve.org.uk APT key (This key is only used to sign the APT repository at http://www.steve.org.uk/apt/) <[email protected]>
sub   elg2048 2006-02-23 [E]

# cat /etc/apt/sources.list.d/steve-kemp.list 
deb     http://packages.steve.org.uk/templer/jessie/ ./
# 
# apt -q update
Hit:1 http://security.debian.org/debian-security stretch/updates InRelease
Ign:2 http://packages.steve.org.uk/templer/jessie ./ InRelease
Get:3 http://packages.steve.org.uk/templer/jessie ./ Release [347 B]
Get:4 http://packages.steve.org.uk/templer/jessie ./ Release.gpg [181 B]
Ign:4 http://packages.steve.org.uk/templer/jessie ./ Release.gpg
Ign:5 http://mirror.bytemark.co.uk/debian stretch InRelease
Hit:6 http://mirror.bytemark.co.uk/debian stretch-updates InRelease
Hit:7 http://mirror.bytemark.co.uk/debian stretch Release
Reading package lists...
W: GPG error: http://packages.steve.org.uk/templer/jessie ./ Release: The following signatures were invalid: 36619DAAB8E831471BB1A3EFF3E8C641DC2698A1
E: The repository 'http://packages.steve.org.uk/templer/jessie ./ Release' is not signed.

I'm generally on stretch, is that the trouble? Could you release for stretch, pretty please?
Thanks

It isn't possible to auto-generate pages / create virtual pages.

At the moment input pages are processed, correctly, into output pages. We have plugin support that could be used to generate new pages - but we don't have the ability to do that.

Consider a plugin that you might desire to generate an automatic sitemap. You could write that as a standard variable-expanding plugin:

sub expand_variables{
   my( $self, $page, $data ) = ( @_);

   # record the input path.
   push( $self->{'pages'}, $page->source();

   # return the data unmodified
   return( $data )
}

sub cleanup
{
    # here we can iterate over the page-sources we've recorded in the
    # expand_variables method
}

That's the core of a plugin that can read every input-page, and record their filenames. The missing step is obviously the generation of the /output/sitemap.html file. Now we can read the configuration variables of the site and output pure HTML but that must be done without the access to the site layout.

The solution has to be a Templer::Site method to inject a virtual page into the build process. Something like:

  $site->addPage( { title => "Test title", random  => "bob", content => "This is my generated page", source => "sitemap.wgn" } );

Details need to be considered because the input page will be generated despite not living on disk.

The file-hash plugin is bogus.

The documentation doesn't match the code, and the use of Digest::SHA1 is a problem.

Suggestion:

  • Audit the code for behaviour.
  • Attempt to load both Digest::SHA1 and Digest::SHA.

Changes required:

  • If running with --verbose ensure we output the name of the file we're digesting.
  • Fail hard if both module(s) aren't present.

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.