Steve Losh avatar Steve Losh committed 0f87233

Moar.

Comments (0)

Files changed (7)

bookmarkdown/bookmarkdown

 #!/usr/bin/env python
 
 # {{{
-import os, shutil
+import os, shutil, sys
 import baker
 import markdown
 import config
 from pyquery import PyQuery as pq
 from jinja2 import Environment, PackageLoader
 
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+
 env = Environment(loader=PackageLoader('bookmarkdown', 'templates'))
 join = os.path.join
 
         target = join(acc, next)
         os.path.exists(target) or os.mkdir(target)
         return target
-    reduce(_md, os.path.split(path), '')
+    reduce(_md, path.split(os.path.sep), '')
 
 def render(template, **context):
     full_context = {}
     with open(source, 'r') as f:
         content = markdown.markdown(f.read())
 
-    name = pq(content)('h1').text()
+    try:
+        name = pq(content)('h1').text()
+    except ValueError:
+        name = "Untitled Chapter"
+
     out = render(template, content=content, name=name, **context)
     target = join('build', 'html', '%s.html' % filename)
 
 
     _copy_static()
 
-    _build_html_file('acknowledgements', 'single')
     _build_html_file('license', 'single')
     _build_html_file('preface', 'single')
 

bookmarkdown/static/styles/style.less

             padding: 0;
         }
     }
+    ul {
+        list-style-type: circle;
+        
+        li {
+            margin-left: 36px;
+        }
+    }
 }
 
 body.splash {

bookmarkdown/templates/single.html

 {% extends "base.html" %}
 
 {% block content %}
-    {{ content }}
+    <div class="sixteen columns">
+        {{ content }}
 
-    <div class="prevnext">
-        <a class="prev" href="">&laquo; Previous</a>
-        <a class="next" href="">Next &raquo;</a>
+        <div class="prevnext">
+            <a class="prev" href="">&laquo; Previous</a>
+            <a class="next" href="">Next &raquo;</a>
+        </div>
     </div>
 {% endblock %}

bookmarkdown/templates/splash.html

             <h2>Table of Contents</h2>
 
             <ol>
-                <li><a href="/acknowledgements.html">Acknowledgements</a></li>
                 <li><a href="/preface.html">Preface</a></li>
                 {% for chapter in chapters %}
                     <li><a href="/{{ chapter['filename'] }}.html">{{ chapter['name'] }}</a></li>
 baker
 jinja2
-python-markdown
+Markdown
+pyquery

sample/acknowledgements.markdown

-I has some content!
-
-*ack*

sample/preface.markdown

-*preface*
+Preface
+=======
 
-derp.
+Programmers shape ideas into text.
+
+That text gets turned into numbers and those numbers bump into other numbers
+and *make things happen*.
+
+To get our ideas out of our heads and the chunks of text we call "programs" we
+use text editors.  Full-time programmers will easily spend thousands of hours
+of their lives interacting with their text editor doing many things:
+
+* Getting raw text from brains into computers.
+* Correcting mistakes in that text.
+* Restructuring the text to formulate a problem in a different way.
+* Recording how and why something was done a particular way.
+* Communicating with other programmers about all of these things.
+
+Vim is incredibly powerful out of the box, but it doesn't truly shine until you
+take some time to customize it for your particular work, habits, and fingers.
+This book will introduce you to Vimscript, the main programming language used to
+customize Vim.  You'll be able to mold Vim around your own personal text editing
+and make the rest of your time in Vim more efficient.
+
+Along the way I'll also mention things that aren't strictly about Vimscript, but
+are more about learning and being more efficient in general.  Learning Vimscript
+isn't going to help you much if you wind up fiddling with your editor all day
+instead of working, so you must strike a balance.
+
+Each chapter of the book focuses on a single topic.  They're short but packed
+with information, so don't just skim them.  If you really want to learn the most
+you can from this book, you need to *type in* all of the commands.
+
+You may already be an experienced programmer who's used to reading code and
+understanding it straight away.  If so: it doesn't matter.  Learning Vim and
+Vimscript is a different experience from learning a normal programming language.
+
+**Type.  In.  The.  Exercises.**
+
+First, Vimscript is old and has a lot of dusty corners and twisty hallways.  One
+configuration option can change how the entire language works.  By typing
+*every* command in *every* exercise you'll discover problems with your Vim build
+or configuration on the simpler commands, which will be easier to diagnose and
+fix.
+
+Second, Vimscript *is* Vim.  To save a file in Vim, you type `:write` (or `:w`
+for short) and press return.  To save a file in a Vimscript, you use `write`.
+Mastering a text editor means developing muscle memory, which you simply can't
+get from just reading.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.