This commit is contained in:
sqozz 2015-02-12 22:06:31 +01:00
parent 90bd3ea1f2
commit 94ba7485c6
19 changed files with 227 additions and 534 deletions

View File

@ -1,47 +0,0 @@
Audio
Lossless
Lossy
Audiobooks
Other
Video
Movies 3D
Movies HD
Movies SD
Series HD
Series SD
Clips
Other
Porn
Movies 3D
Movies HD
Movies SD
Series HD
Series SD
Clips
Pictures
Other
Games
PC
MAC
iOS
Android
Consoles
Other
Applications
Windows
Mac
*nix
iOS
Android
Other
Other
E-Books
Comics
Pictures
Other

View File

@ -1,53 +1,23 @@
#!/usr/bin/python3
# vim:ts=2 sw=2 sts=2 noexpandtab
import json, os
#/* vim:set ts=2 set noexpandtab */
from flask import Flask, render_template, url_for, request
from werkzeug import secure_filename
uploadFolder = "upload"
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = uploadFolder
strings = None
settings = None
@app.route("/")
def index():
return render_template("search.html", strings=strings)
return render_template("search.html")
@app.route("/categories")
@app.route("/categorys")
def categorys():
return render_template("categories.html", strings=strings)
return render_template("categorys.html")
@app.route("/create")
def create():
return render_template("create.html", categories=settings["categories"], strings=strings)
return render_template("create.html")
@app.route("/search", methods=['GET'])
def search():
return render_template("result.html", results=request.args.get("q", ""), strings=strings)
def getLocalString(language, descriptor):
if language in strings.keys():
if descriptor in strings[language].keys():
return strings[language][descriptor]
else:
return None
else:
return None
def init():
global strings
global settings
with open("strings.json", "r") as strings:
strings = json.load(strings)
with open("settings.json", "r") as settings:
settings = json.load(settings)
return render_template("result.html", results=request.args.get("q", ""))
if __name__ == "__main__":
app.jinja_env.globals.update(getLocalString=getLocalString)
app.jinja_env.globals.update(json=json)
init()
print(settings["categories"].keys())
app.run(debug=True)
app.run(debug=True)

View File

@ -1,10 +0,0 @@
{
"categories": {
"audio" : [ "lossless", "lossy", "audiobooks", "other" ],
"video" : [ "movies_3d", "movies_4k", "movies_hd", "movies_sd", "series_hd", "series_sd", "clips", "other" ],
"porn" : [ "movies_3d", "movies_4k", "movies_hd", "movies_sd", "series_hd", "series_sd", "clips", "pictures", "other" ],
"games" : [ "pc", "mac", "ios", "android", "consoles", "other" ],
"applications" : [ "windows", "mac", "unix", "ios", "android", "other" ],
"other" : [ "ebooks", "comics", "pictures", "other" ]
}
}

View File

