The Poetry Book =============== What is The Poetry Book? [What?] -------------------------------- *The Poetry Book* is a fast and easy system for quickly making your own book of poems. You can also use it as the basis for building highly interactive websites, apps or game interfaces. If you want to create your own book of poems that looks like this one, [get the source code](https://github.com/kittykatattack/thepoetrybook) and modify it as much as you like. ![A Painting by William Blake](images/williamBlake.png) All the content for the entire book exists as a single [markdown document](http://daringfireball.net/projects/markdown/basics). Markdown documents are quick and easy to read and write, and don't require any technical skill to create. The Poetry Book uses the markdown document to figure out how the website should be organized. This is all done automatically using JavaScript - you don't have to worry about it. Just drop your markdown file into the Poetry Book's home folder, and the navigation bar and content pages will be automatically created. Fill the content pages with anything you like, as much as you like. Completely change the layout and design with CSS. Drop the Poetry Book project folder into any webserver, and you're done. There's nothing to configure or install, no complex dependant technologies, and no command-line-anything. It's a new way to think about websites and interactive content using the most basic technologies available. If you like, you can completely customize the css code to create entirely new and original layouts and designs based on this system. It will work on any platform, anywhere. There is only one content file, so it's extremely easy to manage and displays pages instantly. If you keep things simple, this might be all you need to build a small to medium-sized personal website, portfolio gallery or focused app. Or, just make a poetry book. ### What do you need to know? ### You need to know [how to write a markdown document](http://www.markdowntutorial.com). That's all. If you want to post your Poetry Book on the internet, you need some kind of website hosting service. You could [use Google Drive](http://chronicle.com/blogs/profhacker/host-a-website-on-google-drive/46737). Or, you could use [Dropbox, in the normal way](http://www.dropboxwiki.com/tips-and-tricks/host-websites-with-dropbox), or [Dropbox, in the fancy way](http://www.makeuseof.com/tag/how-to-host-a-dropbox-website/). Or, you could use your own website hosting company and with your own domain name - there are lots of options. If you want to change the graphic-design style and behaviour of your Poetry Book, you should know some basic HTML and CSS. If you don't know what those things are, you should learn them first. (There are many resources on the internet that will help you do this. Doing a web search for "HTML and CSS tutorial" is a good place to start. The first chapter of [this book](http://www.apress.com/programming/javascript/9781430247166) is also really good). You need to know HTML and CSS basics so that you can start customizing things like the fonts, colors and layout. For HTML and CSS experts, go wild! This project was intended as the simplest, bare-bones example of a new vision of what highly interactive websites and apps could be. ### How to make your own book ### First, make sure you have a local web server runnning. If you're using OSX, [Here's how to do that](http://osxdaily.com/2012/09/02/start-apache-web-server-mac-os-x/). On other platforms, [try XAMMP](http://www.apachefriends.org/en/xampp.html). If you're not afraid of the command line, you could [try a simple Python webserver](http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python). Or just, to make things really easy, download [Brackets](http://www.brackets.io/) and the latest version of [Chrome](https://www.google.com/intl/en/chrome/browser/) and then launch any project's index.html file by clicking Bracket's lightning bolt icon. Brackets will create a local web server for you automatically. Next, [Download the source files](https://github.com/kittykatattack/thepoetrybook/releases), put them in your local web server, and view the index.html file in a web browser. You can then start writing your own poetry book. Use a plain text editor to write a markdown document. Or, you can use a free online markdown editor, [like this one](http://dillinger.io). (If you want to get fancy, download the latest version of [Brackets](http://brackets.io) and install the markdown extension from the extension manager). The Poetry Book uses an improved style of markdown called GFM, which [adds some extra useful features](https://help.github.com/articles/github-flavored-markdown). (Here's a good [markdown cheat-sheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) you can use while you're learning to write markdown documents.) What does a markdown document look like? Here's an example of a markdown document that will create a book with two pages of poems. ![](images/example1Markdown.png) Save this document with the name "book.markdown" in the main Poetry Book project folder. (That's the same folder that includes a file called index.html. If there's already an existing document called book.markdown in that same folder (there will be, this one!), replace it with your new one.) After you've done that, open the index.html file in a web browser, and you'll see this: ![](images/example1.png) The Poetry Book will organize the poems in the same order that they appear in your markdown document. (You'll find this example markdown document as "example1.markdown" in the "examples" folder.) If you're the kind of person who really likes to organize things, you can sort your poems into categories. Maybe you've got two kinds of poems: *fun* poems and *boring* poems. You can add categories to your poem titles, and the Poetry Book will sort your poems into those categories. Here's an example of a book with three poems: one boring poem and two fun poems. ![](images/example2Markdown.png) Here's what this next example poetry book will look like: ![](images/example2.png) You can see that in this example the poem titles include extra words that are surrounded by square brackets. Those words are the category that you want to organize your poem into. That means that if you wanted to create a new category called *Really crazy ideas* you would do it like this: `Drawing on puddles with water-proof markers [Really crazy ideas]` `-----------------------------------------------------------------------` You can use any category names you like. All poems in the same categories will be grouped together in the navigation bar. That is all you need to do. You've got a poetry book! ### Category ordering ### The categories will be ordered alphabetically. To change that, you'll need to change the JavaScript code in the tree.js file. If that's something you're confident doing, go for it! But, if you don't fight it, you'll discover that's it's really nice just to have the system organize your poems for you automatically like this. It's just one less decision you need to make, and you can make it work for you. Spend the extra time you saved to write some poetry. Poems will be organized under categories based on the order in which they appear in your markdown document. That means the poems near the top will appear before the poems below them. If you don't include a category, the poem will appear at the very top of the navigation bar, above the all the other categorized poems. A useful feature is that the first poem in the markdown document will also be the first one to be displayed when the book loads. That means if you want readers to see the newest content first, just add it as the first poem in your markdown document. ### Adding images ### Use this bit of simple markdown to add an image: `![A description of the image](imageFileName.png)` ### Linking poems ### If you want to link a poem to another poem in the book you can [do it like this](#songsofthepixies): `[do it like this](#songsofthepixies)` ### Sub-page navigation headings for websites ### If you want to use The Poetry Book to make a website, you can think of each poem as a page of content. You might have pages with a lot of information that you want to break up with sub-headings. You can add a sub-heading in a page like this: `### This is a sub-heading inside a page ###` The Poetry Book will automatically create a sub-page navigation bar for you based on these headings. To see it in this example, move your mouse over the light-gray vertical bar to the left of this page. A navigation bar will open showing you all the headings inside this page. You can jump to a new heading by clicking one of the links. If you don't want this sub-page navigation to be displayed, add this bit of code to the end of your CSS file: .section1 nav {display: none;} ### Making a website ### You can use The Poetry Book to make a website. Just use real information, instead of poems. And, if you know enough HTML CSS and JavaScript, you can completely customize it to look and behave however you want it to. In fact, The Poetry Book was written specifically to make it easy for you to do that. If you don't know HTML, CSS and basic JavaScript - don't read further! But, if you do, here are some of the things you should know about the source code: All the HTML code is generated automatically by the poetryBook.min.js file based on the structure of your markdown document. That means you won't be able to see the HTML page structure by looking at the index.html file. Instead, you'll need to open the *developer tools* in whatever browser you're using, and use it to inspect the generated HTML elements. (If you're using the [Chrome browser](https://www.google.com/intl/en/chrome/browser/), you can [do it like this](https://developers.google.com/chrome-developer-tools/docs/elements).) Using those tools, try it now and a look at the HTML structure of this example Poetry Book (yes, this very one you're reading!) You'll notice that every heading from the markdown document has a matching HTML heading tag: `

,

,

` etc. And each of those headings, and the content they contain, are nested inside a matching `
` tag. Those `
` tags all have class names: section0, section1, section2, etc. section0 matches the `

` tag, section1 matches the `

` tags, and section2 matches the `

` tags. ![](images/htmlExample1.png) Here's what one of the poems looks like: ![](images/htmlExample3.png) You can also see that the id names for each section are the same as the document headings, except in lower case without spaces or punctuation. You'll also notice that the entire book is wrapped inside a single `
` tag with the class name section0. That's based on the main heading that you gave your markdown document. #### Selection states You'll also notice that the sections have *state* attributes. These are set as either "selected" or "unselected". Those states are set for you automatically by the poetrybook.min.js file, based on currently active links. This is really useful, because it means that you can use those *state* attributes to selectivly show or hide content. For example, here's the css you could use to make only selected content in section1 visible: section .section1[state=selected] { opacity: 1; z-index: 1; } section .section1[state=unselected] { z-index: 0; opacity: 0; } This is a really powerful feature. It's the key to easily making highly dynamic, complex websites with nothing more than a few simple lines of CSS. Take a look at the poetryBook.css file to see how it's been implemented in this example. #### Navigation bars Each `
` tag is also immediately followed by a `