Permalink
Browse files

Use Twitter Bootstrap for HTML template (plus minor assorted improvem…

…ents)
  • Loading branch information...
1 parent dd823a1 commit 0fec04d59a04208536a3e8b2c84bc6b1d2bcc4bf @xolox committed Jun 23, 2013
Showing with 47 additions and 36 deletions.
  1. +10 −2 autoload/xolox/notes/html.vim
  2. +5 −1 autoload/xolox/notes/markdown.vim
  3. +8 −5 autoload/xolox/notes/parser.vim
  4. +24 −28 misc/notes/template.html
View
12 autoload/xolox/notes/html.vim
@@ -15,10 +15,18 @@ function! xolox#notes#html#view() " {{{1
" [markdown]: http://en.wikipedia.org/wiki/Markdown
try
" Convert the note's text to HTML using Markdown.
- let note_title = getline(1)
+ let note_title = xolox#notes#current_title()
+ let filename = xolox#notes#title_to_fname(note_title)
let note_text = join(getline(1, '$'), "\n")
let raw_html = xolox#notes#html#convert_note(note_text)
- let styled_html = xolox#notes#html#apply_template({'title': note_title, 'content': raw_html, 'encoding': &encoding})
+ let styled_html = xolox#notes#html#apply_template({
+ \ 'encoding': &encoding,
+ \ 'title': note_title,
+ \ 'content': raw_html,
+ \ 'version': g:xolox#notes#version,
+ \ 'date': strftime('%A %B %d, %Y at %H:%M'),
+ \ 'filename': fnamemodify(filename, ':~'),
+ \ })
let filename = s:create_temporary_file(note_title)
if writefile(split(styled_html, "\n"), filename) != 0
throw printf("Failed to write HTML file! (%s)", filename)
View
6 autoload/xolox/notes/markdown.vim
@@ -64,7 +64,11 @@ function! xolox#notes#markdown#convert_block(block) " {{{1
endif
return join(items, "\n\n")
elseif a:block.type == 'paragraph'
- return s:make_urls_explicit(a:block.text)
+ let text = s:make_urls_explicit(a:block.text)
+ if len(text) <= 50 && text =~ ':$'
+ let text = printf('**%s**', text)
+ endif
+ return text
else
let msg = "Encountered unsupported block: %s!"
throw printf(msg, string(a:block))
View
13 autoload/xolox/notes/parser.vim
@@ -3,6 +3,8 @@
" Last Change: June 23, 2013
" URL: http://peterodding.com/code/vim/notes/
+" TODO Support for block quotes!
+
function! xolox#notes#parser#parse_note(text) " {{{1
" Parser for the note taking syntax used by vim-notes.
let starttime = xolox#misc#timer#start()
@@ -217,18 +219,19 @@ function! s:parse_list(context) " {{{1
endif
endif
let line = s:match_line(a:context)
+ call xolox#misc#msg#debug("notes.vim %s: Matched line in list item: %s", g:xolox#notes#version, string(line))
call add(lines, line)
if line[-1:] != "\n"
" XXX When match_line() returns a line that doesn't end in a newline
" character, it means either we hit the end of the input or the current
" line continues in a code block (which is not ours to parse :-).
+ call xolox#misc#msg#debug("notes.vim %s: List terminated by end of input / start of code block ..", g:xolox#notes#version)
+ break
+ elseif line =~ '^\_s*$'
+ " For now an empty line terminates the list item.
+ " TODO Add support for list items with multiple paragraphs of text.
break
endif
- " FIXME What happens when we find an empty line? Here's what:
- " 1. If the line after that starts without indentation, we found
- " the end of the list.
- " 2. If the line starts with indentation, we are dealing with a
- " list item that contains multiple paragraphs...
endwhile
call s:save_item(items, lines, indent)
return {'type': 'list', 'ordered': (list_type == 'ordered-list'), 'items': items}
View
52 misc/notes/template.html
@@ -3,42 +3,38 @@
<head>
<meta charset="{{ encoding }}">
<title>{{ title }}</title>
+ <!-- jQuery from the Google CDN. -->
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
+ <!-- Bootstrap CSS & JS from the Bootstrap CDN. -->
+ <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" >
+ <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<style type="text/css">
body {
- margin: 1em auto 10em auto;
+ margin: 2.5em auto 10em auto;
width: 50em;
max-width: 90%;
- line-height: 1.5em;
}
- h1 {
- text-align: center;
- }
- h2, h3 {
- border-bottom: 1px solid #eee;
- }
- h1, h2, h3, h4, h5, h6 {
- font-family: sans-serif;
- letter-spacing: 1px;
- color: navy;
- }
- h2, h3, h4, h5, h6 {
- margin: 2em 0 0 0;
- }
- hr {
- height: 0;
- border: none;
- margin: 5em 0;
- }
- hr:before {
- display: block;
- text-align: center;
- letter-spacing: 10px;
- content: "* * *";
- color: #ccc;
+ h2 { margin-top: 1.5em; }
+ h3 { margin-top: 1.25em; }
+ h4 { margin-top: 1em; }
+ h5 { margin-top: 0.75em; }
+ h6 { margin-top: 0.5em; }
+ hr { margin: 5em 0; }
+ #footer {
+ margin-top: 5em;
+ opacity: 0.5;
+ line-height: 2.5em;
}
+ #footer:hover { opacity: 1.0; }
</style>
</head>
<body>
- {{ content }}
+ <div id="content">
+ {{ content }}
+ </div>
+ <div id="footer">
+ Exported by <a href="http://peterodding.com/code/vim/notes" class="btn">vim-notes {{ version }}</a>
+ on {{ date }} based on the note <code>{{ filename }}</code>.
+ </div>
</body>
</html>

0 comments on commit 0fec04d

Please sign in to comment.