@ -1,169 +0,0 @@
/*
* Globals
*/
/* Links */
a,
a:focus,
a:hover {
color: #fff;
}
/* Custom default button */
.btn-default,
.btn-default:hover,
.btn-default:focus {
color: #333;
text-shadow: none; /* Prevent inheritence from `body` */
background-color: #fff;
border: 1px solid #fff;
}
/*
* Base structure
*/
html,
body {
height: 100%;
background-color: #333;
}
body {
color: #fff;
text-align: center;
text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
/* Extra markup and styles for table-esque vertical and horizontal centering */
.site-wrapper {
display: table;
width: 100%;
height: 100%; /* For at least Firefox */
min-height: 100%;
-webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5);
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
}
.site-wrapper-inner {
display: table-cell;
vertical-align: top;
}
.cover-container {
margin-right: auto;
margin-left: auto;
}
/* Padding for spacing */
.inner {
padding: 30px;
}
/*
* Header
*/
.masthead-brand {
margin-top: 10px;
margin-bottom: 10px;
}
.masthead-nav > li {
display: inline-block;
}
.masthead-nav > li + li {
margin-left: 20px;
}
.masthead-nav > li > a {
padding-right: 0;
padding-left: 0;
font-size: 16px;
font-weight: bold;
color: #fff; /* IE8 proofing */
color: rgba(255,255,255,.75);
border-bottom: 2px solid transparent;
}
.masthead-nav > li > a:hover,
.masthead-nav > li > a:focus {
background-color: transparent;
border-bottom-color: #a9a9a9;
border-bottom-color: rgba(255,255,255,.25);
}
.masthead-nav > .active > a,
.masthead-nav > .active > a:hover,
.masthead-nav > .active > a:focus {
color: #fff;
border-bottom-color: #fff;
}
@media (min-width: 768px) {
.masthead-brand {
float: left;
}
.masthead-nav {
float: right;
}
}
/*
* Cover
*/
.cover {
padding: 20px;
}
.cover .btn-lg {
padding: 10px 20px;
font-weight: bold;
}
/*
* Footer
*/
.mastfoot {
color: #999; /* IE8 proofing */
color: rgba(255,255,255,.5);
}
/*
* Affix and center
*/
@media (min-width: 768px) {
/* Pull out the header and footer */
.masthead {
/*position: fixed;*/
top: 0;
}
.mastfoot {
position: fixed;
bottom: 0;
}
/* Start the vertical centering */
.site-wrapper-inner {
/*vertical-align: middle;*/
}
/* Handle the widths */
.masthead,
.mastfoot,
.cover-container {
width: 100%; /* Must be percentage or pixels for horizontal alignment */
}
}
@media (min-width: 992px) {
.masthead,
.mastfoot,
.cover-container {
width: 700px;
}
}
.list-group-item {
background-color: #212121;
border: 1px solid #717171;
}

View File

@ -0,0 +1,163 @@
/*
* Globals
*/
/* Links */
a,
a:focus,
a:hover {
color: #fff;
}
/* Custom default button */
.btn-default,
.btn-default:hover,
.btn-default:focus {
color: #333;
text-shadow: none; /* Prevent inheritence from `body` */
background-color: #fff;
border: 1px solid #fff;
}
/*
* Base structure
*/
html,
body {
height: 100%;
background-color: #333;
}
body {
color: #fff;
text-align: center;
text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
/* Extra markup and styles for table-esque vertical and horizontal centering */
.site-wrapper {
display: table;
width: 100%;
height: 100%; /* For at least Firefox */
min-height: 100%;
-webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5);
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
}
.site-wrapper-inner {
display: table-cell;
vertical-align: top;
}
.cover-container {
margin-right: auto;
margin-left: auto;
}
/* Padding for spacing */
.inner {
padding: 30px;
}
/*
* Header
*/
.masthead-brand {
margin-top: 10px;
margin-bottom: 10px;
}
.masthead-nav > li {
display: inline-block;
}
.masthead-nav > li + li {
margin-left: 20px;
}
.masthead-nav > li > a {
padding-right: 0;
padding-left: 0;
font-size: 16px;
font-weight: bold;
color: #fff; /* IE8 proofing */
color: rgba(255,255,255,.75);
border-bottom: 2px solid transparent;
}
.masthead-nav > li > a:hover,
.masthead-nav > li > a:focus {
background-color: transparent;
border-bottom-color: #a9a9a9;
border-bottom-color: rgba(255,255,255,.25);
}
.masthead-nav > .active > a,
.masthead-nav > .active > a:hover,
.masthead-nav > .active > a:focus {
color: #fff;
border-bottom-color: #fff;
}
@media (min-width: 768px) {
.masthead-brand {
float: left;
}
.masthead-nav {
float: right;
}
}
/*
* Cover
*/
.cover {
padding: 20px;
}
.cover .btn-lg {
padding: 10px 20px;
font-weight: bold;
}
/*
* Footer
*/
.mastfoot {
color: #999; /* IE8 proofing */
color: rgba(255,255,255,.5);
}
/*
* Affix and center
*/
@media (min-width: 768px) {
/* Pull out the header and footer */
.masthead {
/*position: fixed;*/
top: 0;
}
.mastfoot {
position: fixed;
bottom: 0;
}
/* Start the vertical centering */
.site-wrapper-inner {
/*vertical-align: middle;*/
}
/* Handle the widths */
.masthead,
.mastfoot,
.cover-container {
width: 100%; /* Must be percentage or pixels for horizontal alignment */
}
}
@media (min-width: 992px) {
.masthead,
.mastfoot,
.cover-container {
width: 700px;
}
}

