Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 357c3c9
Showing
8 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var express = require('express') | ||
var logfmt = require('logfmt') | ||
var translate = require('wikipedia-translator') | ||
var wikipedias = require('wikipedias') | ||
var app = express() | ||
|
||
app.configure(function() { | ||
if (process.env.NODE_ENV !== "test") app.use(logfmt.requestLogger()); | ||
app.use(app.router); | ||
app.use('/', express.static('public')); | ||
app.set('view engine', 'jade'); | ||
}); | ||
|
||
app.get('/', function(req, res) { | ||
res.render('index'); | ||
}); | ||
|
||
app.get('/search', function(req, res) { | ||
translate(req.query.q, function(err, translation) { | ||
// res.json(translation); | ||
translation.wikipedias = wikipedias; | ||
console.log(wikipedias); | ||
res.render('search', translation); | ||
}) | ||
}); | ||
|
||
app.listen(process.env.PORT || 5000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "translator", | ||
"version": "0.0.0", | ||
"description": "A website/webservice for displaying wikipedia word translations", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "nodemon index.js", | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/zeke/translator.git" | ||
}, | ||
"keywords": [ | ||
"translation", | ||
"words", | ||
"language", | ||
"scraping", | ||
"wikipedia" | ||
], | ||
"author": "zeke", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/zeke/translator/issues" | ||
}, | ||
"homepage": "https://github.com/zeke/translator", | ||
"devDependencies": { | ||
"should": "~2.1.1", | ||
"mocha": "~1.17.0" | ||
}, | ||
"dependencies": { | ||
"logfmt": "~0.18.1", | ||
"jade": "~1.1.4", | ||
"express": "~3.4.7", | ||
"wikipedia-translator": "~0.1.0", | ||
"wikipedias": "~0.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
*, *:before, *:after { | ||
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; | ||
} | ||
|
||
body { | ||
font-family: 'PT Sans', sans-serif; | ||
/*font-family: "helvetica neue", helvetica;*/ | ||
font-weight: bold; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
section { | ||
padding: 20px; | ||
} | ||
|
||
ul.translations { | ||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
} | ||
|
||
ul.translations > li { | ||
margin: 0; | ||
padding: 20px 10px; | ||
width: 280px; | ||
float: left; | ||
} | ||
|
||
a { | ||
color: green; | ||
text-decoration: none; | ||
} | ||
|
||
h1 { | ||
font-size: 72px; | ||
margin: 0; | ||
padding: 0; | ||
line-height: 1.5; | ||
} | ||
|
||
h2 { | ||
line-height: 1; | ||
font-size: 24px; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
span.lang { | ||
line-height: 1; | ||
display: block; | ||
opacity: 0.5; | ||
font-size: 14px; | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extends layout | ||
|
||
block content | ||
|
||
h1 Wikipedia Translator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
doctype html | ||
html | ||
head | ||
title Wikipedia Translator | ||
link(rel='stylesheet', type='text/css', href='/styles.css') | ||
link(href='//fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css') | ||
|
||
script(src='https://code.jquery.com/jquery-2.0.3.min.js') | ||
block head | ||
|
||
body | ||
section | ||
block content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extends layout | ||
|
||
block content | ||
|
||
h1= query | ||
|
||
ul.translations | ||
each t in translations | ||
li | ||
h2 | ||
a(href=t.href)= t.word | ||
if wikipedias[t.lang] | ||
span.lang= wikipedias[t.lang].language |