Skip to content

Commit

Permalink
Game Materials, update jquery, bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
eljeffeg committed Jun 18, 2018
1 parent 409a300 commit f4e0b85
Show file tree
Hide file tree
Showing 45 changed files with 10,162 additions and 24 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Expand Up @@ -4,16 +4,14 @@
# File uploads and what not
files/avatars/*-*
files/avatars/user/*-*
!files/avatars/user/README.md

files/avatars/team/*-*
!files/avatars/team/README.md
files/avatars/box/*-*
!files/avatars/box/README.md
files/avatars/upload/*-*
!files/avatars/upload/README.md
files/icons/*-*
files/shares/*-*
files/source_code_market/*-*
files/game_materials/*
files/*.db
files/*.cfg

Expand Down Expand Up @@ -64,3 +62,6 @@ __pycache__

# Backups
*.bak

# Readme
!*README.md
3 changes: 3 additions & 0 deletions files/game_materials/README.md
@@ -0,0 +1,3 @@
Game Materials
=============
Location for you to drop game materials that the player can use in the game - such as documents, files, applications, forensic images, etc.
80 changes: 80 additions & 0 deletions handlers/MaterialsHandler.py
@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-
'''
Created on Jun 18, 2018
@author: eljefe
Copyright 2018 Root the Box
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''

import os
import json

from handlers.BaseHandlers import BaseHandler
from libs.SecurityDecorators import authenticated
from tornado.options import options

class MaterialsHandler(BaseHandler):

@authenticated
def get(self, *args, **kwargs):
r=['<ul class="jqueryFileTree" style="display: none;">']
try:
r=['<ul class="jqueryFileTree" style="display: none;">']
d=options.game_materials_dir
for f in os.listdir(d):
ff=os.path.join(d,f)
if os.path.isdir(ff):
r.append('<li class="directory collapsed"><a rel="%s/">%s</a></li>' % (ff,f))
else:
if f == "README.md":
continue
e=os.path.splitext(f)[1][1:] # get .ext and remove dot
r.append('<li class="file ext_%s"><a rel="%s">%s</a></li>' % (e,ff,f))
r.append('</ul>')
except Exception,e:
r.append('Could not load directory: %s' % str(e))
r.append('</ul>')
dirlisting = ''.join(r)
self.render('file_upload/material_files.html', tree=json.dumps([self.path_to_dict(d)]), errors=None)

@authenticated
def post(self, *args, **kwargs):
d=options.game_materials_dir
self.write(json.dumps(self.path_to_dict(d)))

def path_to_dict(self, path):
d = {'text': os.path.basename(path)}
if os.path.isdir(path):
d['type'] = "directory"
d['children'] = [self.path_to_dict(os.path.join(path,x)) for x in os.listdir(path)]
else:
d['type'] = "file"
d['a_attr'] = { "href" : "/materials/%s" % os.path.basename(path), "onclick":"window.location='/materials/%s'" % os.path.basename(path)}
e=os.path.splitext(path)[1][1:] # get .ext and remove dot
d['icon'] = "file ext_%s" % (e)
return d


def has_materials():
d=options.game_materials_dir
i = 0
for f in os.listdir(d):
if f == "README.md":
continue
else:
i += 1
return i > 0
6 changes: 6 additions & 0 deletions handlers/__init__.py
Expand Up @@ -50,6 +50,7 @@
from handlers.ScoreboardHandlers import *
from handlers.FileUploadHandlers import *
from handlers.NotificationHandlers import *
from handlers.MaterialsHandler import *
from handlers.StaticFileHandler import StaticFileHandler
from tornado.options import options

Expand Down Expand Up @@ -145,6 +146,11 @@ def get_cookie_secret():
StaticFileHandler, {'path': 'static/'}),
(r'/avatars/(.*\.(png|jpeg|jpg|gif|bmp))',
StaticFileHandler, {'path': 'files/avatars/'}),
(r'/materials/(.*)',
StaticFileHandler, {'path': 'files/game_materials/'}),

# Game Materials
(r'/materials', MaterialsHandler),

# Admin Handlers
(r'/admin/game', AdminGameHandler),
Expand Down
5 changes: 5 additions & 0 deletions rootthebox.py
Expand Up @@ -218,6 +218,11 @@ def check_cwd():
group="application",
help="the directory to store souce code market files")

define("game_materials_dir",
default="./files/game_materials",
group="application",
help="the directory to store applications, docs, and other materials for the game")

# ReCAPTCHA
define("use_recaptcha",
default=True,
Expand Down
2 changes: 1 addition & 1 deletion setup/0.7.0-dbupdate.sql
Expand Up @@ -49,4 +49,4 @@ ALTER TABLE `rootthebox`.`game_level`
ADD COLUMN `_type` VARCHAR(10) NOT NULL DEFAULT 'buyout' AFTER `_buyout`;

ALTER TABLE `rootthebox`.`game_level`
ADD COLUMN `_reward` int(11) NOT NULL DEFAULT '0',
ADD COLUMN `_reward` int(11) NOT NULL DEFAULT '0';
93 changes: 81 additions & 12 deletions static/css/bootstrap-responsive.css
@@ -1,11 +1,11 @@
/*!
* Bootstrap Responsive v2.1.0
* Bootstrap Responsive v2.3.2
*
* Copyright 2012 Twitter, Inc
* Copyright 2013 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
* Designed and built with all the love in the world by @mdo and @fat.
*/

.clearfix {
Expand Down Expand Up @@ -40,6 +40,10 @@
box-sizing: border-box;
}

@-ms-viewport {
width: device-width;
}

.hidden {
display: none;
visibility: hidden;
Expand Down Expand Up @@ -91,6 +95,19 @@
}
}

.visible-print {
display: none !important;
}

@media print {
.visible-print {
display: inherit !important;
}
.hidden-print {
display: none !important;
}
}

@media (min-width: 1200px) {
.row {
margin-left: -30px;
Expand All @@ -107,6 +124,7 @@
}
[class*="span"] {
float: left;
min-height: 1px;
margin-left: 30px;
}
.container,
Expand Down Expand Up @@ -214,6 +232,9 @@
.row-fluid [class*="span"]:first-child {
margin-left: 0;
}
.row-fluid .controls-row [class*="span"] + [class*="span"] {
margin-left: 2.564102564102564%;
}
.row-fluid .span12 {
width: 100%;
*width: 99.94680851063829%;
Expand Down Expand Up @@ -453,6 +474,7 @@
}
[class*="span"] {
float: left;
min-height: 1px;
margin-left: 20px;
}
.container,
Expand Down Expand Up @@ -560,6 +582,9 @@
.row-fluid [class*="span"]:first-child {
margin-left: 0;
}
.row-fluid .controls-row [class*="span"] + [class*="span"] {
margin-left: 2.7624309392265194%;
}
.row-fluid .span12 {
width: 100%;
*width: 99.94680851063829%;
Expand Down Expand Up @@ -780,7 +805,8 @@
padding-left: 20px;
}
.navbar-fixed-top,
.navbar-fixed-bottom {
.navbar-fixed-bottom,
.navbar-static-top {
margin-right: -20px;
margin-left: -20px;
}
Expand Down Expand Up @@ -811,11 +837,15 @@
margin-left: 0;
}
[class*="span"],
.uneditable-input[class*="span"],
.row-fluid [class*="span"] {
display: block;
float: none;
width: auto;
width: 100%;
margin-left: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.span12,
.row-fluid .span12 {
Expand All @@ -824,6 +854,9 @@
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.row-fluid [class*="offset"]:first-child {
margin-left: 0;
}
.input-large,
.input-xlarge,
.input-xxlarge,
Expand All @@ -845,6 +878,9 @@
display: inline-block;
width: auto;
}
.controls-row [class*="span"] + [class*="span"] {
margin-left: 0;
}
.modal {
position: fixed;
top: 20px;
Expand All @@ -853,8 +889,11 @@
width: auto;
margin: 0;
}
.modal.fade {
top: -100px;
}
.modal.fade.in {
top: auto;
top: 20px;
}
}

Expand All @@ -870,7 +909,7 @@
input[type="radio"] {
border: 1px solid #ccc;
}
.form-horizontal .control-group > label {
.form-horizontal .control-label {
float: none;
width: auto;
padding-top: 0;
Expand All @@ -886,6 +925,16 @@
padding-right: 10px;
padding-left: 10px;
}
.media .pull-left,
.media .pull-right {
display: block;
float: none;
margin-bottom: 10px;
}
.media-object {
margin-right: 0;
margin-left: 0;
}
.modal {
top: 10px;
right: 10px;
Expand Down Expand Up @@ -944,14 +993,14 @@
display: none;
}
.nav-collapse .nav .nav-header {
color: #555555;
color: #777777;
text-shadow: none;
}
.nav-collapse .nav > li > a,
.nav-collapse .dropdown-menu a {
padding: 9px 15px;
font-weight: bold;
color: #555555;
color: #777777;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
Expand All @@ -967,11 +1016,19 @@
margin-bottom: 2px;
}
.nav-collapse .nav > li > a:hover,
.nav-collapse .dropdown-menu a:hover {
.nav-collapse .nav > li > a:focus,
.nav-collapse .dropdown-menu a:hover,
.nav-collapse .dropdown-menu a:focus {
background-color: #f2f2f2;
}
.navbar-inverse .nav-collapse .nav > li > a,
.navbar-inverse .nav-collapse .dropdown-menu a {
color: #999999;
}
.navbar-inverse .nav-collapse .nav > li > a:hover,
.navbar-inverse .nav-collapse .dropdown-menu a:hover {
.navbar-inverse .nav-collapse .nav > li > a:focus,
.navbar-inverse .nav-collapse .dropdown-menu a:hover,
.navbar-inverse .nav-collapse .dropdown-menu a:focus {
background-color: #111111;
}
.nav-collapse.in .btn-group {
Expand All @@ -982,7 +1039,7 @@
position: static;
top: auto;
left: auto;
display: block;
display: none;
float: none;
max-width: none;
padding: 0;
Expand All @@ -996,13 +1053,20 @@
-moz-box-shadow: none;
box-shadow: none;
}
.nav-collapse .open > .dropdown-menu {
display: block;
}
.nav-collapse .dropdown-menu:before,
.nav-collapse .dropdown-menu:after {
display: none;
}
.nav-collapse .dropdown-menu .divider {
display: none;
}
.nav-collapse .nav > li > .dropdown-menu:before,
.nav-collapse .nav > li > .dropdown-menu:after {
display: none;
}
.nav-collapse .navbar-form,
.nav-collapse .navbar-search {
float: none;
Expand All @@ -1014,6 +1078,11 @@
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-inverse .nav-collapse .navbar-form,
.navbar-inverse .nav-collapse .navbar-search {
border-top-color: #111111;
border-bottom-color: #111111;
}
.navbar .nav-collapse .nav.pull-right {
float: none;
margin-left: 0;
Expand Down
Binary file added static/css/images/32px.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/40px.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/application.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/code.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/css.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/db.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/directory-lock.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/directory.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/doc.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/file-lock.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/file.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/film.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/flash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/folder_open.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/html.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/java.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/linux.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/music.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/pdf.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/php.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/picture.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/ppt.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/psd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/ruby.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/script.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/css/images/spinner.gif
Binary file added static/css/images/throbber.gif
Binary file added static/css/images/txt.png
Binary file added static/css/images/xls.png
Binary file added static/css/images/zip.png
Binary file modified static/css/img/glyphicons-halflings.png

0 comments on commit f4e0b85

Please sign in to comment.