mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-10 12:37:06 +08:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
outPath: "build"
|
||||
srcPath: "source"
|
||||
prompts: false
|
||||
outPath: "build"
|
||||
srcPath: "source"
|
||||
prompts: false
|
||||
}
|
||||
|
||||
+13
-13
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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' ] }
|
||||
]
|
||||
]
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
test("jsonReader", () ->
|
||||
testCases = [{
|
||||
tested: """
|
||||
{
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
},
|
||||
content: [
|
||||
"<p><strong>This</strong> is leading text.</p>",
|
||||
{ section: "I", text: "<p>First section.</p>" },
|
||||
{ section: "II", text: "<p>Second section.</p>" },
|
||||
{ text: "<p>Another section.</p>" },
|
||||
],
|
||||
}"""
|
||||
expected: {
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
}
|
||||
content: [
|
||||
{ section: "", text: "<p><strong>This</strong> is leading text.</p>" }
|
||||
{ section: "I", text: "<p>First section.</p>" }
|
||||
{ section: "II", text: "<p>Second section.</p>" }
|
||||
{ section: "", text: "<p>Another section.</p>" }
|
||||
]
|
||||
}
|
||||
}]
|
||||
testCases = [{
|
||||
tested: """
|
||||
{
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
},
|
||||
content: [
|
||||
"<p><strong>This</strong> is leading text.</p>",
|
||||
{ section: "I", text: "<p>First section.</p>" },
|
||||
{ section: "II", text: "<p>Second section.</p>" },
|
||||
{ text: "<p>Another section.</p>" },
|
||||
],
|
||||
}"""
|
||||
expected: {
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
}
|
||||
content: [
|
||||
{ section: "", text: "<p><strong>This</strong> is leading text.</p>" }
|
||||
{ section: "I", text: "<p>First section.</p>" }
|
||||
{ section: "II", text: "<p>Second section.</p>" }
|
||||
{ section: "", text: "<p>Another section.</p>" }
|
||||
]
|
||||
}
|
||||
}]
|
||||
|
||||
testReader("jsonReader", testCases)
|
||||
testReader("jsonReader", testCases)
|
||||
)
|
||||
|
||||
@@ -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: '<a href="http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights">http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights</a>'
|
||||
}
|
||||
content: [
|
||||
{ section: "1", text: "<p>All human beings are born <em>free</em> and equal in dignity and rights...</p>\n" }
|
||||
{ section: "2", text: """<p>Everyone is entitled to all the rights and freedoms...</p>
|
||||
<p>Furthermore, no distinction shall be made on the basis of...</p>\n""" }
|
||||
{ section: "11.1", text: "<p>Everyone charged with a penal offence has the right to be presumed...</p>\n" }
|
||||
{ section: "11.2", text: "<p>No one shall be held guilty of any penal offence...</p>\n" }
|
||||
{ section: "13", text: """<p>Everyone is entitled to:</p>
|
||||
<ul>
|
||||
<li>sex</li>
|
||||
<li>drugs</li>
|
||||
<li>rock & roll</li>
|
||||
</ul>\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: '<a href="http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights">http://en.wikisource.org/wiki/Universal_Declaration_of_Human_Rights</a>'
|
||||
}
|
||||
content: [
|
||||
{ section: "1", text: "<p>All human beings are born <em>free</em> and equal in dignity and rights...</p>\n" }
|
||||
{ section: "2", text: """
|
||||
<p>Everyone is entitled to all the rights and freedoms...</p>
|
||||
<p>Furthermore, no distinction shall be made on the basis of...</p>\n""" }
|
||||
{ section: "11.1", text: "<p>Everyone charged with a penal offence has the right to be presumed...</p>\n" }
|
||||
{ section: "11.2", text: "<p>No one shall be held guilty of any penal offence...</p>\n" }
|
||||
{ section: "13", text: """
|
||||
<p>Everyone is entitled to:</p>
|
||||
<ul>
|
||||
<li>sex</li>
|
||||
<li>drugs</li>
|
||||
<li>rock & roll</li>
|
||||
</ul>\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: "<p><strong>This</strong> is leading text.</p>\n" }
|
||||
{ section: "I", text: "<p>First section.</p>\n" }
|
||||
{ section: "II", text: "<p>Second section.</p>\n" }
|
||||
]
|
||||
}
|
||||
}]
|
||||
**This** is leading text.
|
||||
# I
|
||||
First section.
|
||||
# II
|
||||
Second section.
|
||||
"""
|
||||
expected: {
|
||||
meta: {
|
||||
Title: "Test leading text"
|
||||
}
|
||||
content: [
|
||||
{ section: "", text: "<p><strong>This</strong> is leading text.</p>\n" }
|
||||
{ section: "I", text: "<p>First section.</p>\n" }
|
||||
{ section: "II", text: "<p>Second section.</p>\n" }
|
||||
]
|
||||
}
|
||||
}]
|
||||
|
||||
testReader("markdownReader", testCases)
|
||||
testReader("markdownReader", testCases)
|
||||
)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
body {
|
||||
font-family: "Titillium Web", sans-serif;
|
||||
font-family: "Titillium Web", sans-serif;
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user