View File

@ -1,50 +0,0 @@
window.onload = function () {
catList = document.getElementById("categories_list")
categories = sortCategories(global_categories)
for(var key in categories) {
var a = document.createElement("a")
var li = document.createElement("li")
li.setAttribute("role", "presentation")
li.addEventListener("click", function(){fillSubCategorie(this.children[0].text); setDropdownText(this)})
a.setAttribute("role", "menuitem")
a.tabIndex = "-1"
a.href = "#"
a.innerHTML = getLocalString("english", categories[key])
li.appendChild(a)
catList.appendChild(li)
a = undefined
li = undefined
}
}
function sortCategories(categories) {
var sortedCategories = []
for(var key in categories) {
sortedCategories.push(key)
}
sortedCategories.sort()
return sortedCategories
}
function setDropdownText(liElement) {
liElement.parentNode.parentNode.childNodes[1].childNodes[0].textContent = liElement.children[0].text + " "
}
function fillSubCategorie(categorie) {
subCategory = getDescriptorByLocalString("english", categorie)
catList = document.getElementById("subcategory_list")
catList.innerHTML = ""
categories = global_categories[subCategory].sort()
for(var key in categories) {
var a = document.createElement("a")
var li = document.createElement("li")
li.setAttribute("role", "presentation")
li.addEventListener("click", function(){setDropdownText(this)})
a.setAttribute("role", "menuitem")
a.tabIndex = "-1"
a.href = "#"
a.innerHTML = getLocalString("english", categories[key])
li.appendChild(a)
catList.appendChild(li)
}
}

View File

@ -1,16 +0,0 @@
function getLocalString(language, descriptor){
if(global_strings[language]){
return global_strings[language][descriptor] || global_strings["english"][descriptor] || descriptor
} else {
return descriptor
}
}
function getDescriptorByLocalString(language, localString){
for(string in global_strings[language]){
if(global_strings[language][string] == localString){
return string
}
}
return localString
}

View File

@ -1,35 +0,0 @@
{
"english" : {
"audio" : "Audio",
"lossless" : "Lossless",
"lossy" : "Lossy",
"audiobooks" : "Audiobooks",
"other" : "Other",
"video" : "Video",
"movies_3d" : "Movies 3D",
"movies_4k" : "Movies 4K",
"movies_hd" : "Movies HD",
"movies_sd" : "Movies SD",
"series_hd" : "Series HD",
"series_sd" : "Series SD",
"clips" : "Clips",
"other" : "Other",
"porn" : "Porn",
"pictures" : "Pictures",
"games" : "Games",
"pc" : "PC",
"mac" : "Mac",
"ios" : "iOS",
"android" : "Android",
"consoles" : "Consoles",
"applications" : "Applications",
"windows" : "Windows",
"unix" : "*nix",
"ebooks" : "E-Books",
"comics" : "Comics",
"please_choose" : "Please choose…",
"search" : "Search",
"categories" : "Categories",
"create" : "Create"
}
}

View File

