Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nav for switching between trashmaps #3

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ daemon_data.json
daemon_storage.json
daemon_log.txt
*.swp
*.css.map
*.sass-cache/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DDNet Trashmap
[DDNet Trashmap](https://trashmap.timakro.de/) is a service for mappers who can't host their own server.
[DDNet Trashmap](http://trashmap.ddnet.tw/) is a service for mappers who can't host their own server.
You can create a testing server here and test your map alone or with other players.

## Development
Expand Down
4 changes: 2 additions & 2 deletions srv/daemon_control.py → daemon_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
DELETE_RCON = 14

def getdata():
data = json.load(open("/srv/trashmap/daemon_data.json"))
data = json.load(open("/srv/trashmap/srv/daemon_data.json"))
return data

def writefifo(order):
line = json.dumps(order) + "\n"
with open("/srv/trashmap/daemon_input.fifo", "w") as fifo:
with open("/srv/trashmap/srv/daemon_input.fifo", "w") as fifo:
fifo.write(line)

print("Welcome to daemon control, enter 'help' to get a list of commands.")
Expand Down
1 change: 1 addition & 0 deletions sass/_master.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $shade1: #e3e3e3;

$text1-0: #555;
$accent1: #378A54;
$accent1-fade: lighten(desaturate($accent1, 20%), 10%);
$link1: #37798A;
$error1: #8a3737;
$warning1: #935E22;
56 changes: 53 additions & 3 deletions sass/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,22 @@ body {

.breadcrumbs {
background-color: $shade0;
padding: 5px 0px 5px 20px;
padding-left: 20px;
border-bottom: 1px solid darken($shade1, 10%);
font-size: 16px;
position: relative;
.separator {
padding-top: 5px;
padding-bottom: 5px;
position: relative;
top: -2px;
margin-right: 10px;
height: 1em;
vertical-align: middle;
}
.crumb {
padding-top: 5px;
padding-bottom: 5px;
margin-right: 10px;
color: darken($shade1, 40%);
font-family: $headerFS;
Expand All @@ -252,6 +257,34 @@ body {
font-weight: 500;
}
}
.locality_tab {
position: absolute;
height: 100%;
right: 0;
background-color: $accent1-fade;
border-bottom: 1px solid $accent1-fade;
box-sizing: content-box;
display: inline-block;
padding: 0 20px 0 20px;
&:hover {
cursor: pointer;
}
.locality {
padding-top: 5px;
padding-bottom: 5px;
display: inline-block;
color: $shade0;
font-size: 16px;
}
.dropdown {
position: relative;
top: -3px;
display: inline-block;
font-size: 16px;
height: 0.8em;
vertical-align: middle;
}
}
}

.tingle-modal {
Expand Down Expand Up @@ -310,6 +343,23 @@ body {
}
}
}
.trashmap_locations_header {
border-bottom: 2px solid $accent1;
padding-bottom: 8px;
}
ul.trashmap_locations {
list-style-type: none;
background-color: desaturate(lighten($accent1, 40%), 10%);
margin-top: 0;
margin-left: 0;
padding: 20px;
li a {
color: darken($accent1, 5%);
&:hover {
color: darken($accent1, 20%);
}
}
}
}


Expand All @@ -332,7 +382,7 @@ body {
background-color: $shade0;
}
&.page_branding {
background-color: lighten(desaturate($accent1, 20%), 10%);
background-color: $accent1-fade;
.page_title {
color: $shade0;
display: inline-block;
Expand All @@ -349,7 +399,7 @@ body {
}
}
&.site_branding {
background-color: lighten(desaturate($accent1, 20%), 10%);
background-color: $accent1-fade;
padding-top: 60px;
padding-bottom: 60px;
overflow: hidden;
Expand Down
14 changes: 9 additions & 5 deletions srv/daemon_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "DDNet South Africa Trashmap",
"ip": "zaf.ddnet.tw",
"name": "DDNet GER Trashmap",
"locality" : "GER",
"ip": "trashmap.ddnet.tw",
"maxservers": 300,
"maxserversperip": 2,
"maxrunningservers": 10,
Expand All @@ -9,8 +10,8 @@
"joinminutes": 5,
"stophours": 8,
"deletedays": 30,
"mapsizehuman": "2MB",
"mapsize": 2097152,
"mapsizehuman": "5MB",
"mapsize": 5242880,
"minplayers": 1,
"maxplayers": 16,
"defaultplayers": 8,
Expand All @@ -20,5 +21,8 @@
"maxlengthpassword": 25,
"maxlengthrconcommand": 25,
"maxlengthrcon": 25,
"bannedips": []
"bannedips": [],
"othertrashmaps" : [
{ "name":"DDNet ZAF Trashmap", "locality":"ZAF", "ip":"zaf.ddnet.tw" },
]
}
47 changes: 47 additions & 0 deletions srv/daemon_storage.json.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"suggested_rcon": [],
"allowed_rcon": [
"up",
"down",
"right",
"left",
"super",
"unsuper",
"totele",
"totelecp",
"addweapon",
"removeweapon",
"tune",
"tune_reset",
"tune_dump",
"tune_zone",
"tune_zone_enter",
"tune_zone_leave",
"tune_zone_reset",
"tune_zone_dump",
"logout",
"status",
"tele",
"kick",
"ban",
"bans",
"unban",
"unban_all",
"ban_range",
"unban_range",
"undeep",
"unsolo",
"shotgun",
"grenade",
"ninja",
"rifle",
"unshotgun",
"ungrenade",
"unrifle",
"jetpack",
"unjetpack",
"move",
"move_raw"
],
"servers": {}
}
2 changes: 0 additions & 2 deletions srv/init.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
sv_welcome Welcome to DDNet South Africa Trashmap! Information at trashmap.timakro.de

sv_input_fifo fifo

sv_inactivekick_time 0
Expand Down
11 changes: 11 additions & 0 deletions systemd/user/trashmap.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=DDNet Trashmap

[Service]
Type=simple
ExecStart=/srv/trashmap/trashmap.py
ExecReload=/bin/kill -USR1 $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion trashmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def startserver(identifier):
if info["password"]:
commands.append(buildcommand("password", info["password"]))
commands.append(buildcommand("exec", "banlist.cfg"))
commands.append(buildcommand("sv_welcome", "Welcome to {}! Visit trashmap.ddnet.tw".format(data["config"]["name"])))
commands.append(buildcommand("exec", "/srv/trashmap/srv/init.cfg"))
for rcon in data["storage"]["allowed_rcon"]:
commands.append(buildcommand("access_level", rcon, 2))
Expand Down Expand Up @@ -459,7 +460,7 @@ def main():
# sleep for a tick
delta = next_run - time.time()
if delta < 0:
log("Skipped {0} ticks".format(delta / -data["config"]["tickseconds"]), warning=True)
log("Skipped {} ticks".format(delta / -data["config"]["tickseconds"]), warning=True)
else:
time.sleep(delta)

Expand Down
6 changes: 6 additions & 0 deletions www/access_server.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
<div class="crumb">
Access Server
</div>
<div class="locality_tab">
<h4 class="locality">
<?php echo $config["locality"]?>
</h4>
<img class="dropdown" src="includes/dropdown.svg">
</div>
</div>

<div class="main">
Expand Down
1 change: 0 additions & 1 deletion www/access_server_handle.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
} elseif($_POST["action"] == "map") {
$mapfile = tempnam("/srv/trashmap/upload", "");
move_uploaded_file($_FILES["map"]["tmp_name"], $mapfile);
chmod($mapfile, 0666);
file_put_contents("/srv/trashmap/srv/daemon_input.fifo", json_encode(
["type" => $CHANGE_MAP,
"identifier" => $identifier,
Expand Down
6 changes: 6 additions & 0 deletions www/create_server.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<div class="crumb">
Create Server
</div>
<div class="locality_tab">
<h4 class="locality">
<?php echo $config["locality"]?>
</h4>
<img class="dropdown" src="includes/dropdown.svg">
</div>
</div>

<div class="main">
Expand Down
1 change: 0 additions & 1 deletion www/create_server_handle.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
$link = "access_server.php?".http_build_query(["id" => $identifier, "key" => $raw_accesskey]);
$mapfile = tempnam("/srv/trashmap/upload", "");
move_uploaded_file($_FILES["map"]["tmp_name"], $mapfile);
chmod($mapfile, 0666);
file_put_contents("/srv/trashmap/srv/daemon_input.fifo", json_encode(
["type" => $CREATE_SERVER,
"identifier" => $identifier,
Expand Down
28 changes: 28 additions & 0 deletions www/daemon_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "DDNet GER Trashmap",
"locality" : "GER",
"ip": "trashmap.ddnet.tw",
"maxservers": 300,
"maxserversperip": 2,
"maxrunningservers": 10,
"tickseconds": 1,
"titleupdateseconds": 10,
"joinminutes": 5,
"stophours": 8,
"deletedays": 30,
"mapsizehuman": "5MB",
"mapsize": 5242880,
"minplayers": 1,
"maxplayers": 16,
"defaultplayers": 8,
"defaultrcon": "trashmap",
"maxlengthlabel": 25,
"maxlengthaccesskey": 25,
"maxlengthpassword": 25,
"maxlengthrconcommand": 25,
"maxlengthrcon": 25,
"bannedips": [],
"othertrashmaps" : [
{ "name":"DDNet ZAF Trashmap", "locality":"ZAF", "ip":"zaf.ddnet.tw" },
]
}
4 changes: 2 additions & 2 deletions www/includes/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var breadcrumbs = (function (public) {
var initialLength = breadcrumbsBar.children.length;
var crumbs = [];
for (var i = 1; i < initialLength; i++) {
crumbs.push(breadcrumbsBar.children[i]);
// console.log(breadcrumbsBar.children[i]);
if (!breadcrumbsBar.children[i].classList.contains("locality_tab"))
crumbs.push(breadcrumbsBar.children[i]);
}
for (var j = 0; j < crumbs.length; j++) {
var separator = document.createElement("IMG");
Expand Down
29 changes: 29 additions & 0 deletions www/includes/dropdown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions www/includes/head.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
<script src="includes/breadcrumbs.js"></script>
<script src="includes/fileUpload.js"></script>
<script src="includes/start.js"></script>
<script src="includes/localizeNav.js"></script>
8 changes: 8 additions & 0 deletions www/includes/localityModal.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="locality_modal" style="display:none;">
<h2 class="trashmap_locations_header">Other Trashmap Locations</h2>
<ul class="trashmap_locations">
<?php foreach ($config['othertrashmaps'] as $othertrashmaps): ?>
<li><a href="http://<?php echo $othertrashmaps['ip'];?>"><?php echo $othertrashmaps['name'];?></a></li>
<?php endforeach; ?>
</ul>
</div>
Loading