Skip to content

Commit

Permalink
it works
Browse files Browse the repository at this point in the history
  • Loading branch information
zeke committed Jan 11, 2014
0 parents commit 357c3c9
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
Empty file added README.md
Empty file.
27 changes: 27 additions & 0 deletions index.js
@@ -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)
38 changes: 38 additions & 0 deletions package.json
@@ -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"
}
}
57 changes: 57 additions & 0 deletions public/styles.css
@@ -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;
}



5 changes: 5 additions & 0 deletions views/index.jade
@@ -0,0 +1,5 @@
extends layout

block content

h1 Wikipedia Translator
13 changes: 13 additions & 0 deletions views/layout.jade
@@ -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
13 changes: 13 additions & 0 deletions views/search.jade
@@ -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

0 comments on commit 357c3c9

Please sign in to comment.