Socket
Socket
Sign inDemoInstall

punch

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

punch - npm Package Compare versions

Comparing version 0.4.5 to 0.4.6

2

lib/content_handler.js

@@ -311,3 +311,3 @@ var _ = require("underscore");

} else {
return callback("[Error: Content not found]", null, null, {});
return callback("[Error: Content for " + basepath + " not found]", null, null, {});
}

@@ -314,0 +314,0 @@ });

@@ -6,3 +6,3 @@ var path = require("path");

content_dir: "contents",
output_dir: "public",
output_dir: "output",
shared_content: "shared",

@@ -12,3 +12,3 @@

skip_hosts: ["localhost", "127.0.0.1", ".local"],
fingerprint: false
fingerprint: true
},

@@ -15,0 +15,0 @@

@@ -9,5 +9,5 @@ /*jshint regexp: false */

var conditions = {
"initial": function() { return $.trim(main_text) === "" },
"step2": function() { return $.trim(main_text) === "This is just a placeholder." },
"step3": function() { return $("div[role=main] p").length < 1 },
"initial": function() { return window.location.href === "http://localhost:9009/" && $.trim(main_text) === "" },
"step2": function() { return window.location.href === "http://localhost:9009/" && $.trim(main_text) === "This is just a placeholder." },
"step3": function() { return window.location.href === "http://localhost:9009/" && $("div[role=main] p").length < 1 },
"step4": function() { return window.location.href !== "http://localhost:9009/about" && $(".navbar").children().length < 1 },

@@ -23,17 +23,17 @@ "step5": function() { return window.location.href === "http://localhost:9009/about" && $(".navbar").children().length < 1 },

"step1": "One of the basic principles of Punch, is to keep the contents separated from its presentation. When structuring your site, remember all presentational elements (layouts, precompiled &amp; static assets) needs to be placed in the `templates` directory, while all the information you need to communicate should go in the `contents` directory.\bIf you go inside the `templates` directory, you will find a file named `_layout.mustache`. This is the main layout of your site. You can create different layouts for different sections of your site. For now, we shall use the main layout to render all pages of the site.\bOpen the `_layout.mustache` and place the tag `{{{intro}}}` inside the `&lt;div role=\"main\"&gt;&lt;/div&gt;`.\bReload this page when you're done.",
"step1": "We believe the separation of content from its presentation is important for any kind of site. To make this easy, Punch creates two directories named `contents` and `templates`. All information you wish to communicate should go in `contents`; all presentational elements (layouts, assets) should be placed in `templates`.\bIf you go inside the `templates` directory, you will find a file named `_layout.mustache`. This is the main layout of your site. You can create different layouts for different sections of your site. For now, we shall use the main layout to render all pages.\bOpen the `_layout.mustache` and place the tag `{{{intro}}}` inside `&lt;div role=\"main\"&gt;&lt;/div&gt;`.\bReload this page when you're done.",
"step2": "Did you notice that the `intro` tag you just placed, got replaced with some placeholder text? Let's understand what happened there.\bWhen Punch serves a request, it looks for the best matching content and layout to render the requested page. In this case, we are requesting for the `/index.html` page. So Punch chose the `contents/index.json` as the best matching content and the main layout to render the page.\bIf you look in `contents/index.json`, you will find a property named `intro` defined there. It's the value that got rendered on the page. Try changing it to see what happens.\bDid you change the value of `intro`? Then, reload this page.",
"step2": "Did you notice that the `intro` tag you just placed, got replaced with some placeholder text? Let's try to figure out how it happened.\bWhen Punch serves a request, it looks for the best matching content and layout to render the requested page. In this case, we requested for the `/index.html` page. So, Punch chose `contents/index.json` as the best matching content and the main layout to render the page.\bIf you look in `contents/index.json`, you will find the `intro` property defined. You can change its value and see the effect.\bReload this page after changing the value of `intro`.",
"step3": "Nice! You should now see the value you just defined, rendered on the page. [JSON](http://json.org) is a good way to define short, structured content. But what about long, formatted content we often want to insert into our pages? It would be cumbersome if we had to write HTML tags inside JSON strings. Well, there's a smarter way - use [Markdown](http://daringfireball.net/projects/markdown/).\bSo let's create a new file and rewrite our intro using Markdown syntax. Check how you can break the text into multiple paragraphs, emphasize points and add links using Markdown.\bBTW, there's a special convention to follow when saving Markdown content in Punch. Inside `contents` create a new directory named `_index` (page name preceded by an underscore). Inside it save your new file as `intro.markdown` (filename should be the property you are defining using Markdown).\bReload this page again to see your changes.",
"step3": "Nice! You should now see the value you just defined got rendered on the page. [JSON](http://json.org) is a good way to define short, structured content. But what about long, formatted texts we often want to insert into our pages? It would be cumbersome if we had to write HTML tags inside JSON strings. Well, there's a smarter option - [Markdown](http://daringfireball.net/projects/markdown/).\bLet's try to define the intro text using Markdown. For that, we need to create a directory named `_index` under `contents`. Then inside it, create a file named `intro.markdown`. Write the intro in that file, using Markdown. Make sure you break the text into multiple paragraphs, emphasize points and add links.\bReload the page again, to see how updated intro will render.",
"step4": "You're picking up so fast! Now, shall we add another page to the site?\bLet's add a About page to the site. Follow the same steps you took to create the contents for the Index page. Hint: You can start by creating a directory named `_about`.\bIf you did it correctly, visiting [http://localhost:9009/about](http://localhost:9009/about) should show the contents you created for the About page.",
"step4": "You're picking up so fast! Notice how you can provide content for a page, in a JSON file named by the page name(`index.json`) and/or a directory named by the page name preceded with an underscore(`_index`), placed inside `contents`.\bSuch a directory, is known as extended contents, can contain parsable content such as Markdown files or even JSON files. Those content can be accessed in layouts by the name of the file (eg. intro.markdown is accessed as `intro`).\bFollowing these concepts, let's add a About page to the site. Create a directory named `_about` in `contents` and place a `intro.markdown` file for the About page as well.\bOnce done, visit [http://localhost:9009/about](http://localhost:9009/about) to see the About page you just created.",
"step5": "Great job! Since there are already two pages in the site, it's better to add a navbar.\bOpen the `shared.json` file in `contents` and modify the `navbar` property to look like this:\b<pre>\"navbar\": [\n { \"label\": \"Home\", \"href\": \"/\" },\n { \"label\": \"About\", \"href\": \"/about\" }\n]</pre>\bReload the page, when you're done.",
"step5": "Great job! Since there are already two pages in the site, it's better to add a navbar.\bOpen the `shared.json` file in `contents` and modify the `navbar` property to look like this:\b<pre>\"navbar\": [\n { \"label\": \"Home\", \"href\": \"/\" },\n { \"label\": \"About\", \"href\": \"/about\" }\n]</pre>\bAlso, you can change the title of your site by changing the `site-title` property.\bReload the page, when you're done.",
"step6": "We had the markup for the navbar pre-defined in `templates/_header.mustache`, that's why it showed up automagically. `_header.mustache` is a partial layout that can be shared across multiple layouts.\bAlso note, when you define a property in `shared.json`, it's made available to all pages of the site.\bNow let's go back to [homepage](/) and try to make it little prominent.",
"step6": "Sweet! This site is coming up nicely. If you want to change the markup used for the site title and navbar, you can do it by editing `templates/_header.mustache`. Layout files, other than the `_layout.mustache`, that has a name starting with an underscore are known as partial layouts. You can include them in other layouts, using the following syntax - `{{> header }}`.\bAlso note, any property you define in `contents/shared.json` is made available to all pages of the site.\bNow let's go back to [homepage](/) and try to make it little prominent.",
"step7": "Rather than using the main layout, we'll use a layout specifically for the homepage.\bCopy the contents in `templates/_layout.mustache` into a new file. Save it as `index.mustache`.\b If there's a layout by the name of a requested page, Punch will use that layout to render the page.\bThere are many interesting things you can try on homepage; but for now we'll just insert a banner image. Copy a suitable image into `templates` directory. Then, modify the markup of `index.mustache` to show the image:\b<pre>&lt;div role=\"main\"&gt;\n &lt;img src=\"banner.jpg\"&gt;\n {{{intro}}}\n&lt;/div&gt;</pre>Reload the page, when you're done.",
"step7": "So far we used the main layout (`templates/_layout.mustache`) to render all pages of the site. We shall create a separate layout for the homepage to make it more prominent.\bYou can create a new layout by simply copying the `_layout.mustache` into a new file. Save it as `index.mustache`.\bIf there's a layout by the name of a requested page, Punch will use that layout to render the page (eg. `index.mustache` will be picked to render `/index` request).\bThere are many interesting things you can try on homepage; but for now we'll just insert a banner image. Copy a suitable image into `templates` directory. Then, modify the markup of `index.mustache` to show the image:\b<pre>&lt;div role=\"main\"&gt;\n &lt;img src=\"banner.jpg\"&gt;\n {{{intro}}}\n&lt;/div&gt;</pre>Reload the page, when you're done.",
"step8": "Woah! Look you just created a nice little site with Punch :)\bThere are some more great features in Punch that worth exploring. You will figure most of them by yourself, when you deep dive into your project. Remember, [Punch Guide](https://github.com/laktek/punch/wiki) is your friend.\bNow you can remove this guided tutorial block. Go to `templates/_footer.mustache` and remove the tag `{{{first-run}}}`.\bHappy Hacking!",
"step8": "Woah! Look you just created a nice little site with Punch :)\bTo learn further on the concepts we touched upon and discover other great features in Punch, you can peruse [Punch Guide](https://github.com/laktek/punch/wiki).\bTo remove this block, go to `templates/_footer.mustache` and remove the tag `{{{first-run}}}`.\bHappy Hacking!",

@@ -46,3 +46,3 @@ "skip": "To remove this block, go to `templates/_footer.mustache` and remove the tag `{{{first-run}}}`.\bBTW, [Punch Guide](https://github.com/laktek/punch/wiki) might come in handy, when you want to refer how to get certain things done.\bHappy Hacking!"

var help_message = $("<div>").attr("class", "message");
var sticky_links = $("<span>").append("<a href=\"https://github.com/laktek/punch/issues/new\">Got stuck? We can help you</a> | <a href=\"#no_help\">End the hands-on tutorial</a>");
var sticky_links = $("<span>").append("<a href=\"https://github.com/laktek/punch/issues/new\">Got stuck? Seek help</a> | <a href=\"#no_help\">Skip the tutorial</a>");

@@ -49,0 +49,0 @@ $(help_box).append(help_message).append(sticky_links);

@@ -23,3 +23,3 @@ var helper_utils = require("../utils/helper_utils.js");

var last_value = arr.pop();
return arr.join(", ") + " &amp; " + last_value;
return arr.join(", ") + ", &amp; " + last_value;
} else {

@@ -26,0 +26,0 @@ return arr.join("");

@@ -42,3 +42,3 @@ var url = require("url");

sendResponse: function(response, status_code, headers, body){
var encoding = (headers["Content-Type"].split("=")[1] === "utf-8") ? "utf8" : "binary";
var encoding = (headers["Content-Type"].split(";")[0] === "text/html") ? "utf8" : "binary";

@@ -55,3 +55,3 @@ response.statusCode = parseInt(status_code, 10);

response.end(new Buffer(body, encoding));
response.end(body, encoding);
},

@@ -58,0 +58,0 @@

{
"name": "punch"
, "description": "A fun and easy way to build modern websites"
, "keywords": ["static site", "generator", "minfier", "server", "mustache", "json", "markdown"]
, "version": "0.4.5"
, "keywords": ["static site", "framework", "web publishing", "generator", "minfier", "server", "mustache", "json", "markdown"]
, "version": "0.4.6"
, "homepage": "https://github.com/laktek/punch"

@@ -7,0 +7,0 @@ , "author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)"

# Punch
## A Fun and Easy Way to Build Modern Websites
Punch is a framework designed to cater the modern web development needs. It doesn't matter whether you are a novice developer prototyping a hobby project or an seasoned designer creating a complex web architecture, Punch can make your workflow more productive and joyful.
Punch is a modern web publishing framework, which is simple, intuitive and pleasure to use for both designers and developers.

@@ -13,3 +13,3 @@ ### With Punch you can...

* Use Markdown to write formatted content.
* Use CoffeeScript and LESS if those are your taste.
* Use CoffeeScript and LESS if that's your thing.
* Minify and bundle assets before serving.

@@ -22,12 +22,12 @@ * Preview changes on the fly, while you develop.

* Content can be fetched from any data source (eg. SQL databases, key-value stores or REST APIs).
* Don't like Mustache? Switch to a template engine of your choice.
* Write helpers to spice up the templates.
* Use any data source for content (eg. Relational databases, Document stores or REST APIs).
* Don't like Mustache? Switch to a different template engine of your choice.
* Write helpers to add run-time behaviour.
* Add custom content parsers, pre-compilers, minifiers and publishers.
* Add hooks to run after generating a page or site.
* Define your own caching strategy.
* Define your own publishing strategy.
### Getting Started
* You will need to download and install Node.js. http://nodejs.org/#download
* Download and install Node.js. http://nodejs.org/#download

@@ -42,3 +42,3 @@ * To install Punch, run `npm install -g punch`

* Follow the quick hands-on tutorial.
* Follow the steps in hands-on tutorial.

@@ -49,3 +49,3 @@ **Note**: If you experience any issues in installing Punch on Windows, please [read this guide](https://github.com/laktek/punch/wiki/Windows).

For complete documentation on usage & features, please check [Punch Guide](https://github.com/laktek/punch/wiki)
For complete documentation on usage & customizations, check the [Punch Guide](https://github.com/laktek/punch/wiki)

@@ -55,2 +55,1 @@ ### Licence

[MIT LICENSE](https://github.com/laktek/punch/blob/master/LICENSE)

@@ -347,3 +347,3 @@ var default_handler = require("../lib/content_handler.js");

expect(spyCallback).toHaveBeenCalledWith("[Error: Content not found]", null, null, {});
expect(spyCallback).toHaveBeenCalledWith("[Error: Content for path/test not found]", null, null, {});
});

@@ -350,0 +350,0 @@

@@ -15,7 +15,7 @@ var list_helper_obj = require("../../lib/helpers/list_helper");

it("return a formatted string for an array literal", function(){
expect(list_helper.format_list([ "Peter", "John", "Andrew" ])).toEqual("Peter, John &amp; Andrew");
expect(list_helper.format_list([ "Peter", "John", "Andrew" ])).toEqual("Peter, John, &amp; Andrew");
});
it("return a formatted string for an array literal as a string", function(){
expect(list_helper.format_list("Peter,John,Andrew")).toEqual("Peter, John &amp; Andrew");
expect(list_helper.format_list("Peter,John,Andrew")).toEqual("Peter, John, &amp; Andrew");
});

@@ -35,7 +35,7 @@

it("return a formatted string for an array literal", function(){
it("return the first item for an array literal", function(){
expect(list_helper.first(["Peter", "John", "Andrew"])).toEqual("Peter");
});
it("return a formatted string for an array literal as a string", function(){
it("return the first item for an array literal as a string", function(){
expect(list_helper.first("Peter,John,Andrew")).toEqual("Peter");

@@ -56,7 +56,7 @@ });

it("return a formatted string for an array literal", function(){
it("return the last item for an array literal", function(){
expect(list_helper.last(["Peter", "John", "Andrew"])).toEqual("Andrew");
});
it("return a formatted string for an array literal as a string", function(){
it("return the last item for an array literal as a string", function(){
expect(list_helper.last("Peter,John,Andrew")).toEqual("Andrew");

@@ -63,0 +63,0 @@ });

@@ -7,7 +7,7 @@ var text_helper_obj = require("../../lib/helpers/text_helper");

it("change whole text to uppercase", function(){
expect(text_helper.upcase("hello")).toEqual("HELLO");
expect(text_helper.upcase("hello")).toEqual("HELLO");
});
it("return an empty string for null values", function() {
expect(text_helper.upcase(null)).toEqual("");
expect(text_helper.upcase(null)).toEqual("");
});

@@ -20,7 +20,7 @@

it("change whole text to lowercase", function(){
expect(text_helper.downcase("HELlo")).toEqual("hello");
expect(text_helper.downcase("HELlo")).toEqual("hello");
});
it("return an empty string for null values", function() {
expect(text_helper.downcase(null)).toEqual("");
expect(text_helper.downcase(null)).toEqual("");
});

@@ -33,11 +33,11 @@

it("make the first letter upper case", function(){
expect(text_helper.capitalize("hello")).toEqual("Hello");
expect(text_helper.capitalize("hello")).toEqual("Hello");
});
it("make other letters lower case", function(){
expect(text_helper.capitalize("HeLLo")).toEqual("Hello");
expect(text_helper.capitalize("HeLLo")).toEqual("Hello");
});
it("return an empty string for null values", function() {
expect(text_helper.capitalize(null)).toEqual("");
expect(text_helper.capitalize(null)).toEqual("");
});

@@ -50,7 +50,7 @@

it("capitalize each word", function(){
expect(text_helper.titleize("hello my DEAR People")).toEqual("Hello My Dear People");
expect(text_helper.titleize("hello my DEAR People")).toEqual("Hello My Dear People");
});
it("return an empty string for null values", function() {
expect(text_helper.titleize(null)).toEqual("");
expect(text_helper.titleize(null)).toEqual("");
});

@@ -63,7 +63,7 @@

it("removes whitespace in the beginning and end of the text", function(){
expect(text_helper.trim(" hello my dear people ")).toEqual("hello my dear people");
expect(text_helper.trim(" hello my dear people ")).toEqual("hello my dear people");
});
it("return an empty string for null values", function() {
expect(text_helper.trim(null)).toEqual("");
expect(text_helper.trim(null)).toEqual("");
});

@@ -76,15 +76,14 @@

it("removes dashes and undersocres", function(){
expect(text_helper.humanize("hello-my_dear_people")).toEqual("Hello my dear people");
it("removes dashes and underscores", function(){
expect(text_helper.humanize("hello-my_dear_people")).toEqual("Hello my dear people");
});
it("capitalize the sentence", function(){
expect(text_helper.humanize("hello-my-dear-people")).toEqual("Hello my dear people");
expect(text_helper.humanize("hello-my-dear-people")).toEqual("Hello my dear people");
});
it("return an empty string for null values", function() {
expect(text_helper.humanize(null)).toEqual("");
expect(text_helper.humanize(null)).toEqual("");
});
});

@@ -95,10 +94,9 @@

it("return the dasherized output", function() {
expect(text_helper.dasherize("hello my dear people ")).toEqual("hello-my-dear-people");
expect(text_helper.dasherize("hello my dear people ")).toEqual("hello-my-dear-people");
});
it("return an empty string for null values", function() {
expect(text_helper.dasherize(null)).toEqual("");
expect(text_helper.dasherize(null)).toEqual("");
});
});

@@ -109,7 +107,7 @@

it("return the underscored output", function() {
expect(text_helper.underscored("hello my dear people ")).toEqual("hello_my_dear_people");
expect(text_helper.underscored("hello my dear people ")).toEqual("hello_my_dear_people");
});
it("return an empty string for null values", function() {
expect(text_helper.underscored(null)).toEqual("");
expect(text_helper.underscored(null)).toEqual("");
});

@@ -122,5 +120,5 @@

it("throw an error if invalid parameters were passed", function() {
expect(function() { text_helper.underscored("hello my dear people ", function(){ } ) }).toThrow();
expect(function() { text_helper.underscored("hello my dear people ", function(){ } ) }).toThrow();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc