diff --git a/cats.txt b/cats.txt new file mode 100644 index 0000000..013fcc1 --- /dev/null +++ b/cats.txt @@ -0,0 +1,47 @@ +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 + diff --git a/indexer.py b/indexer.py index c302593..af4522e 100644 --- a/indexer.py +++ b/indexer.py @@ -1,23 +1,53 @@ #!/usr/bin/python3 -#/* vim:set ts=2 set noexpandtab */ +# vim:ts=2 sw=2 sts=2 noexpandtab +import json, os 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") + return render_template("search.html", strings=strings) -@app.route("/categorys") +@app.route("/categories") def categorys(): - return render_template("categorys.html") + return render_template("categories.html", strings=strings) @app.route("/create") def create(): - return render_template("create.html") + return render_template("create.html", categories=settings["categories"], strings=strings) @app.route("/search", methods=['GET']) def search(): - return render_template("result.html", results=request.args.get("q", "")) + 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) if __name__ == "__main__": - app.run(debug=True) + app.jinja_env.globals.update(getLocalString=getLocalString) + app.jinja_env.globals.update(json=json) + init() + print(settings["categories"].keys()) + app.run(debug=True) diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..dd9b7a3 --- /dev/null +++ b/settings.json @@ -0,0 +1,10 @@ +{ + "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" ] + } +} diff --git a/static/css/bootstrap.css b/static/css/bootstrapshit/bootstrap.css similarity index 100% rename from static/css/bootstrap.css rename to static/css/bootstrapshit/bootstrap.css diff --git a/static/css/search.css b/static/css/bootstrapshit/search.css similarity index 100% rename from static/css/search.css rename to static/css/bootstrapshit/search.css diff --git a/static/css/bootstrapshit/style.css b/static/css/bootstrapshit/style.css new file mode 100644 index 0000000..793b568 --- /dev/null +++ b/static/css/bootstrapshit/style.css @@ -0,0 +1,169 @@ +/* + * 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; +} diff --git a/static/css/style.css b/static/css/style.css index 2c3df37..e69de29 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -1,163 +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; - } -} diff --git a/static/js/create.js b/static/js/create.js new file mode 100644 index 0000000..18f3f57 --- /dev/null +++ b/static/js/create.js @@ -0,0 +1,50 @@ +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) + } +} diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 0000000..0998134 --- /dev/null +++ b/static/js/main.js @@ -0,0 +1,16 @@ +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 +} diff --git a/strings.json b/strings.json new file mode 100644 index 0000000..5966f1d --- /dev/null +++ b/strings.json @@ -0,0 +1,35 @@ +{ + "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" + } +} diff --git a/templates/categorys.html b/templates/bootstrapshit/categories.html similarity index 55% rename from templates/categorys.html rename to templates/bootstrapshit/categories.html index 3200c46..c152e77 100644 --- a/templates/categorys.html +++ b/templates/bootstrapshit/categories.html @@ -2,8 +2,8 @@ vim: ts=2 noexpandtab --> {% extends "index.html" %} -{% block title %}{{ super() }} - Categorys{% endblock%} -{% set active_page = "categorys" %} +{% block title %}{{ super() }} - Categories{% endblock%} +{% set active_page = "categories" %} {% block content %}

CATEGORYS

{% endblock content%} diff --git a/templates/bootstrapshit/create.html b/templates/bootstrapshit/create.html new file mode 100644 index 0000000..1c5ef4b --- /dev/null +++ b/templates/bootstrapshit/create.html @@ -0,0 +1,44 @@ + +{% extends "index.html" %} +{% block title %}{{ super() }} - Create{% endblock%} +{% set active_page = "create" %} +{% block content %} + + +
+

Add new torrent

+ +
+{% endblock content%} + diff --git a/templates/bootstrapshit/index.html b/templates/bootstrapshit/index.html new file mode 100644 index 0000000..7dde050 --- /dev/null +++ b/templates/bootstrapshit/index.html @@ -0,0 +1,57 @@ + +{% set navigation_bar = [ + ("/", "search", "Search", "glyphicon-search"), + ("/categories", "categories", "Categories", "glyphicon-th"), + ("/create", "create", "Create", "glyphicon-plus") +] -%} + + + + + + + + + + {% block title %}TorrentIndexer{% endblock %} + + + + + + + +
+
+
+
+
+

TorrentIndexer

+ +
+
+
+ {% block content %}{% endblock %} +
+
+
+
+ + + + + diff --git a/templates/bootstrapshit/result.html b/templates/bootstrapshit/result.html new file mode 100644 index 0000000..dbccc72 --- /dev/null +++ b/templates/bootstrapshit/result.html @@ -0,0 +1,9 @@ + +{% extends "index.html" %} +{% block title %}{{ super() }} - Results{% endblock%} +{% set active_page = "search" %} +{% block content %} +

{{results}}

+{% endblock content%} diff --git a/templates/bootstrapshit/search.html b/templates/bootstrapshit/search.html new file mode 100644 index 0000000..2ad9088 --- /dev/null +++ b/templates/bootstrapshit/search.html @@ -0,0 +1,26 @@ + +{% extends "index.html" %} +{% block title %}{{ super() }} - Search{% endblock%} +{% set active_page = "search" %} +{% block content %} + + +
+ +
+
+ +
+
+
+{% endblock content%} diff --git a/templates/create.html b/templates/create.html index 22e3c31..ac15907 100644 --- a/templates/create.html +++ b/templates/create.html @@ -2,8 +2,12 @@ vim: ts=2 noexpandtab --> {% extends "index.html" %} -{% block title %}{{ super() }} - Create{% endblock%} -{% set active_page = "create" %} +{% block title %}{{ super() }} - Search{% endblock%} +{% set active_page = "search" %} {% block content %} -

CREATE

+ +
+ + +
{% endblock content%} diff --git a/templates/index.html b/templates/index.html index c456606..2e36aad 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,10 +1,9 @@ - +{% set language = "english" -%} + {% set navigation_bar = [ - ("/", "search", "Search", "glyphicon-search"), - ("/categorys", "categorys", "Categorys", "glyphicon-th"), - ("/create", "create", "Create", "glyphicon-plus") +("/", "search", getLocalString(language, "search")), + ("/categories", "categories", "Categories"), + ("/create", "create", "Create") ] -%} @@ -13,41 +12,25 @@ vim: ts=2 noexpandtab - - {% block title %}TorrentIndexer{% endblock %} - + -
-
-
-
-
-

TorrentIndexer

- -
-
-
- {% block content %}{% endblock %} -
-
-
+ +
+ {% for href, id, caption in navigation_bar %} + {{ caption }} + {% endfor %}
- - - + {% block content %} + + INDEX + {% endblock %} diff --git a/templates/result.html b/templates/result.html index dbccc72..ccaf287 100644 --- a/templates/result.html +++ b/templates/result.html @@ -2,8 +2,9 @@ vim: ts=2 noexpandtab --> {% extends "index.html" %} -{% block title %}{{ super() }} - Results{% endblock%} +{% block title %}{{ super() }} - Search{% endblock%} {% set active_page = "search" %} {% block content %} -

{{results}}

+ +{{results}} {% endblock content%} diff --git a/templates/search.html b/templates/search.html index 2ad9088..d8d051d 100644 --- a/templates/search.html +++ b/templates/search.html @@ -7,20 +7,9 @@ vim: ts=2 noexpandtab {% block content %} -
-
-
- -
+ + +
-
{% endblock content%}