@ -1,44 +0,0 @@
<!--
vim: ts=2 noexpandtab
-->
{% extends "index.html" %}
{% block title %}{{ super() }} - Create{% endblock%}
{% set active_page = "create" %}
{% block content %}
<script type="text/javascript">
var global_categories = {{json.dumps(categories)|safe}};
</script>
<script type="text/javascript" src="{{ url_for ("static", filename="js/create.js") }}" ></script>
<div class="create_container" >
<h4>Add new torrent</h4>
<ul class="list-group">
<li class="list-group-item">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Torrent name</span>
<input type="text" class="form-control" aria-describedby="basic-addon1">
</div>
</li>
<li class="list-group-item">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="categories" data-toggle="dropdown" aria-expanded="true">
{{getLocalString("english", "please_choose")}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="categories_list" role="menu" aria-labelledby="dropdownMenu1">
</ul>
</div>
<br/>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="subcategory" data-toggle="dropdown" aria-expanded="true">
{{getLocalString("english", "please_choose")}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" id="subcategory_list">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">{{getLocalString("english", subcat)}}</a></li>
</ul>
</div>
</li>
</ul>
</div>
{% endblock content%}

View File

@ -1,57 +0,0 @@
<!--
vim: ts=2 noexpandtab
-->
{% set navigation_bar = [
("/", "search", "Search", "glyphicon-search"),
("/categories", "categories", "Categories", "glyphicon-th"),
("/create", "create", "Create", "glyphicon-plus")
] -%}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<title>{% block title %}TorrentIndexer{% endblock %}</title>
<link href="{{ url_for("static", filename="css/bootstrap.css") }}" rel="stylesheet">
<link href="{{ url_for("static", filename="css/style.css") }}" rel="stylesheet">
<script type="text/javascript" src="{{ url_for ("static", filename="js/main.js") }}" ></script>
</head>
<body>
<script type="text/javascript">
var global_strings = {{json.dumps(strings)|safe}}
</script>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="cover-container">
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand"><a href="/">TorrentIndexer</a></h3>
<nav>
<ul class="nav masthead-nav">
{% for href, id, caption, icon in navigation_bar %}
<li {% if id == active_page %}class="active"{% endif %}>
<a href="{{ href }}">
<span class="glyphicon {{ icon|e }}" aria-hidden="true"></span> {{ caption|e }}
</a>
</li>
{% endfor %}
</ul>
</nav>
</div>
</div>
<div class="inner cover">
{% block content %}{% endblock %}
</div>
</div>
</div>
</div>
<script src="{{ url_for("static", filename="js/jquery.js") }}"></script>
<script src="{{ url_for("static", filename="js/bootstrap.js") }}"></script>
</body>
</html>

View File

@ -1,9 +0,0 @@
<!--
vim: ts=2 noexpandtab
-->
{% extends "index.html" %}
{% block title %}{{ super() }} - Results{% endblock%}
{% set active_page = "search" %}
{% block content %}
<p>{{results}}</p>
{% endblock content%}

View File

@ -1,26 +0,0 @@
<!--
vim: ts=2 noexpandtab
-->
{% extends "index.html" %}
{% block title %}{{ super() }} - Search{% endblock%}
{% set active_page = "search" %}
{% block content %}
<link href="{{ url_for("static", filename="css/search.css") }}" rel="stylesheet">
<div class="search_container">
<img class="logo" src="{{ url_for("static", filename="images/Pirates.svg") }}" />
<form action="search" >
<div class="form-group">
<div class="input-group search-box">
<input type="text" name="q" class="form-control" placeholder="Seach for…" aria-describedby="basic-addon2">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
Search!
</button>
</span>
</div>
</div>
</form>
</div>
{% endblock content%}

View File

@ -2,8 +2,8 @@
vim: ts=2 noexpandtab
-->
{% extends "index.html" %}
{% block title %}{{ super() }} - Categories{% endblock%}
{% set active_page = "categories" %}
{% block title %}{{ super() }} - Categorys{% endblock%}
{% set active_page = "categorys" %}
{% block content %}
<p>CATEGORYS</p>
{% endblock content%}

View File

@ -2,12 +2,8 @@
vim: ts=2 noexpandtab
-->
{% extends "index.html" %}
{% block title %}{{ super() }} - Search{% endblock%}
{% set active_page = "search" %}
{% block title %}{{ super() }} - Create{% endblock%}
{% set active_page = "create" %}
{% block content %}
<link href="{{ url_for("static", filename="css/search.css") }}" rel="stylesheet">
<form id="tfnewsearch" method="get" action="search">
<input type="text" class="tftextinput" name="torrent_name">
<input type="submit" value="{{ getLocalString("english", "search") }}" class="tfbutton">
</form>
<p>CREATE</p>
{% endblock content%}

View File

@ -1,9 +1,10 @@
{% set language = "english" -%}
<!--
vim: ts=2 noexpandtab
-->
{% set navigation_bar = [
("/", "search", getLocalString(language, "search")),
("/categories", "categories", "Categories"),
("/create", "create", "Create")
("/", "search", "Search", "glyphicon-search"),
("/categorys", "categorys", "Categorys", "glyphicon-th"),
("/create", "create", "Create", "glyphicon-plus")
] -%}
<!DOCTYPE html>
@ -12,25 +13,41 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<title>{% block title %}TorrentIndexer{% endblock %}</title>
<link href="{{ url_for("static", filename="css/bootstrap.css") }}" rel="stylesheet">
<link href="{{ url_for("static", filename="css/style.css") }}" rel="stylesheet">
<script type="text/javascript" src="{{ url_for ("static", filename="js/main.js") }}" ></script>
</head>
<body>
<script type="text/javascript">
var global_strings = {{ json.dumps(strings)|safe }}
</script>
<div class="header">
{% for href, id, caption in navigation_bar %}
<a href="{{ href }}">{{ caption }}</a>
{% endfor %}
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="cover-container">
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand"><a href="/">TorrentIndexer</a></h3>
<nav>
<ul class="nav masthead-nav">
{% for href, id, caption, icon in navigation_bar %}
<li {% if id == active_page %}class="active"{% endif %}>
<a href="{{ href|e }}">
<span class="glyphicon {{ icon|e }}" aria-hidden="true"></span> {{ caption|e }}
</a>
</li>
{% endfor %}
</ul>
</nav>
</div>
</div>
<div class="inner cover">
{% block content %}{% endblock %}
</div>
</div>
</div>
</div>
{% block content %}
<script type="text/javascript">
var global_strings = {{json.dumps(strings)|safe}}
</script>
INDEX
{% endblock %}
<script src="{{ url_for("static", filename="js/jquery.js") }}"></script>
<script src="{{ url_for("static", filename="js/bootstrap.js") }}"></script>
</body>
</html>

View File

@ -2,9 +2,8 @@
vim: ts=2 noexpandtab
-->
{% extends "index.html" %}
{% block title %}{{ super() }} - Search{% endblock%}
{% block title %}{{ super() }} - Results{% endblock%}
{% set active_page = "search" %}
{% block content %}
<link href="{{ url_for("static", filename="css/search.css") }}" rel="stylesheet">
{{results}}
<p>{{results}}</p>
{% endblock content%}

View File

@ -7,9 +7,20 @@ vim: ts=2 noexpandtab
{% block content %}
<link href="{{ url_for("static", filename="css/search.css") }}" rel="stylesheet">
<div class="search_container">
<img class="logo" src="{{ url_for("static", filename="images/Pirates.svg") }}" />
<form id="tfnewsearch" method="get" action="search">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120">
<input type="submit" value="{{ getLocalString("english", "search") }}" class="tfbutton">
<form action="search" >
<div class="form-group">
<div class="input-group search-box">
<input type="text" name="q" class="form-control" placeholder="Seach for…" aria-describedby="basic-addon2">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
Search!
</button>
</span>
</div>
</div>
</form>
</div>
{% endblock content%}