diff --git a/factoriocp.py b/factoriocp.py index d46c66a..f108ae3 100644 --- a/factoriocp.py +++ b/factoriocp.py @@ -41,11 +41,31 @@ def log_in(username, password): # get a list of server dicts def get_servers(): pass - return [{ "name": "Creative fun", "desc": "A creative vanilla server for tests.", "version": "0.14.20", "status": "online", "port": "34197" }, - { "name": "Vanilla on the rocks", "desc": "Vanilla map with some mods.", "version": "0.14.19", "status": "offline", "port": "34198" }, - { "name": "Mad enemies", "desc": "Hazardous map. A lot of enemies.", "version": "0.14.19", "status": "offline", "port": "34199" }, - { "name": "Online Map", "desc": "A modded map for friends.", "version": "0.14.19", "status": "online", "port": "34200" }, - { "name": "Mad enemies2", "desc": "Just a copy of Mad enemies.", "version": "0.14.20", "status": "offline", "port": "34201" }] + return [{ "name": "Creative fun", "desc": "A creative vanilla server for tests.", "version": "0.14.20", "status": "online", "port": "34197", "mods": [ "base", "" ] }, + { "name": "Vanilla on the rocks", "desc": "Vanilla map with some mods.", "version": "0.14.19", "status": "offline", "port": "34198", "mods": [ "base", "" ] }, + { "name": "Mad enemies", "desc": "Hazardous map. A lot of enemies.", "version": "0.14.19", "status": "offline", "port": "34199", "mods": [ "base", "Factorissimo", "long-reach" ] }, + { "name": "Online Map", "desc": "A modded map for friends.", "version": "0.14.19", "status": "online", "port": "34200", "mods": [ "base", "Factorissimo", "long-reach", "FactorioExtended-Extra", "FactorioExtended-Titan", "FactorioExtended-Military", "FactorioExtended-Core", "Factorissimo" ] }, + { "name": "Mad enemies2", "desc": "Just a copy of Mad enemies.", "version": "0.14.20", "status": "offline", "port": "34201", "mods": [ "base", ] }] + +# find a available port for new server +def find_port(): + ports = [ server['port'] for server in get_servers()] + for port in range(int(config['factorio']['port']),int(config['factorio']['port'])+9): + if str(port) not in ports: + return port + return False + + +# create new server +def create_server(name, desc, file): + + port = find_port() + if port: + #create server directory in factorio base path + #download and unzip factorio headless to this directory + install_headless(path) + + # routing @@ -63,6 +83,7 @@ def view_home(): username=username, servers=servers, app_name=config['DEFAULT']['app_name'], + fqdn=config['server']['fqdn'], message=message) else: # render login @@ -111,7 +132,7 @@ def send_static(filename): return static_file(filename, root=config['DEFAULT']['static_files']) # render server page -@get('/server/') +@get('/edit/') def view_server(port): username = logged_in() message = request.get_cookie(config['DEFAULT']['cookie_name'] + "_message", @@ -120,7 +141,7 @@ def view_server(port): servers = get_servers() server = [ server for server in servers if int(server['port']) == int(port) ] if server: - return template('server', + return template('edit', app_name=config['DEFAULT']['app_name'], server=server[0], username=username, @@ -141,7 +162,18 @@ def view_server(port): # create new server @get('/create') def create_server(): - pass + username = logged_in() + message = request.get_cookie(config['DEFAULT']['cookie_name'] + "_message", + secret=config['DEFAULT']['cookie_secret']) + if username: + return template('create', + app_name=config['DEFAULT']['app_name'], + username=username, + fqdn=config['server']['fqdn'], + message=message) + + else: + redirect("/") diff --git a/static/css/sticky-footer.css b/static/css/sticky-footer.css index 61f1fad..e11a9e5 100644 --- a/static/css/sticky-footer.css +++ b/static/css/sticky-footer.css @@ -11,7 +11,7 @@ body { a.nounderline { text-decoration: none; - color: dimgrey; + color: black; } .footer { diff --git a/views/create.tpl b/views/create.tpl new file mode 100644 index 0000000..15e2189 --- /dev/null +++ b/views/create.tpl @@ -0,0 +1,47 @@ +%include('header.tpl', app_name=app_name, message=message, page_name="Create server") + +
+ + +
+
+ +
+
+ + + This will be visible to clients. +
+
+ + + This will be visible to clients. +
+ +
+ + + You can import your own map by uploading a savegame(.zip) here. If left empty a new map will be generated. +
+
+
+
+
+ +
+
+ +
+ +
+
+
+ + +%include('footer.tpl', username=username, app_name=app_name) diff --git a/views/default.tpl b/views/default.tpl index 82127d1..0b4a386 100644 --- a/views/default.tpl +++ b/views/default.tpl @@ -1,113 +1,61 @@ -%include('header.tpl', app_name=app_name, message=message) - -
-
-
-

Server overview

-
-
-
- - -
-
-
-

Control your Factorio game servers from here.

- - +%include('header.tpl', app_name=app_name, message=message, page_name="Server overview") +
%for server in servers: + +
%end +
+ - -
-%include('footer.tpl', username=username) +%include('footer.tpl', username=username, app_name=app_name) diff --git a/views/server.tpl b/views/edit.tpl similarity index 59% rename from views/server.tpl rename to views/edit.tpl index a86fce6..33bcb11 100644 --- a/views/server.tpl +++ b/views/edit.tpl @@ -1,105 +1,98 @@ -%include('header.tpl', app_name=app_name, message=message) - -
-
-
-

Edit Server

-
-
-
- - -
-
-
-

Control your Factorio game server from here.

+%include('header.tpl', app_name=app_name, message=message, page_name="Edit server") + +
-

{{ server['desc'] }}

- - - - -
Address{{ fqdn }}:{{ server['port'] }}
Version{{ server['version'] }}
Status{{ server['status'] }}
-
-
-
-
- Start Stop +

{{ server['desc'] }}

+ + + + + +
Address:{{ fqdn }}:{{ server['port'] }}
Version:{{ server['version'] }}
Mods: + %for mod in server['mods']: + {{ mod }} + %end +
Admins:0bsidian0rder, Singso
+
+
+
+ %if server['status'] == "online": + Stop + %else: + Start + Delete + %end +
+
-
-
-
+
+ +
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. -
-
+ + +
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. -
-
+ +
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
-
- + - -%include('footer.tpl', username=username) + + +%include('footer.tpl', username=username, app_name=app_name) diff --git a/views/footer.tpl b/views/footer.tpl index 4689694..b33bf0d 100644 --- a/views/footer.tpl +++ b/views/footer.tpl @@ -1,3 +1,5 @@ + +
@@ -6,9 +8,7 @@
- - + diff --git a/views/header.tpl b/views/header.tpl index 75dabb8..9a236f6 100644 --- a/views/header.tpl +++ b/views/header.tpl @@ -18,6 +18,7 @@ +

@@ -29,3 +30,25 @@ %end

+ + +
+
+
+

{{ page_name }}

+
+
+
+ + +
+
+
+

Control your Factorio game servers from here.

diff --git a/views/login.tpl b/views/login.tpl index d8c4394..ebd1665 100644 --- a/views/login.tpl +++ b/views/login.tpl @@ -8,17 +8,15 @@ - {{ app_name }} + - - - +

@@ -30,6 +28,7 @@ %end

+
- - +