Initial Commit

master
rubenwardy 2017-01-03 23:45:22 +00:00
commit 009bdddd0c
8 changed files with 274 additions and 0 deletions

59
.gitignore vendored Normal file
View File

@ -0,0 +1,59 @@
~*
out
settings.json
downloads.txt
reports.json
downloads.json
/data
# Created by https://www.gitignore.io/api/node,linux
### Node ###
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*

25
package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "minetest-mod-database",
"version": "0.1.0",
"description": "Minetest Mod Database",
"main": "index.js",
"scripts": {
"test": "mocha tests.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rubenwardy/minetest-mod-database.git"
},
"author": "rubenwardy",
"license": "LGPL-2.1+",
"bugs": {
"url": "https://github.com/rubenwardy/minetest-mod-database/issues"
},
"homepage": "https://github.com/rubenwardy/minetest-mod-database#readme",
"dependencies": {
"apicache": "^0.7.4",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"express-liquid": "^0.2.6"
}
}

1
service/index.js Normal file
View File

@ -0,0 +1 @@
"use strict"

View File

@ -0,0 +1,14 @@
// Index controller - puts all the controllers together
"use strict";
const express = require("express")
const router = express.Router()
router.get("/", function(req, res) {
res.render("index", {
title: "Mod Developer Panel",
mods: []
})
})
module.exports = router

42
webapp/index.js Normal file
View File

@ -0,0 +1,42 @@
"use strict";
require("process").chdir(__dirname)
var app = require("express")()
// Support JSON and URL encoded bodies
var bodyParser = require("body-parser")
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}))
// Caching for JSON APIs
var apicache = require("apicache").options({ debug: false }).middleware
// Support Liquid templating
var expressLiquid = require("express-liquid")
var options = {
// read file handler, optional
includeFile: function (filename, callback) {
var fs = require("fs");
fs.readFile(filename, "utf8", callback);
},
// the base context, optional
context: expressLiquid.newContext(),
// custom tags parser, optional
customTags: {},
// if an error occurred while rendering, show detail or not, default to false
traceError: false
};
app.set("view engine", "liquid");
app.engine("liquid", expressLiquid(options));
app.use(expressLiquid.middleware);
// Controllers
app.use(require("./controllers"))
// Start server
app.listen(8080, "127.0.0.1", function () {
console.log("Minetest Mod Database listening on port 8080!");
});

View File

@ -0,0 +1,11 @@
</div>
<footer>
Created by rubenwardy |
<a href="/">Dashboard</a> |
<a href="/blacklist/">Blacklist</a> |
<a href="/verified/">Verified Links</a>
</footer>
</body>
</html>

View File

@ -0,0 +1,93 @@
<!doctype html>
<html>
<head>
<title>{{ title }} | Minetest Mod Database</title>
<style>
html, body {
margin: 0;
padding: 0;
font-family: "Arial", sans-serif;
background: #222;
color: #aaa;
min-height: 100%;
}
#container {
position: relative;
width: 80%;
max-width: 860px;
margin: auto;
padding: 0;
min-height: 90%;
}
#screenshots > img {
max-height: 500px;
max-width: 100%;
}
footer {
width: 80%;
max-width: 860px;
margin: auto;
padding: 50px 0 20px 0;
}
footer a {
color: #666;
}
a {
color: #0be;
font-weight: bold;
text-decoration: none;
}
h1 {
text-align: center;
}
#back {
position: absolute;
top: 10px;
left: 10px;
}
a:hover {
color: #0df;
text-decoration: underline;
}
ul, li {
list-style: none;
margin: 0;
padding: 0;
}
ul li {
margin: 10px 0;
padding: 10px 20px;
display: block;
border-radius: 5px;
background: #333;
color: #ccc;
}
ul li a {
padding-bottom: 5px;
color: #eee;
font-weight: bold;
}
.right {
background: #353;
}
.wrong {
background: #422;
}
</style>
</head>
<body>
<div id="container">
<h1><a href="http://rubenwardy.com/mtmods4android/">Minetest Mod Database</a></h1>

29
webapp/views/index.liquid Normal file
View File

@ -0,0 +1,29 @@
{% include "header" %}
<aside>
<h2>Mods Search</h2>
<form action="/mods/" method="get">
<input type="text" name="q" placeholder="Search" value="{{ search }}">
<input type="submit" value="Go">
</form>
</aside>
<h2>Popular</h2>
<ul>
{% for mod in mods %}
<li>
<span style="padding-right:10px">{{ forloop.index }})</span>
<a href="{{ mod.forum_url }}">{{ mod.title }}</a> by {{ mod.author }}<br />
<p>
{{ mod.description | truncate: 100, '…' }}
</p>
<a href="{{ mod.download_link }}">Download</a> [{{ mod.downloads }}] |
<a href="{{ mod.forum_url }}">Forum Topic</a> |
<a href="/status/?a={{ mod.author }}">{{ mod.author }}'s mods</a>
</li>
{% endfor %}
</ul>
{% include "footer" %}