Coder Social home page Coder Social logo

punch's People

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  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  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  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar

punch's Issues

Less parser.js error: 385

I recently moved the twitter bootstrap less files into a folder called boostrap in my css folder in templates. I import the bootstrap.less file into a file I call custom.less and use punch's bundling to minify into all.css as per your example.

$ punch s

is successful but

$ punch g
Generating site...

/usr/local/lib/node_modules/punch/node_modules/less/lib/less/parser.js:385
                        throw new(LessError)(e, env);
                              ^
[object Object]

fails with the above error code. If I run:

$ lessc custom.less

I receive no errors, and if I compile my code with lessc into a css file and remove all my less files from my project then punch g works.

You can look into the project here

Thanks

Sass compiler module produces wrong output

When I use "sass" notation I get empty css file, containing single "null" word... File syntax was checked with ruby-sass. When I tried "scss" notation (with brackets), It worked ok.

fingerprint errors

When generating the site with

"asset_bundling": {
    "fingerprint": true
}

the generated css and js receive a file name with {timestamp} (for example: /css/all-1349374532000.css)
but the file generated is all.css so when i try accessing the site the css/js do not load.
I believe the correct result should be /css/all.css?t=1349374532000 or something similar. or the output file should also be named all-1349374532000.css and not all.css

Any thoughts?

s3 publishing on 0.3.4

Here is the output I have when I use punch p s3

(company)whits-iMac:wedding-cards whit$ punch p s3

/usr/local/lib/node_modules/punch/lib/publishers/s3.js:63
            self.copyFile(entry.path, callback);
   ^
ReferenceError: self is not defined
    at [object Object].<anonymous> (/usr/local/lib/node_modules/punch/lib/publishers/s3.js:63:4)
    at [object Object].emit (events.js:70:17)
    at ProxyReader.<anonymous> (/usr/local/lib/node_modules/punch/lib/utils/deep_fstream.js:24:10)
    at ProxyReader.emit (events.js:67:17)
    at DirReader.<anonymous> (native)
    at DirReader.emit (events.js:67:17)
    at DirReader.emitEntry (/usr/local/lib/node_modules/punch/node_modules/fstream/lib/dir-reader.js:247:8)
    at FileReader.EMITCHILD (/usr/local/lib/node_modules/punch/node_modules/fstream/lib/dir-reader.js:157:12)
    at FileReader.emit (events.js:67:17)
    at go (/usr/local/lib/node_modules/punch/node_modules/fstream/lib/reader.js:219:10)

Less @imports

I can't seem to get Less @imports to work, I get the following error when trying to do @import "normalize.less";:

