+
diff --git a/server.py b/server.py index 37e6eba..9191c76 100644 --- a/server.py +++ b/server.py @@ -3,7 +3,7 @@ import uuid import json import socket import os - +import urllib # non standards, in requirements.txt from flask import Flask, request, Markup, render_template, redirect, url_for @@ -48,12 +48,12 @@ class Anonymous_Github: content = content.replace(term, "XXX") return content if ".md" in file.name: - return "
" + file.decoded_content + ""), terms) return Markup("Download %s" % (file.url, file.name)) @@ -78,17 +78,24 @@ class Anonymous_Github: if repo[-1] == '/': repo = repo[:-1] g_repo = self.github.get_repo(repo) - current_folder = g_repo.get_contents(path) + current_folder = g_repo.get_contents(urllib.quote(path)) current_file = None if type(current_folder) is github.ContentFile.ContentFile: current_file = current_folder - current_folder = g_repo.get_contents(os.path.dirname(path)) + current_folder = g_repo.get_contents(urllib.quote(os.path.dirname(path))) else: for f in current_folder: if f.name.lower() == "readme.md" or f.name.lower() == "index.html": current_file = f break - return render_template('repo.html', terms=data["terms"], current_repository=id, current_file=current_file, current_folder=current_folder) + + return render_template('repo.html', + name=data['name'], + terms=data["terms"], + current_repository=id, + current_file=current_file, + current_folder=current_folder, + path=path.split("/") if path != '' else []) @application.route('/', methods=['GET']) def index(): @@ -98,15 +105,17 @@ class Anonymous_Github: def add_repository(): id = str(uuid.uuid4()) repo = request.form['githubRepository'] - terms = request.form['terms'] + terms = request.form['terms'], + repo_name = request.form['name'] config_path = self.config_dir + "/" + str(id) os.mkdir(config_path) with open(config_path + "/config.json", 'w') as outfile: json.dump({ "id": id, + "name": repo_name, "repository": repo, - "terms": terms.split("\n") + "terms": terms.split() }, outfile) return redirect(url_for('repository', id=id)) diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..6958f8e --- /dev/null +++ b/static/css/style.css @@ -0,0 +1,41 @@ +.main { + width: 80%; + margin: auto; +} + +.files { + border: 1px solid #dddddd; + border-bottom: initial; + margin: 15px; + border-radius: 5px; +} + +.files a { + display: block; + padding: 9px; +} + +.files .file, .files .dir, .files .parent_folder { + border-bottom: 1px solid #dddddd; +} + +.files .file.active, .files .file:hover, .files .dir:hover, .files .parent_folder:hover { + background: #f0f0f0; +} + +.paths { + margin: 15px; + border: 1px solid #dddddd; + border-radius: 5px; + padding: 8px +} + +.paths a { + color: #000000; +} + +.paths .path::after { + content: '/'; + color: #dddddd; + padding-left: 4px; +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 11536f0..9227cbf 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,23 +7,32 @@ + + -
| {{ item.name }} | -