From 8c777c53019cbe494b6e77e07e997a080790da0a Mon Sep 17 00:00:00 2001 From: Vit Brunner Date: Sat, 15 Jun 2013 06:32:31 +0100 Subject: [PATCH] Switch to tabs for indentation I got drunk, read the coffeescript style guide, and decided to use spaces. Spaces for indentation is still as bad an idea as it ever were, and this is not a coffeescript project - it's multilingual, hence using coffeescript conventions is pointless. --- README.md | 4 +- docpad.coffee | 6 +- package.json | 26 ++-- source/documents/index.html.jade | 23 ++-- .../documents/scripts/controllers.js.coffee | 11 +- .../documents/scripts/reader/json.js.coffee | 24 ++-- .../scripts/reader/markdown.js.coffee | 72 +++++----- .../scripts/tests/reader/_abstract.js.coffee | 8 +- .../scripts/tests/reader/json.js.coffee | 52 +++---- .../scripts/tests/reader/markdown.js.coffee | 128 +++++++++--------- source/documents/styles/style.css.less | 2 +- source/documents/tests.html.jade | 24 ++-- 12 files changed, 192 insertions(+), 188 deletions(-) diff --git a/README.md b/README.md index 904be1a..19f6f7e 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ bibles, etc. Install nodejs and javascript dependencies, on Debian/Ubuntu, it goes more or less like this: - sudo apt-get install nodejs - npm install + sudo apt-get install nodejs + npm install ### Tests diff --git a/docpad.coffee b/docpad.coffee index 06ca1ac..7c9c9df 100644 --- a/docpad.coffee +++ b/docpad.coffee @@ -1,5 +1,5 @@ module.exports = { - outPath: "build" - srcPath: "source" - prompts: false + outPath: "build" + srcPath: "source" + prompts: false } diff --git a/package.json b/package.json index 61fe451..bd93c05 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "name": "side-by-side", - "version": "0.0.1", - "author": "Vit Brunner", - "description": "Visual comparison of different translations of itemized texts; e.g. poems, bibles, etc.", - "devDependencies": { - "docpad": "6.x", - "docpad-plugin-coffeescript": "2.x", - "docpad-plugin-jade": "2.x", - "docpad-plugin-less": "2.x", - "qunitjs": "1.11.x", - "phantomjs": "1.9.x" - }, - "license": "MIT" + "name": "side-by-side", + "version": "0.0.1", + "author": "Vit Brunner", + "description": "Visual comparison of different translations of itemized texts; e.g. poems, bibles, etc.", + "devDependencies": { + "docpad": "6.x", + "docpad-plugin-coffeescript": "2.x", + "docpad-plugin-jade": "2.x", + "docpad-plugin-less": "2.x", + "qunitjs": "1.11.x", + "phantomjs": "1.9.x" + }, + "license": "MIT" } diff --git a/source/documents/index.html.jade b/source/documents/index.html.jade index 98a6212..63a0c9f 100644 --- a/source/documents/index.html.jade +++ b/source/documents/index.html.jade @@ -1,14 +1,15 @@ doctype 5 html(ng-app="sideBySide") - head - title Side By Side viewer - meta(charset="utf-8") - link(rel="stylesheet", type="text/css", href="//fonts.googleapis.com/css?family=Titillium+Web:400,700,400italic,700italic") - link(rel="stylesheet", type="text/css", href="styles/style.css") - include _scripts.html.jade + head + title Side By Side viewer + meta(charset="utf-8") + link(rel="stylesheet", type="text/css", href="//fonts.googleapis.com/css?family=Titillium+Web:400,700,400italic,700italic") + link(rel="stylesheet", type="text/css", href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css") + link(rel="stylesheet", type="text/css", href="styles/style.css") + include _scripts.html.jade - body - div(class="container", ng-controller="comparisonController") - div(class="verse", ng-repeat="verse in verses") - div(class="section", ng-bind="verse.section") - div(class="version", ng-repeat= "version in verse.versions") {{ version }} + body + div(class="container", ng-controller="comparisonController") + div(class="verse", ng-repeat="verse in verses") + div(class="section", ng-bind="verse.section") + div(class="version", ng-repeat= "version in verse.versions") {{ version }} diff --git a/source/documents/scripts/controllers.js.coffee b/source/documents/scripts/controllers.js.coffee index 06d2f34..8f7d05e 100644 --- a/source/documents/scripts/controllers.js.coffee +++ b/source/documents/scripts/controllers.js.coffee @@ -1,6 +1,7 @@ angular.module("sideBySide.controllers", []) -.controller "comparisonController", ($scope) -> - $scope.verses = [ - { section: 'first', versions: [ 'a', '1' ] } - { section: 'second', versions: [ 'b', '2' ] } - ] +.controller "comparisonController", ['$scope', ($scope) -> + $scope.verses = [ + { section: 'first', versions: [ 'a', '1' ] } + { section: 'second', versions: [ 'b', '2' ] } + ] +] diff --git a/source/documents/scripts/reader/json.js.coffee b/source/documents/scripts/reader/json.js.coffee index 358b0b6..5d795c6 100644 --- a/source/documents/scripts/reader/json.js.coffee +++ b/source/documents/scripts/reader/json.js.coffee @@ -1,16 +1,16 @@ angular.module("sideBySide").factory("jsonReader", () -> - return (source) -> - parsed = eval('(' + source + ')') + return (source) -> + parsed = eval('(' + source + ')') - new_content = [] - for verse in parsed.content - if typeof(verse) == "string" - new_content.push({ section: "", text: verse }) - else - if "section" not of verse - verse.section = "" - new_content.push(verse) + new_content = [] + for verse in parsed.content + if typeof(verse) == "string" + new_content.push({ section: "", text: verse }) + else + if "section" not of verse + verse.section = "" + new_content.push(verse) - parsed.content = new_content - return parsed + parsed.content = new_content + return parsed ) diff --git a/source/documents/scripts/reader/markdown.js.coffee b/source/documents/scripts/reader/markdown.js.coffee index 4f2a88e..581b8de 100644 --- a/source/documents/scripts/reader/markdown.js.coffee +++ b/source/documents/scripts/reader/markdown.js.coffee @@ -1,45 +1,45 @@ angular.module("sideBySide").factory("markdownReader", () -> - return (source) -> - read_meta = (block, inlineLexer) -> - meta = {} - lexed = inlineLexer.output(block.text) - for line in lexed.split("\n") - match = /([^:]*):(.*)/.exec(line) - meta[match[1].trim()] = match[2].trim() - return meta + return (source) -> + read_meta = (block, inlineLexer) -> + meta = {} + lexed = inlineLexer.output(block.text) + for line in lexed.split("\n") + match = /([^:]*):(.*)/.exec(line) + meta[match[1].trim()] = match[2].trim() + return meta - read_content = (lexed) -> - get_section = (lexed) -> - items = [] - while lexed.length > 0 - if lexed[0]["type"] == "heading" - break - items.push(lexed.shift()) - return items + read_content = (lexed) -> + get_section = (lexed) -> + items = [] + while lexed.length > 0 + if lexed[0]["type"] == "heading" + break + items.push(lexed.shift()) + return items - content = [] + content = [] - while lexed.length > 0 - if lexed[0]["type"] == "heading" - heading = lexed.shift().text - else - heading = '' + while lexed.length > 0 + if lexed[0]["type"] == "heading" + heading = lexed.shift().text + else + heading = '' - text = get_section(lexed) - text.links = lexed.links - content.push({ - section: heading - text: marked.parser(text) - }) + text = get_section(lexed) + text.links = lexed.links + content.push({ + section: heading + text: marked.parser(text) + }) - return content + return content - lexed = marked.lexer(source) - meta = lexed.shift() - inlineLexer = new marked.InlineLexer(lexed.links) + lexed = marked.lexer(source) + meta = lexed.shift() + inlineLexer = new marked.InlineLexer(lexed.links) - return { - meta: read_meta(meta, inlineLexer) - content: read_content(lexed) - } + return { + meta: read_meta(meta, inlineLexer) + content: read_content(lexed) + } ) diff --git a/source/documents/scripts/tests/reader/_abstract.js.coffee b/source/documents/scripts/tests/reader/_abstract.js.coffee index 365b629..e4b8762 100644 --- a/source/documents/scripts/tests/reader/_abstract.js.coffee +++ b/source/documents/scripts/tests/reader/_abstract.js.coffee @@ -1,6 +1,6 @@ this.testReader = (name, testCases) -> - injector = angular.injector(["ng", "sideBySide"]) - reader = injector.get(name) + injector = angular.injector(["ng", "sideBySide"]) + reader = injector.get(name) - for testCase in testCases - deepEqual(reader(testCase.tested), testCase.expected) + for testCase in testCases + deepEqual(reader(testCase.tested), testCase.expected) diff --git a/source/documents/scripts/tests/reader/json.js.coffee b/source/documents/scripts/tests/reader/json.js.coffee index 31f8d60..eb79a54 100644 --- a/source/documents/scripts/tests/reader/json.js.coffee +++ b/source/documents/scripts/tests/reader/json.js.coffee @@ -1,29 +1,29 @@ test("jsonReader", () -> - testCases = [{ - tested: """ - { - meta: { - Title: "Test leading text" - }, - content: [ - "