/usr/local/lib/node_modules/punch/node_modules/less/lib/less/parser.js:418
                        else                                  throw new(LessEr

Is this possible and I'm just doing something wrong?

Windows installation fails due to pty.js dependency

The punch dependency on sftp introduces another dependency on pty.js. When a node-gyp rebuild happens during node install punch, the following error occurs:

 ..\src\pty.cc(20): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory [C:\dev\punch\node_modules\punch\node_modules\sftp\node_modules\pty.js\build\pty.vcxproj]

The lack of unistd.h on Windows is documented here.

This closed pty.js issue includes a statement by the author of pty.js regarding support for Windows, which can be summarized as "not possible".

Here are details regarding my configuration:

  • Windows 7 64-bit
  • Node.js 0.8.14 (x64)
  • npm 1.1.65
  • punch 0.4.18
  • pty.js 0.1.2

I hope I'm overlooking an obvious solution or workaround as I was looking forward to trying Punch.

Brian

Document npm local vs global installation of punch and/or plugins

I ran into some issues installing a punch plugin laktek/punch-sass-compiler#1 which I've been unable to replicate. None the less I think some mention of npm's ability to do local as well as global package installs would be useful.

It might also be useful to discuss various approaches to installing punch and plugins and the pros and cons of local vs global install location.

This helped me understand npm Local vs Global:
'Where does npm put stuff?' and following answers at https://npmjs.org/doc/faq.html

Punch positioned as a generator or frontend?

Hi Lakshan,
I've been going through and messing around with Punch, and I have to say that I enjoy using it. Your initial "first run" walk-through is wonderful.

I'm curious though, are you creating Punch to be more of a generator that resides on a local development computer and just pushing static output to the server, or is Punch's design goal to sit on the front end as a server/publishing system (with publishing static files an option)?

Module css generation/bundling error

I'm having an error when Punch generates css files on the fly. I have the following structure in my template folder:

| -- Templates
|    | -- css
|    |    | -- modules
|    |    |    | -- m-nav.css
|    |    |    | -- m-feature.css
|    |    |    | -- m-shared.css
|    |    |    | -- etc.

In my config.json I'm using wildcards to pull the modules (including whole config file):

{
    "template_dir": "templates",
    "content_dir": "contents",
    "output_dir": "site",
    "server": {
        "port": 9009,
        "generate_interval": 10000,
        "serving_only": false
    },
    "bundles": {
        "/css/module.css": [
            "css/modules/*.css"
        ],
        "/css/framework.css": [
            "/css/framework/normalize.css",
            "/css/framework/foundation.css"
        ],
        "/css/all.css": [
            "/css/framework.css",
            "/css/base.css",
            "/css/layout.css",
            "/css/module.css",
            "/css/theme.css",
            "/css/state.css"
        ]
    },
    "generator":{
        "blank":true
    }
}

When I punch g --blank it works as expected. When I update a template file it works as expected. If I update a css file in css/module/ some of my module css code breaks.

That's right, only some of it doesn't auto generate... What I've come to discover is that punch doesn't re-generate css/module files that come after the module file I update.

I'll break it down. First I use punch g --blank and see a list of files in my console:

...
Created /scripts/polyfill/selectivizr-min.js
Created /scripts/polyfill/boxsizing.htc
Created /css/framework/bootstrap.css
Created /css/framework/foundation.css
Created /css/framework/normalize.css
Created /css/modules/m-feature.css
Created /css/modules/m-product-form.css
Created /css/modules/m-product-table.css
Created /css/modules/m-nav.css
Created /css/modules/m-icons.css
Created /css/modules/m-image-viewer.css
Created /css/modules/m-clearing.css
Created /css/modules/m-shared.css
Created /css/modules/m-rating.css
Created /humans.txt
Created /apple-touch-icon.png
Created /favicon.ico
...

Then I update /css/modules/m-nav.css and reload my page.

The generated file /css/module.css contains code from these files:

/css/modules/m-feature.css
/css/modules/m-product-form.css
/css/modules/m-product-table.css
/css/modules/m-nav.css

If I were to update /css/modules/m-product-form.css and reload my page the generated file /css/module.css contains only code from:

/css/modules/m-feature.css
/css/modules/m-product-form.css

Seems like it hits the updated code and ignores the remaining files when it generates my module css file.

Bundles parts also generated in output with `punch g`

Hi,

I have a config.json that looks like this :

{
  "template_dir": "templates", 
  "content_dir": "contents",
  "output_dir": "output",

  "server": { 
    "port": 9009
  },

  "bundles": {
    "/assets/stylesheets/all.css": [
      "/assets/stylesheets/application.css",
      "/assets/stylesheets/welcome.less"
    ],

    "/assets/javascripts/all.js": [
      "/assets/javascripts/jquery.min.js",
      "/assets/javascripts/jquery-ui.min.js",
      "/assets/javascripts/jquery.init.js",
      "/assets/javascripts/jquery.slider.min.js",
      "/assets/javascripts/application.js"
    ]
  },

  "generator" : {
    "blank" : false
  }
}

When I remove the output folder and run punch g, all-TIMESTAMP.js and all-TIMESTAMP.css are generated but the other files (jquery, jquery-ui, welcome.css...) are also generated which is unnecessary as only all-TIMESTAMP.(css|jss) are needed.

Am I doing something wrong?

Interactive tutorial fails if you're not accessing the site through localhost.

My personal dev preference is to work on a headless linux vm to more closely match my production server. So I'm accessing the test site/tutorial via an actual domain e.g. dev.example.com:9009 rather than localhost:9009.

I've created _about and intro.markdown, but visiting dev.example.com:9009/about merely shows the same page as dev.example.com:9009. The tutorial doesn't advance as a result.

(The only browser that works on my headless localhost is lynx and that doesn't do the js, so no use either.)

From the in page javascript it looks like 'localhost' is hard coded into the script, rather than being dynamically generated via the url.

Obvious workaround is to use my host OS (OSX) for the tutorial, or one of the linux vm's I have with a full desktop, or whatever. But I wonder if this couldn't be made more robust.

Further bundling

Hi Lakshan,

I'm working on a project where others are involved and it's making sense to break CSS modules out into their own individual files and then combine them all into a master modules.css, which in turn is combined with all the other types of CSS.

Anyway, a few lines of code are worth a thousand words:

"bundles": {
    "/css/module.css": [
        "/css/modules/*.css"
    ],
    "/css/all.css": [
        "/css/base.css",
        "/css/layout.css",
        "/css/module.css",
        "/css/theme.css",
        "/css/state.css"
    ]
}

Firstly, as more of a designer than a developer perhaps this is silly. Second, if it's not silly is it possible? I tried a few different versions of the above with the * to no avail.

Thanks!

Feature request: automatic browser refresh

It would be nice if punch server would not just recompile but also push changes out to browsers LiveReload style.

https://github.com/stephenlb/nodejuice is a standalone project that does similar but since punch already has it's own 'seeker' server watching for file changes it would seem half of the functionality is already there.

This would be a great feature.

Use both custom content handler and default content handler?

How can I use both a custom content handler and the default content handler?

For example, say I have a blog section, but I want to pull the data from some API, but only in that section.

I want shared.json available everywhere, and I want all the other pages and sections to use the default methods (i.e. _about/seo.json, _about/history.markdown).

I imagine this is probably simple in the content_handler.js module, but I can't seem to get it.

Thanks

"output_dir" config option being ignored on 0.5.0

I have "output_dir" set to "public" within config.json but punch g is outputting to output directory.

Full config.json:

{
    "template_dir": "templates", 
    "content_dir": "contents",
    "output_dir": "public",

    "server": { 
        "port": 9009
    }
}

The tutorial doesn't seem to work on Windows 8

I've been trying to use Punch on Windows 8 and have been running into problems going through the tutorial. I've tried the same thing on the latest version of Ubuntu and the tutorial works perfectly.

Before I start listing the issues I thought I'd asked whether this has been tested on Windows only because if it had it's clearly an issue with my environment.

Design Concept for Punch Web Site

Hi Lakshan,

Here's a quick preview of a design concept I came up with. It's basically inspired by boxing posters from the mid 1900's, but not an overt copy. I kept the structure exact to the current HTML, but if we were to update the HTML slightly I could do a bit more with layout and certain details.

There are some existing details I didn't have time to get to yet but could incorporate into the comp or via CSS.

In CSS, I would also make the design responsive.

Click the image to view full size
Punch site design concept

Docs: Multi-site setup

Can you please provide more documentation on setting up a multi-site install with shared resources? The docs do mention it briefly, but a dedicated page would be appreciated!

For Example:

One Domain with Multiple Subdomains
Say I have domain.com as my main site and want to setup a few subdomained sites with similar design. These will be something like products.domain.com, support.domain.com, etc. They will share the same assets such as CSS, JS, Images, etc. Since they are separate subdomains they will need to be output to different folders and have separate config.json files.

Update s3 publishing example to show how to do public-read acl

Hi Lakshan,

I published recently but the website went down because all the acls were reset to private.

This is because knox uses private amazon acls by default. Are you able to update the documentation
to show how to set the acls to public?

Cheers

punch setup without arguments

Running punch setup without any arguments:

punch setup
/usr/local/lib/node_modules/punch/lib/cli.js:50
    if(args[0].length > 1){
              ^
TypeError: Cannot read property 'length' of undefined
    at Object.setup (/usr/local/lib/node_modules/punch/lib/cli.js:50:15)
    at Object.init (/usr/local/lib/node_modules/punch/lib/cli.js:133:26)
    at Object.<anonymous> (/usr/local/lib/node_modules/punch/bin/punch:7:5)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:31)
    at Function._load (module.js:311:12)
    at Array.0 (module.js:484:10)
    at EventEmitter._tickCallback (node.js:190:38)

Gives this error which doesn't describe the cause. Perhaps calling punch setup without arguments should print a help message or message that you must set a directory?

Tutorial: markdown output fails to render as HTML

When using intro.markdown, the tutorial won't continue. I guess it's because the generated HTML is escaped. I can read <p>This is some intro text.</p> including HTML Tags. The tutorial JS seems to expect <p> tags, not CDATA-like text with <p> in it, so I suppose something's broken.

Windows install/usage instructions

Hello! Thanks for a wonderful tool and so forth.

I've found two obstacles for running punch on windows, and I thought I'd share them here, maybe create a wiki entry?

1 npm and git://

Problem: npm does not handle git:// urls from cmd.exe
Solution: install in bash, works with git-bash

2 the 'cp' command

Problem: Copying the files are hard-coded in the source to use "cp" which is a *NIX-command, and further using copy instead of cd (through adding a cp.cmd that redirects to copy or editing the source) will not work either as the paths are hard-coded with forward-slashes which "copy" does not handle well.
Solution: Using a mingw32-cp, like the one installed with msys-git

Partial layouts not properly reloaded

I followed the first run instructions, wich went quite well. But when I got to the last step, where I was prompted to remove the {{{first-run}}} tag in the footer partial, the partial was not reloaded after the changes I made.

After a bit of messing around, I realized none of the partials were reloaded when I made changes, until I changed something in the main layout file. But again, this doesn't seem to be true all the time. Sometimes, even if I change something in the footer and layout, only changes made in the main layout will be shown when running the site.

I'm currently running the site on localhost:9009 using punch s, with node 0.8.8.

What am I doing wrong?

s3 publish path fail

Hi I use punch on a mac. And when I do punch p I find that it tries to upload to

bucketname.aws.amazonaws.comUsers/jervis/punchwebsite/public/index.html

when it should be

bucketname.aws.amazonaws.com/index.html

I think the bug happens because deep_fstream is giving the full expanded path instead of the relative path to copyFile.

I've written some code that uses fs instead of fstream module. It works ok except there is a different bug to do with unexpected socket errors now (so I can't contribute the code as is)

[wiki] [create template] Document how to do template inheritence

My website has three pages:

index.html
/ productpage1.html
/ productpage2.html

The layout is identical on all of them. The only thing that changes is some content details (headings, paragraph text etc)

How would you structure such a site using punch? Can I update with the wiki with this information? It really shows how you would structure a real site.

javascript bundles always produce files with zero bytes

For reference, you can try the example site in the root of the main branch. I've tried it two computer (both macs, Mountain Lion and Lion) and every time the css files are generated properly but all.js has zero bytes. I've seen the same behavior on my own site.

Support for non-latin languages

It seems that punch doesn't support cyrillic text after generating static html

Before (index.json):

{
    "title": "Х-фактор",
}

After (index.html):

<title>%-D0:B>@</title>

Incompatible with Windows?

When I tried to use punch to generate a site with node.js on windows, it threw this error:

"Error: Command failed: 'cp' is not recognized as an internal or external command, operable program or batch file."

The trace was from C:\Users\Julia\AppData\Roaming\npm\node_modules\punch\lib\project_creator.js:32

Using an asset bundle helper tag causes getTime error

Using a bundle helper tag as described in https://github.com/laktek/punch/wiki/Asset-Bundles generates an error 500 (internal server error):

 [TypeError: Cannot call method 'getTime' of undefined]

Location of source stylesheet is: /templates/css/main.styl
Location of generated stylesheet is: /output/css/main.css

Tag used in _layout.mustache:

{{#stylesheet_bundle}}/css/main.css{{/stylesheet_bundle}}

Am I right in thinking that the helper tag should point to the generated css and not the source styl file?

punch g fails on LESS file (while punch s is not)

Hi,

thanks a lot for this very easy tool. I like it pretty much!
I migrated a website over punch but I encounter a problem when generating the outputs.

I have a template/css/screen.less beginning by this:

// CSS Reset
@import "../../vendor/bootstrap/less/reset.less";

// Core variables and mixins
@import "components/variables.less"; // Modify this for custom colors, font-sizes, etc
@import "../../vendor/bootstrap/less/mixins.less";

// Grid system and page structure
@import "../../vendor/bootstrap/less/scaffolding.less";

Site generation displays this:

$ punch g
Generating site...
Created /css/screen.css
.Created /css/fonts.css
.....Created /css/components/variables.css

/usr/local/lib/node_modules/punch/node_modules/less/lib/less/parser.js:421
                        throw new(LessError)(e, env);
                              ^
[object Object]

I guess there is a problem with imports but the files were previously working (I managed them through grunt-contrib-less with imports configuration.

In case you need it, the whole code is here.

Thanks for support!

sporadic terminate thrown after error

Since updating to 0.5.11 punch server has been periodically aborting with this error (on page refresh).

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid
Aborted

It might possibly happen when a precompiler (stylus or sass) throws an error, but deliberately introducing an error for stylus/sass doesn't cause the abort. After the error you can do 'punch s' without issue and without it aborting for a while.

Error: Cannot find module 'mime'

I'm using nodejs v0.6.17 and npm 1.1.15 in ubuntu 12.04

I do sudo npm install -g puch
it's ok no errros.

so I do mkdir site and run punch setup

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'mime'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (/usr/lib/node_modules/punch/lib/server.js:9:12)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)

Wrong encoding for files with extension ≠ .html (xml, json, txt…)

I was trying to generate a "/rss.xml" based on a content handler : articles are taken from the punch-blog-content-handler but given the extension is .xml and not .html, then cache store will write it using binary encoding.

That's not what I want because in case of text file it will break encoding (I end with my UTF8 strings getting written as latin-1).

I fixed it with a generator hook, but it should probably be a core options. We may let user provide a list of paths or extensions that should be written using utf8 encoding instead of binary. Or if this is possible (I'm not sure you can distinguish them, but who knows) never use binary for generated files (from content handler) versus physically copied files.

Add a config option for ignoring paths

I ran into this error when running punch s after versioning my project with SVN (not my choice):

public/.svn/entries: Permission denied

If would be nice to have something like this in the config.json that would result in the matches being ignored and not copied to the "output_dir":

"ignore": [ ".svn", "*.foo", "readme.md"]

Any way to get Punch on windows?

Really excited by this project and working well so far under Ubuntu...but really want to get this running under Windows (and eventually AZURE) as well. Using a Windows 7 workstation, where a lot of JRuby, and various node projects are being worked on and running... the npm install of punch fails.

Have had no problems installing and using mustache and underscore and lot of others without a problem on other projects, but the npm install of Punch is failing because of the spawn syscalls to git clone the dependencies ... see npm-debug.log below...and probably any of the spawn calls...

info using [email protected]
info using [email protected]

Is there a way to support installing this on Windows and update/modify the npm package to get around this? I'm going to work on manually tweaking the install, but wondering if you had plans to support npm installation of punch on windows and were possibly already working on it.

Great Project! Thanks for you efforts...

http GET https://registry.npmjs.org/marked
silly exec git "clone" "git://github.com/janl/mustache.js" "C:\Users[MyUserName]\AppData\Local\Temp\npm-1336671749658\1336671749658-0.6476961350999773"
silly spawning [ 'git',
silly spawning [ 'clone',
silly spawning 'git://github.com/janl/mustache.js',
silly spawning 'C:\Users[MyUserName]\AppData\Local\Temp\npm-1336671749658\1336671749658-0.6476961350999773' ],
silly spawning null ]
ERR! Error: spawn ENOTSUP
ERR! at errnoException (child_process.js:483:11)
ERR! at ChildProcess.spawn (child_process.js:446:11)
ERR! at Object.spawn (child_process.js:342:9)
ERR! at spawn (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\exec.js:118:22)
ERR! at exec (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\exec.js:50:12)
ERR! at C:\Program Files (x86)\nodejs\node_modules\npm\lib\cache.js:307:5
ERR! at Object.oncomplete (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\mkdirp\index.js:22:20)
ERR! You may report this log at:
ERR! http://github.com/isaacs/npm/issues
ERR! or email it to:
ERR! [email protected]
ERR!
ERR! System Windows_NT 6.1.7601
ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "punch"
ERR! cwd c:\Projects\NodeProjects\TaskList-MochaTesting
ERR! node -v v0.6.16
ERR! npm -v 1.1.19
ERR! syscall spawn
ERR! code ENOTSUP
ERR! message spawn ENOTSUP
ERR! errno {}
verbose exit [ 1, true ]

Opaque error message when json file is empty

To reproduce:

  • create a standard punch setup
    punch setup .
  • create an empty content file touch contents/index.json and a template curl t.co > templates/index.mustache
  • serve punch s

What I expect to happen:
An error message warning of the empty index.json file

What I get instead:

Server is running on localhost:9009
Generating the site...

undefined:0

^
SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /usr/local/lib/node_modules/punch/lib/generator.js:130:26
    at [object Object].<anonymous> (fs.js:123:5)
    at [object Object].emit (events.js:64:17)
    at Object.oncomplete (fs.js:1190:12)

How would you handle blog posts?

Given the current architecture how would you handle blog posts? The only way that I see to do it is to have a json object that references an array of mustache partials, like:

{
  "posts": [
    {
      "partial": "2012-9-1-test"
    }
  ]
}

Then have a partial named _2012-9-1-test.mustache

And in my blog.mustache have mustache loop through and include the partials like:

{{#posts}}
  {{>.}}
{{/posts}}

So two questions:

  • I'd rather have my blog posts be markdown files that are in the content/_blog folder, is this possible?
  • If its not possible, is there any consideration being given to having punch be "blog-aware" in a similar way that jekyll is? The way I could see doing that would be to have in the config.json a setting for "models" to "catalog". So you could say "catalog": ["blog", "portfolio"]. And then node will search the _blog and _portfolio directory for files that fall under a certain format, say year-month-day-title, and then it adds entries to the blog.json and portfolio.json with the parsed contents of the files, along with other data such as num_entries, snippets, etc.

I'd be willing to work on this if you agree on this architecture. If you don't agree, let me know what would make more sense to you.

Files in template dir w/ no registered renderer cause error

Could punch either 1) ignore files in template directory whose names begin with '.' (dotfiles), or 2) output a warning (instead of error) for files that don't have a renderer, or 3) both?

If I'm actively editing a template file in vim, vim will by default create a backup file in the same directory, called a swap file. Swap files start with '.' and have the extension '.swp'. Punch errors out when these files are encountered because they don't have a registered renderer. This means that punch won't run correctly if I'm actively editing a template file. There are workarounds in vim for where swp files are created/stored, but I think the suggestions above are reasonable.

Output of combined JSON files

Feature request/discussion topic: I have a structure like the one below for each post, basically a JSON file with some metadata and a summary and body of the post in markdown. This is working great in that I'm able to write templates that put it all together nicely. I'm doing some client side rendering and would like to have the generate process output a JSON file for each post that combines the JSON that is there now with the transformed markdown included in it. This would enable the client side javascript to render or conditionally render the HTML. Example use case is in a small screen device show only summaries but in a large screen show full bodies of posts.

Any thoughts on supporting this case? Is it possible to hook into the generation process in a easy way to make this possible?

| -- contents
|    | -- posts
|    |     | -- hello-word.json
|    |     | -- _hello-world
|    |     |    | -- summary.markdown
|    |     |    | -- body.markdown

Example JSON:

{
  "title": "Hello World",
  "thumbnail_image": "/assets/images/hello-world.png"
}

Example combined JSON:

{
  "title": "Hello World",
  "thumbnail_image": "/assets/images/hello-world.png",
  "summary": "<p>This is a great article</p>",
  "body": "<p>This was in a markdown file, it is now HTML</p>"
}

Partial templates, long content and markdown.

The situation:
I have several long text content pages (50 paragraphs on the first page...) and need to add several images into each one, in the text.

I'd like to use html5 figure/figcaption elements for these images which markdown has no support for. I was thinking it'd be nice to just define the images, titles and captions as json and render them with a 'partial' template instead of repeatedly adding the same markup to the content.

I've treated the long text as markdown although it is in fact just html at the moment.

The problem:
markdown is markdown, none of the punch helpers or partial templates will work from within markdown, markdown only does basic img elements. The only solution within markdown appears to be to write the figure/figcaption html. over and over.

Solutions:
What's the best solution?

I could put the long text content into a massive json document – but that just feels wrong, on top of being awkward to edit.

A 'figure' helper would perhaps be nice, but again wouldn't work in the context of markdown.
A custom content handler perhaps? to just parse fragments of html and run punch helpers so we could have helpers working in content?

I suppose just putting the content into the template would work, and having a custom 'content' template for each page. But that mixes up content and layout a lot. Plus I may as well just write the static html documents myself...

At the moment punch is really helpful for well structured content, anything a bit more free-form seems more awkward to handle.

Provide a way to add multiple content handlers

We can have many helpers, hooks, etc… but only one content handler, this makes it quite uneasy to append new content handlers above existing ones. For example in my case I use:

  • my dedicated custom content handler for some specific pages, which falls back to…
  • a content handler generating RSS, itself using…
  • blog-content-handler, which falls back to…
  • default content handler

Maybe the content_handler(s?) option could be an array, and core would:

  • unshift default content handler (so it's always here, cannot be disabled, or another option?)
  • concatenate all their "getSections" & co
  • for every negotiation: call all "negotiateContent", and merge provided contents (in the same order, last handler = most priority)

I don't think this would be too hard to do. What do you think? Do you see major issues with this vision (before I start working on PR)?

Default content

Hi,

Is there currently any way of implementing default/site-wide content? I'm thinking a defaults.json or site.json file where the contents for each page get deep merged into it to accommodate common site content.

On second thoughts, it wouldn't necessarily even need to be merged, it could just add a site key to the json that is made available to the template.

Is there currently a way to achieve this before I go ahead and look adding it?

Punch, just a missing feature of DocPad?

Hey Lakshan, I really like what you are doing with Punch, and your evangelism for it is fantastic.

Though I can't help but feel Punch is simply a missing feature of DocPad
In fact, here's the feature request: docpad/docpad#141

So I'm not particularly sure what the benefit of using and maintaing Punch is when compared to using and improving DocPad to be honest...

I'd love to hear your thoughts on this, Sincerely,

  • Ben

Improve error reporting when config.json has syntax errors

When starting the punch server with 'punch s', if there is a syntax error in config.json a warning is given and punch falls back on the default config:

Cannot read the custom config: Error: ENOENT, stat 'config'
Using the default config.

However if you introduce a syntax error to config.json whilst developing the site you may end up with a different error that obfuscates the real problem somewhat. For example a missing comma in a stylesheet bundle might give 'Error: Content for combined.css not found'.

I'm not sure which config punch then uses, does it continue to use the custom config, or immediately fall back on the default?

It might me better not to fall back on the default config at all, ever, since a single error in config.json could cause multiple customisations to stop working, not just the one with the syntax error, again somewhat masking the real issue.

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.