Skip to content

Commit 567e684

Browse files
committed
Front-end clean-up
1 parent 9f43388 commit 567e684

File tree

225 files changed

+5173
-17502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+5173
-17502
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
templates/*.html linguist-language=html+jinja linguist-detectable=true

KerbalStuff/app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from .blueprints.anonymous import anonymous
2525
from .blueprints.api import api
2626
from .blueprints.blog import blog
27-
from .blueprints.lists import lists
27+
from .blueprints.packs import packs
2828
from .blueprints.login_oauth import list_defined_oauths, login_oauth
2929
from .blueprints.mods import mods
3030
from .blueprints.profile import profiles
@@ -86,7 +86,7 @@ def load_user(username: str) -> User:
8686
app.register_blueprint(blog)
8787
app.register_blueprint(admin)
8888
app.register_blueprint(mods)
89-
app.register_blueprint(lists)
89+
app.register_blueprint(packs)
9090
app.register_blueprint(api)
9191

9292
try:

KerbalStuff/blueprints/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def users(page: int) -> Union[str, werkzeug.wrappers.Response]:
138138
@admin.route("/admin/blog")
139139
@adminrequired
140140
def blog() -> str:
141-
return render_template("admin-blog.html")
141+
return render_template("admin-blog_create.html")
142142

143143

144144
@admin.route("/admin/publishers/<int:page>")

KerbalStuff/blueprints/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def create_list() -> Union[Dict[str, Any], Tuple[Dict[str, Any], int]]:
637637
game_id=game)
638638
db.add(mod_list)
639639
db.commit()
640-
return {'url': url_for("lists.edit_list", list_id=mod_list.id, list_name=mod_list.name)}
640+
return {'url': url_for("packs.edit_list", list_id=mod_list.id, list_name=mod_list.name)}
641641

642642

643643
@api.route('/api/mod/create', methods=['POST'])

KerbalStuff/blueprints/blog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def edit_blog(id: str) -> Union[str, werkzeug.wrappers.Response]:
4444
if not post:
4545
abort(404)
4646
if request.method == 'GET':
47-
return render_template("edit_blog.html", post=post)
47+
return render_template("blog_edit.html", post=post)
4848
else:
4949
post.title = request.form.get('post-title')
5050
post.text = request.form.get('post-body')

KerbalStuff/blueprints/mods.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def update(mod_id: int, mod_name: str) -> str:
8989
check_mod_editable(mod)
9090
game_versions = GameVersion.query.filter(
9191
GameVersion.game_id == mod.game_id).order_by(desc(GameVersion.id)).all()
92-
return render_template("update.html", ga=mod.game, mod=mod, game_versions=game_versions)
92+
return render_template("mod_update.html", ga=mod.game, mod=mod, game_versions=game_versions)
9393

9494

9595
@mods.route("/mod/<int:mod_id>.rss", defaults={'mod_name': None})
@@ -257,7 +257,7 @@ def edit_mod(mod_id: int, mod_name: str) -> Union[str, werkzeug.wrappers.Respons
257257
check_mod_editable(mod)
258258
if request.method == 'GET':
259259
original = current_user == mod.user
260-
return render_template("edit_mod.html", mod=mod, original=original,
260+
return render_template("mod_edit.html", mod=mod, original=original,
261261
background=mod.background_url(_cfg('protocol'), _cfg('cdn-domain')),
262262
new=request.args.get('new') is not None and original)
263263
else:
@@ -287,9 +287,9 @@ def edit_mod(mod_id: int, mod_name: str) -> Union[str, werkzeug.wrappers.Respons
287287
mod.description = description.replace('\r\n', '\n')
288288
mod.score = get_mod_score(mod)
289289
if not mod.license:
290-
return render_template("edit_mod.html", mod=mod, error="All mods must have a license.")
290+
return render_template("mod_edit.html", mod=mod, error="All mods must have a license.")
291291
if mod.description == default_description:
292-
return render_template("edit_mod.html", mod=mod, stupid_user=True)
292+
return render_template("mod_edit.html", mod=mod, stupid_user=True)
293293
newly_published = False
294294
if request.form.get('publish', None):
295295
if not mod.published:
@@ -328,7 +328,7 @@ def edit_mod(mod_id: int, mod_name: str) -> Union[str, werkzeug.wrappers.Respons
328328
@with_session
329329
def create_mod() -> str:
330330
ga = _restore_game_info()
331-
return render_template("create.html", games=get_games(), ga=ga)
331+
return render_template("mod_create.html", games=get_games(), ga=ga)
332332

333333

334334
@mods.route("/mod/<int:mod_id>/stats/downloads", defaults={'mod_name': None})

KerbalStuff/blueprints/lists.py KerbalStuff/blueprints/packs.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ..database import db
1111
from ..objects import Mod, ModList, ModListItem, Game
1212

13-
lists = Blueprint('lists', __name__)
13+
packs = Blueprint('packs', __name__)
1414

1515

1616
def _get_mod_list(list_id: str) -> Tuple[ModList, Game, bool]:
@@ -27,9 +27,9 @@ def _get_mod_list(list_id: str) -> Tuple[ModList, Game, bool]:
2727
return mod_list, ga, editable
2828

2929

30-
@lists.route("/packs", defaults={'gameshort': None})
31-
@lists.route("/packs/<gameshort>")
32-
def packs(gameshort: Optional[str]) -> str:
30+
@packs.route("/packs", defaults={'gameshort': None})
31+
@packs.route("/packs/<gameshort>")
32+
def packs_list(gameshort: Optional[str]) -> str:
3333
game = None if not gameshort else get_game_info(short=gameshort)
3434
query = ModList.query \
3535
.filter(ModList.mods.any()) \
@@ -40,14 +40,14 @@ def packs(gameshort: Optional[str]) -> str:
4040
return render_template("packs.html", ga=game, game=game, packs=packs, page=page, total_pages=total_pages)
4141

4242

43-
@lists.route("/create/pack")
43+
@packs.route("/create/pack")
4444
def create_list() -> str:
4545
games = Game.query.filter(Game.active == True).order_by(desc(Game.id)).all()
4646
ga = Game.query.order_by(desc(Game.id)).first()
47-
return render_template("create_list.html", games=games, ga=ga)
47+
return render_template("pack_create.html", games=games, ga=ga)
4848

4949

50-
@lists.route("/pack/<int:list_id>/delete")
50+
@packs.route("/pack/<int:list_id>/delete")
5151
@loginrequired
5252
@with_session
5353
def delete(list_id: str) -> werkzeug.wrappers.Response:
@@ -67,26 +67,26 @@ def delete(list_id: str) -> werkzeug.wrappers.Response:
6767
return redirect("/profile/" + current_user.username)
6868

6969

70-
@lists.route("/pack/<list_id>/<list_name>")
70+
@packs.route("/pack/<list_id>/<list_name>")
7171
def view_list(list_id: str, list_name: str) -> str:
7272
mod_list, ga, editable = _get_mod_list(list_id)
73-
return render_template("mod_list.html",
73+
return render_template("pack.html",
7474
**{
7575
'mod_list': mod_list,
7676
'editable': editable,
7777
'ga': ga
7878
})
7979

8080

81-
@lists.route("/pack/<list_id>/<list_name>/edit", methods=['GET', 'POST'])
81+
@packs.route("/pack/<list_id>/<list_name>/edit", methods=['GET', 'POST'])
8282
@with_session
8383
@loginrequired
8484
def edit_list(list_id: str, list_name: str) -> Union[str, werkzeug.wrappers.Response]:
8585
mod_list, ga, editable = _get_mod_list(list_id)
8686
if not editable:
8787
abort(403)
8888
if request.method == 'GET':
89-
return render_template("edit_list.html",
89+
return render_template("pack_edit.html",
9090
**{
9191
'mod_list': mod_list,
9292
'mod_ids': [m.mod.id for m in mod_list.mods],
@@ -129,4 +129,4 @@ def edit_list(list_id: str, list_name: str) -> Union[str, werkzeug.wrappers.Resp
129129
db.commit()
130130
for mod in mod_list.mods:
131131
mod.sort_index = mods.index(mod.mod.id)
132-
return redirect(url_for("lists.view_list", list_id=mod_list.id, list_name=mod_list.name))
132+
return redirect(url_for("packs.view_list", list_id=mod_list.id, list_name=mod_list.name))

KerbalStuff/blueprints/profile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def view_profile(username: str) -> str:
4848
key=lambda m: m.game.name),
4949
lambda m: m.game.name)))
5050
mods_followed = sorted(profile.following, key=lambda mod: mod.created, reverse=True)
51-
return render_template("view_profile.html",
51+
return render_template("profile.html",
5252
profile=profile, forum_url=forum_url, forum_url_username=forum_url_username,
5353
background=profile.background_url(_cfg('protocol'), _cfg('cdn-domain')),
5454
mods_created=mods_created, mods_followed=mods_followed)
@@ -100,7 +100,7 @@ def profile(username: str) -> Union[str, werkzeug.wrappers.Response]:
100100
'following': following,
101101
'background': profile.background_url(_cfg('protocol'), _cfg('cdn-domain')),
102102
}
103-
return render_template("profile.html", **parameters)
103+
return render_template("profile_edit.html", **parameters)
104104
else:
105105
profile = User.query.filter(User.username == username).first()
106106
if not profile:

KerbalStuff/ckan.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def send_to_ckan(mod: Mod) -> None:
2929
'description': mod.description,
3030
'external_link': mod.external_link,
3131
'source_link': mod.source_link,
32-
'user_url': site_base_url + url_for("profile.view_profile", username=mod.user.username),
32+
'user_url': site_base_url + url_for("profile.profile", username=mod.user.username),
3333
'mod_url': site_base_url + url_for('mods.mod', mod_name=mod.name, mod_id=mod.id),
3434
'site_name': site_name,
3535
})

frontend/build.js

+54-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const sass = require('node-sass');
44
const browserify = require('browserify');
55
const coffeeify = require('coffeeify');
66
const babelify = require('babelify');
7+
const uglifyify = require('uglifyify');
78
const tildeImporter = require('node-sass-tilde-importer');
89

910
const paths = {
@@ -13,19 +14,35 @@ const paths = {
1314
},
1415
output: {
1516
styles: 'build',
16-
scripts: 'build'
17+
scripts: 'build',
18+
fonts: 'build'
1719
}
1820
};
1921

20-
function walkDir(dir, callback) {
21-
fs.readdirSync(dir).forEach(f => {
22-
let dirPath = path.join(dir, f);
23-
let isDirectory = fs.statSync(dirPath).isDirectory();
24-
isDirectory
25-
? walkDir(dirPath, callback)
26-
: callback(path.join(dir, f));
27-
});
28-
}
22+
const staticDeps = [
23+
[ 'node_modules/bootstrap-table/dist/bootstrap-table.min.css',paths.output.styles ],
24+
[ 'node_modules/chosen-js/chosen.min.css', paths.output.styles ],
25+
[ 'node_modules/@devhau/md-editor/dist/md-editor.min.css', paths.output.styles ],
26+
27+
[ 'node_modules/jquery/dist/jquery.min.js', paths.output.scripts ],
28+
[ 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js', paths.output.scripts ],
29+
[ 'node_modules/bootstrap-table/dist/bootstrap-table.min.js', paths.output.scripts ],
30+
[ 'node_modules/bootstrap-table/dist/extensions/editable/bootstrap-table-editable.min.js', paths.output.scripts ],
31+
[ 'node_modules/bootstrap-table/dist/locale/bootstrap-table-en-US.min.js', paths.output.scripts ],
32+
[ 'node_modules/underscore/underscore-min.js', paths.output.scripts ],
33+
[ 'node_modules/jscroll/dist/jquery.jscroll.min.js', paths.output.scripts ],
34+
[ 'node_modules/chosen-js/chosen.jquery.min.js', paths.output.scripts ],
35+
[ 'node_modules/@devhau/md-editor/dist/md-editor.min.js', paths.output.scripts ],
36+
[ 'node_modules/typeahead.js/dist/typeahead.bundle.min.js', paths.output.scripts ],
37+
38+
[ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.eot', paths.output.fonts ],
39+
[ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.svg', paths.output.fonts ],
40+
[ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf', paths.output.fonts ],
41+
[ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff', paths.output.fonts ],
42+
[ 'node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2', paths.output.fonts ],
43+
[ 'node_modules/font-awesome/fonts/fontawesome-webfont.ttf', paths.output.fonts ],
44+
[ 'node_modules/font-awesome/fonts/fontawesome-webfont.woff2', paths.output.fonts ]
45+
];
2946

3047
for (let path in paths.output) {
3148
if (paths.output.hasOwnProperty(path)) {
@@ -37,6 +54,24 @@ for (let path in paths.output) {
3754
}
3855
}
3956

57+
for (const [fromFile, toDir] of staticDeps) {
58+
const toFile = fs.statSync(toDir).isDirectory()
59+
? path.join(toDir, path.basename(fromFile))
60+
: toDir;
61+
fs.copyFileSync(fromFile, toFile);
62+
console.log(`Copied ${fromFile} to ${toFile}`);
63+
}
64+
65+
function walkDir(dir, callback) {
66+
fs.readdirSync(dir).forEach(f => {
67+
let dirPath = path.join(dir, f);
68+
let isDirectory = fs.statSync(dirPath).isDirectory();
69+
isDirectory
70+
? walkDir(dirPath, callback)
71+
: callback(path.join(dir, f));
72+
});
73+
}
74+
4075
walkDir(paths.input.styles, inputFile => {
4176
if (!inputFile.endsWith('.scss'))
4277
return;
@@ -46,19 +81,20 @@ walkDir(paths.input.styles, inputFile => {
4681
sass.render({
4782
file: inputFile,
4883
outfile: outFile,
84+
outputStyle: 'compressed',
4985
importer: tildeImporter,
5086
}, (err, result) => {
51-
if (err)
87+
if (err) {
5288
console.log(err);
53-
else fs.writeFile(outFile,
54-
result.css,
55-
'utf8',
56-
err => {
57-
if (err)
89+
} else {
90+
fs.writeFile(outFile, result.css, 'utf8', err => {
91+
if (err) {
5892
console.log(err);
59-
else
93+
} else {
6094
console.log(`Rendered ${inputFile} to ${outFile}`);
95+
}
6196
});
97+
}
6298
});
6399
});
64100

@@ -70,7 +106,7 @@ walkDir(paths.input.scripts, inputFile => {
70106
const outFile = path.join(paths.output.scripts, `${basename}.js`);
71107
browserify([inputFile], {
72108
extensions: [ '.js', '.coffee' ],
73-
transform: [ coffeeify, babelify ],
109+
transform: [ coffeeify, babelify, [uglifyify, {global:true}] ],
74110
}).bundle((err, result) => {
75111
if (err) {
76112
console.log(err);

frontend/coffee/create.manifest

-1
This file was deleted.

frontend/coffee/edit_mod.manifest

-1
This file was deleted.

frontend/coffee/global.coffee

+22
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,25 @@ if donation_alert
155155
donation_alert.addEventListener('click', (e) ->
156156
createCookie('dismissed_donation', 'true')
157157
, false)
158+
159+
resize_boxes = () ->
160+
x = $(".modbox, .gamebox").outerWidth()
161+
$(".modbox, .gamebox").css('height', (((x / 16) * 9) + 40) + 'px')
162+
163+
x = $(".packbox").outerWidth()
164+
$(".packbox").css('height', (((x / 16) * 9) + 40) + 'px')
165+
166+
$(document).ready () ->
167+
resize_boxes()
168+
$(window).on('resize', resize_boxes)
169+
170+
$(".changer").mouseover (el, index) ->
171+
$(this).children(".front").hide()
172+
$(this).children(".back").show()
173+
174+
$(".changer").mouseout (el, index) ->
175+
$(this).children(".front").show()
176+
$(this).children(".back").hide()
177+
178+
$("#loginModal").on 'shown.bs.modal', () ->
179+
$("#username").focus()

frontend/coffee/list.manifest

-1
This file was deleted.

frontend/coffee/mods.coffee frontend/coffee/mod.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
editor = new mdEditor({autoDownloadFontAwesome: false})
2+
editor.render()
3+
14
window.activateStats()
25
edit.addEventListener('click', (e) ->
36
e.preventDefault()
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
stats.coffee
2-
mods.coffee
2+
mod.coffee

frontend/coffee/create.coffee frontend/coffee/mod_create.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
editor = new Editor()
1+
editor = new mdEditor({autoDownloadFontAwesome: false})
22
editor.render()
3-
dropzone = require('dropzone')
3+
dropzone = require('dropzone').Dropzone
44

55
error = (name) ->
66
document.getElementById(name).parentElement.classList.add('has-error')

frontend/coffee/mod_create.manifest

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod_create.coffee

frontend/coffee/edit_mod.coffee frontend/coffee/mod_edit.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
editor = new Editor()
1+
editor = new mdEditor({autoDownloadFontAwesome: false})
22
editor.render()
33

44
window.upload_bg = (files, box) ->

frontend/coffee/mod_edit.manifest

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod_edit.coffee

frontend/coffee/update.coffee frontend/coffee/mod_update.coffee

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
dropzone = require('dropzone')
1+
editor = new mdEditor({autoDownloadFontAwesome: false})
2+
editor.render()
3+
dropzone = require('dropzone').Dropzone
24

35
error = (name) ->
46
document.getElementById(name).parentElement.classList.add('has-error')

frontend/coffee/mod_update.manifest

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod_update.coffee
File renamed without changes.

frontend/coffee/pack_create.manifest

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pack_create.coffee

frontend/coffee/edit_pack.coffee frontend/coffee/pack_edit.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
editor = new Editor()
1+
editor = new mdEditor({autoDownloadFontAwesome: false})
22
editor.render()
33

44
window.upload_bg = (files, box) ->
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
typeahead.bundle.min.js
2-
edit_pack.coffee
2+
pack_edit.coffee

frontend/coffee/profile.manifest

-1
This file was deleted.

frontend/coffee/profile.coffee frontend/coffee/profile_edit.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
editor = new Editor()
1+
editor = new mdEditor({autoDownloadFontAwesome: false})
22
editor.render()
33

44
# Background Uploading

frontend/coffee/profile_edit.manifest

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
profile_edit.coffee

0 commit comments

Comments
 (0)