This is leading text.

", - { section: "I", text: "

First section.

" }, - { section: "II", text: "

Second section.

" }, - { text: "

Another section.

" }, - ], - }""" - expected: { - meta: { - Title: "Test leading text" - } - content: [ - { section: "", text: "

This is leading text.

" } - { section: "I", text: "

First section.

" } - { section: "II", text: "

Second section.

" } - { section: "", text: "

Another section.

" } - ] - } - }] + testCases = [{ + tested: """ + { + meta: { + Title: "Test leading text" + }, + content: [ + "

This is leading text.

", + { section: "I", text: "

First section.

" }, + { section: "II", text: "

Second section.

" }, + { text: "

Another section.

" }, + ], + }""" + expected: { + meta: { + Title: "Test leading text" + } + content: [ + { section: "", text: "

This is leading text.

" } + { section: "I", text: "

First section.

" } + { section: "II", text: "

Second section.

" } + { section: "", text: "

Another section.

" } + ] + } + }] - testReader("jsonReader", testCases) + testReader("jsonReader", testCases) ) diff --git a/source/documents/scripts/tests/reader/markdown.js.coffee b/source/documents/scripts/tests/reader/markdown.js.coffee index ee4d36a..e0b2cd3 100644 --- a/source/documents/scripts/tests/reader/markdown.js.coffee +++ b/source/documents/scripts/tests/reader/markdown.js.coffee @@ -1,74 +1,76 @@ test("markdownReader", () -> - testCases = [{ - tested: """ - Title: Universal Declaration of Human Rights - Author: John Peters Humphrey - Date: 1948 - Source: http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights + testCases = [{ + tested: """ + Title: Universal Declaration of Human Rights + Author: John Peters Humphrey + Date: 1948 + Source: http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights - ## 1 - All human beings are born *free* and equal in dignity and rights... + ## 1 + All human beings are born *free* and equal in dignity and rights... - ## 2 - Everyone is entitled to all the rights and freedoms... + ## 2 + Everyone is entitled to all the rights and freedoms... - Furthermore, no distinction shall be made on the basis of... + Furthermore, no distinction shall be made on the basis of... - ## 11.1 - Everyone charged with a penal offence has the right to be presumed... + ## 11.1 + Everyone charged with a penal offence has the right to be presumed... - ## 11.2 - No one shall be held guilty of any penal offence... + ## 11.2 + No one shall be held guilty of any penal offence... - ## 13 - Everyone is entitled to: + ## 13 + Everyone is entitled to: - - sex - - drugs - - rock & roll - """ - expected: { - meta: { - Title: "Universal Declaration of Human Rights" - Author: "John Peters Humphrey" - Date: "1948" - Source: 'http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights' - } - content: [ - { section: "1", text: "

All human beings are born free and equal in dignity and rights...

\n" } - { section: "2", text: """

Everyone is entitled to all the rights and freedoms...

-

Furthermore, no distinction shall be made on the basis of...

\n""" } - { section: "11.1", text: "

Everyone charged with a penal offence has the right to be presumed...

\n" } - { section: "11.2", text: "

No one shall be held guilty of any penal offence...

\n" } - { section: "13", text: """

Everyone is entitled to:

- \n""" } - ] - } - }, { - tested: """ - Title: Test leading text + - sex + - drugs + - rock & roll + """ + expected: { + meta: { + Title: "Universal Declaration of Human Rights" + Author: "John Peters Humphrey" + Date: "1948" + Source: 'http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights' + } + content: [ + { section: "1", text: "

All human beings are born free and equal in dignity and rights...

\n" } + { section: "2", text: """ +

Everyone is entitled to all the rights and freedoms...

+

Furthermore, no distinction shall be made on the basis of...

\n""" } + { section: "11.1", text: "

Everyone charged with a penal offence has the right to be presumed...

\n" } + { section: "11.2", text: "

No one shall be held guilty of any penal offence...

\n" } + { section: "13", text: """ +

Everyone is entitled to:

+ \n""" } + ] + } + }, { + tested: """ + Title: Test leading text - **This** is leading text. - # I - First section. - # II - Second section. - """ - expected: { - meta: { - Title: "Test leading text" - } - content: [ - { section: "", text: "

This is leading text.

\n" } - { section: "I", text: "

First section.

\n" } - { section: "II", text: "

Second section.

\n" } - ] - } - }] + **This** is leading text. + # I + First section. + # II + Second section. + """ + expected: { + meta: { + Title: "Test leading text" + } + content: [ + { section: "", text: "

This is leading text.

\n" } + { section: "I", text: "

First section.

\n" } + { section: "II", text: "

Second section.

\n" } + ] + } + }] - testReader("markdownReader", testCases) + testReader("markdownReader", testCases) ) diff --git a/source/documents/styles/style.css.less b/source/documents/styles/style.css.less index 1c84a78..c515471 100644 --- a/source/documents/styles/style.css.less +++ b/source/documents/styles/style.css.less @@ -1,3 +1,3 @@ body { - font-family: "Titillium Web", sans-serif; + font-family: "Titillium Web", sans-serif; } diff --git a/source/documents/tests.html.jade b/source/documents/tests.html.jade index cd2e585..f52b9b7 100644 --- a/source/documents/tests.html.jade +++ b/source/documents/tests.html.jade @@ -1,17 +1,17 @@ doctype 5 html - head - title Side By Side test suite - meta(charset="utf-8") + head + title Side By Side test suite + meta(charset="utf-8") - include _scripts.html.jade + include _scripts.html.jade - // test scripts - link(rel="stylesheet", type="text/css", href="//cdnjs.cloudflare.com/ajax/libs/qunit/1.11.0/qunit.css") - script(src="//cdnjs.cloudflare.com/ajax/libs/qunit/1.11.0/qunit.js") - script(src="scripts/tests/reader/_abstract.js") - script(src="scripts/tests/reader/markdown.js") - script(src="scripts/tests/reader/json.js") + // test scripts + link(rel="stylesheet", type="text/css", href="//cdnjs.cloudflare.com/ajax/libs/qunit/1.11.0/qunit.css") + script(src="//cdnjs.cloudflare.com/ajax/libs/qunit/1.11.0/qunit.js") + script(src="scripts/tests/reader/_abstract.js") + script(src="scripts/tests/reader/markdown.js") + script(src="scripts/tests/reader/json.js") - body - div(id="qunit") + body + div(id="qunit")