Browse Source

refactored folder layout

added worlds folder, moved images to chunkymapdata/images and added
compass-rose.png (not used yet)
master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
05cc9fcd90
  1. 58
      chunkymap-regen.py
  2. BIN
      etc/compass-rose.xcf
  3. 23
      web/chunkymap.php
  4. BIN
      web/chunkymapdata_default/images/compass-rose.png
  5. 0
      web/chunkymapdata_default/images/start.png
  6. 0
      web/chunkymapdata_default/images/target.png
  7. 0
      web/chunkymapdata_default/images/target_start.png
  8. 0
      web/chunkymapdata_default/images/zoom-in.png
  9. 0
      web/chunkymapdata_default/images/zoom-in_disabled.png
  10. 0
      web/chunkymapdata_default/images/zoom-out.png
  11. 0
      web/chunkymapdata_default/images/zoom-out_disabled.png
  12. 4
      web/chunkymapdata_default/markers/chunk_markers_x0z0.yml
  13. 4
      web/chunkymapdata_default/world/markers/0.yml
  14. 0
      web/chunkymapdata_default/world/players/singleplayer.png

58
chunkymap-regen.py

@ -331,6 +331,7 @@ class MTChunk:
class MTChunks: class MTChunks:
chunkymap_data_path = None chunkymap_data_path = None
chunkymapdata_worlds_path = None
is_save_output_ok = None is_save_output_ok = None
minetestmapper_fast_sqlite_path = None minetestmapper_fast_sqlite_path = None
minetestmapper_custom_path = None minetestmapper_custom_path = None
@ -575,6 +576,7 @@ class MTChunks:
sys.exit() sys.exit()
self.chunkymap_data_path=os.path.join(self.config["www_minetest_path"],"chunkymapdata") self.chunkymap_data_path=os.path.join(self.config["www_minetest_path"],"chunkymapdata")
self.chunkymapdata_worlds_path=os.path.join(self.chunkymap_data_path, "worlds")
print("Using chunkymap_data_path '"+self.chunkymap_data_path+"'") print("Using chunkymap_data_path '"+self.chunkymap_data_path+"'")
#if not os.path.isdir(self.chunkymap_data_path): #if not os.path.isdir(self.chunkymap_data_path):
# os.mkdir(self.chunkymap_data_path) # os.mkdir(self.chunkymap_data_path)
@ -586,8 +588,18 @@ class MTChunks:
self.deny_http_access(self.chunkymap_data_path) self.deny_http_access(self.chunkymap_data_path)
print(" (created .htaccess)") print(" (created .htaccess)")
htaccess_path = os.path.join(self.chunkymapdata_worlds_path,".htaccess")
if not os.path.isdir(self.chunkymapdata_worlds_path):
os.makedirs(self.chunkymapdata_worlds_path)
print("Created '"+self.chunkymapdata_worlds_path+"'")
if not os.path.isfile(htaccess_path):
self.deny_http_access(self.chunkymapdata_worlds_path)
print(" (created .htaccess)")
self.world_name = os.path.basename(self.config["world_path"]) self.world_name = os.path.basename(self.config["world_path"])
self.chunkymap_thisworld_data_path = os.path.join(self.chunkymap_data_path, self.world_name) self.chunkymap_thisworld_data_path = os.path.join(self.chunkymapdata_worlds_path, self.world_name)
if not os.path.isdir(self.chunkymap_thisworld_data_path): if not os.path.isdir(self.chunkymap_thisworld_data_path):
os.makedirs(self.chunkymap_thisworld_data_path) os.makedirs(self.chunkymap_thisworld_data_path)
print("Created '"+self.chunkymap_thisworld_data_path+"'") print("Created '"+self.chunkymap_thisworld_data_path+"'")
@ -614,7 +626,7 @@ class MTChunks:
#TODO: deny recursively under these folders? doesn't seem that important for security so maybe not (no player info is there) #TODO: deny recursively under these folders? doesn't seem that important for security so maybe not (no player info is there)
self.install_website() self.install_default_world_data()
self.chunkymap_players_name = "players" self.chunkymap_players_name = "players"
self.chunkymap_players_path = os.path.join(self.chunkymap_thisworld_data_path, self.chunkymap_players_name) self.chunkymap_players_path = os.path.join(self.chunkymap_thisworld_data_path, self.chunkymap_players_name)
@ -683,22 +695,34 @@ class MTChunks:
if is_config_changed: if is_config_changed:
self.save_config() self.save_config()
def install_website(self): #def install_default_world_data(self):
this_source_dir_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "web") #source_web_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "web")
this_dest_dir_path = self.config["www_minetest_path"] #dest_web_chunkymapdata_world_path = self.chunkymap_thisworld_data_path
#dest_web_chunkymapdata_world_players_path = os.path.join(self.chunkymap_thisworld_data_path, "players")
#install_list.append(InstalledFile("singleplayer.png", source_chunkymapdata_players, dest_chunkymapdata_players))
#formerly install_website
def install_default_world_data(self):
source_web_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "web")
source_web_chunkymapdata_path = os.path.join(source_web_path, "chunkymapdata_default")
source_web_chunkymapdata_world_path = os.path.join(source_web_chunkymapdata_path, "world")
source_web_chunkymapdata_images_path = os.path.join(source_web_chunkymapdata_path, "images")
dest_web_path = self.config["www_minetest_path"]
dest_web_chunkymapdata_path = os.path.join(self.config["www_minetest_path"],"chunkymapdata")
dest_web_chunkymapdata_images_path = os.path.join(dest_web_chunkymapdata_path,"images")
install_list = list() install_list = list()
install_list.append(InstalledFile("browser.php",this_source_dir_path,this_dest_dir_path)) install_list.append(InstalledFile("browser.php",source_web_path,dest_web_path))
install_list.append(InstalledFile("chunkymap.php",this_source_dir_path,this_dest_dir_path)) install_list.append(InstalledFile("chunkymap.php",source_web_path,dest_web_path))
install_list.append(InstalledFile("example.php",this_source_dir_path,this_dest_dir_path)) install_list.append(InstalledFile("example.php",source_web_path,dest_web_path))
source_web_images_path = os.path.join( os.path.join(os.path.dirname(os.path.abspath(self.minetestmapper_py_path)), "web"), "images") install_list.append(InstalledFile("zoom-in.png", source_web_chunkymapdata_images_path, dest_web_chunkymapdata_images_path))
dest_web_images_path = os.path.join( self.config["www_minetest_path"], "images") install_list.append(InstalledFile("zoom-out.png", source_web_chunkymapdata_images_path, dest_web_chunkymapdata_images_path))
install_list.append(InstalledFile("chunkymap_zoom-in.png", source_web_images_path, dest_web_images_path)) install_list.append(InstalledFile("zoom-in_disabled.png", source_web_chunkymapdata_images_path, dest_web_chunkymapdata_images_path))
install_list.append(InstalledFile("chunkymap_zoom-out.png", source_web_images_path, dest_web_images_path)) install_list.append(InstalledFile("zoom-out_disabled.png", source_web_chunkymapdata_images_path, dest_web_chunkymapdata_images_path))
install_list.append(InstalledFile("chunkymap_zoom-in_disabled.png", source_web_images_path, dest_web_images_path)) install_list.append(InstalledFile("start.png", source_web_chunkymapdata_images_path, dest_web_chunkymapdata_images_path))
install_list.append(InstalledFile("chunkymap_zoom-out_disabled.png", source_web_images_path, dest_web_images_path)) install_list.append(InstalledFile("target_start.png", source_web_chunkymapdata_images_path, dest_web_chunkymapdata_images_path))
install_list.append(InstalledFile("chunkymap_start.png", source_web_images_path, dest_web_images_path)) install_list.append(InstalledFile("compass-rose.png", source_web_chunkymapdata_images_path, dest_web_chunkymapdata_images_path))
source_chunkymapdata = os.path.join( os.path.join(os.path.dirname(os.path.abspath(self.minetestmapper_py_path)), "web"), "chunkymapdata_default") source_chunkymapdata_players = os.path.join(source_web_chunkymapdata_world_path, "players")
source_chunkymapdata_players = os.path.join(source_chunkymapdata, "players")
dest_chunkymapdata_players = os.path.join(self.chunkymap_thisworld_data_path, "players") dest_chunkymapdata_players = os.path.join(self.chunkymap_thisworld_data_path, "players")
install_list.append(InstalledFile("singleplayer.png", source_chunkymapdata_players, dest_chunkymapdata_players)) install_list.append(InstalledFile("singleplayer.png", source_chunkymapdata_players, dest_chunkymapdata_players))
for this_object in install_list: for this_object in install_list:

BIN
etc/compass-rose.xcf

Binary file not shown.

23
web/chunkymap.php

@ -37,8 +37,8 @@ if (!isset($chunkymap_view_zoom_multiplier)) {
$chunkymap_view_zoom_multiplier=.25; $chunkymap_view_zoom_multiplier=.25;
} }
// OPTIONAL:
$chunkymapdata_path = "chunkymapdata"; $chunkymapdata_path = "chunkymapdata";
$chunkymapdata_worlds_path = $chunkymapdata_path."/worlds";
$chunkymapdata_thisworld_path = null; $chunkymapdata_thisworld_path = null;
$showplayers=true; $showplayers=true;
@ -137,8 +137,8 @@ function echo_chunkymap_controls($callback_php_path) {
global $chunkymap_anchor_name; global $chunkymap_anchor_name;
$is_in=false; $is_in=false;
$is_out=false; $is_out=false;
$in_img_name = "chunkymap_zoom-in.png"; $in_img_name = "zoom-in.png";
$out_img_name = "chunkymap_zoom-out.png"; $out_img_name = "zoom-out.png";
$in_zoom = $chunkymap_view_zoom_multiplier; $in_zoom = $chunkymap_view_zoom_multiplier;
if ($in_zoom<$chunkymap_view_zoom_max) { if ($in_zoom<$chunkymap_view_zoom_max) {
@ -146,14 +146,14 @@ function echo_chunkymap_controls($callback_php_path) {
$in_zoom = $chunkymap_view_zoom_multiplier*2.0; $in_zoom = $chunkymap_view_zoom_multiplier*2.0;
//echo "in:$in_zoom "; //echo "in:$in_zoom ";
} }
else $in_img_name = "chunkymap_zoom-in_disabled.png"; else $in_img_name = "zoom-in_disabled.png";
$out_zoom = $chunkymap_view_zoom_multiplier; $out_zoom = $chunkymap_view_zoom_multiplier;
if ($out_zoom>$chunkymap_view_zoom_min) { if ($out_zoom>$chunkymap_view_zoom_min) {
$is_out=true; $is_out=true;
$out_zoom = ($chunkymap_view_zoom_multiplier/2.0); $out_zoom = ($chunkymap_view_zoom_multiplier/2.0);
} }
else $out_img_name = "chunkymap_zoom-out_disabled.png"; else $out_img_name = "zoom-out_disabled.png";
$zoom_clip = $chunkymap_view_zoom_max; $zoom_clip = $chunkymap_view_zoom_max;
$found=false; $found=false;
@ -206,8 +206,8 @@ function echo_chunkymap_controls($callback_php_path) {
} }
if (!$found) $in_zoom=$chunkymap_view_zoom_max; if (!$found) $in_zoom=$chunkymap_view_zoom_max;
$in_html="<img src=\"images/$in_img_name\" style=\"width:16pt; height:16pt\" />"; $in_html="<img src=\"chunkymapdata/images/$in_img_name\" style=\"width:16pt; height:16pt\" />";
$out_html="<img src=\"images/$out_img_name\" style=\"width:16pt; height:16pt\" />"; $out_html="<img src=\"chunkymapdata/images/$out_img_name\" style=\"width:16pt; height:16pt\" />";
global $world_name; global $world_name;
$append_vars="&"; $append_vars="&";
if (isset($world_name)) { if (isset($world_name)) {
@ -287,6 +287,7 @@ function echo_entire_chunkymap_as_chunk_table() {
global $chunkymap_view_zoom_max; global $chunkymap_view_zoom_max;
global $chunkymap_view_zoom_min; global $chunkymap_view_zoom_min;
global $chunkymapdata_path; global $chunkymapdata_path;
global $chunkymapdata_worlds_path;
global $map_dict; global $map_dict;
global $is_verbose; global $is_verbose;
global $chunkymap_tile_original_w; global $chunkymap_tile_original_w;
@ -313,7 +314,7 @@ function echo_entire_chunkymap_as_chunk_table() {
$character_icon_h=8; $character_icon_h=8;
global $chunkymapdata_thisworld_path; global $chunkymapdata_thisworld_path;
if (isset($world_name)) { if (isset($world_name)) {
$chunkymapdata_thisworld_path = $chunkymapdata_path."/".$world_name; $chunkymapdata_thisworld_path = $chunkymapdata_worlds_path."/".$world_name;
$generated_yml_path = $chunkymapdata_thisworld_path."/generated.yml"; $generated_yml_path = $chunkymapdata_thisworld_path."/generated.yml";
if (is_file($generated_yml_path)) { if (is_file($generated_yml_path)) {
$map_dict = get_dict_from_conf($generated_yml_path,":"); $map_dict = get_dict_from_conf($generated_yml_path,":");
@ -630,7 +631,7 @@ function echo_entire_chunkymap_as_chunk_table() {
$img_style.="opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below $img_style.="opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below
$text_style="color:white; opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below $text_style="color:white; opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below
} }
echo_hold( "<div style=\"position:absolute; z-index:999; left:$rel_x; top:$rel_z; width: $zoomed_head_w; height: $zoomed_head_h; $img_border_style\"><img src=\"chunkymapdata/players/singleplayer.png\" style=\"$img_style\"/><span style=\"$text_style\">$player_name</span></div>" ); echo_hold( "<div style=\"position:absolute; z-index:999; left:$rel_x; top:$rel_z; width: $zoomed_head_w; height: $zoomed_head_h; $img_border_style\"><img src=\"$chunkymapdata_thisworld_path/players/singleplayer.png\" style=\"$img_style\"/><span style=\"$text_style\">$player_name</span></div>" );
} }
//$position_offset_x+=$character_icon_w; //$position_offset_x+=$character_icon_w;
} }
@ -653,7 +654,7 @@ function echo_entire_chunkymap_as_chunk_table() {
else { //not isset($world_name) else { //not isset($world_name)
echo "<h4>Choose world:</h4>"; echo "<h4>Choose world:</h4>";
echo "<ul>"; echo "<ul>";
if ($chunkymapdata_handle = opendir($chunkymapdata_path)) { if ($chunkymapdata_handle = opendir($chunkymapdata_worlds_path)) {
$append_vars="&"; $append_vars="&";
if (isset($chunkymap_view_zoom_multiplier)) { if (isset($chunkymap_view_zoom_multiplier)) {
$prefix = ""; $prefix = "";
@ -672,7 +673,7 @@ function echo_entire_chunkymap_as_chunk_table() {
global $chunkymap_anchor_name; global $chunkymap_anchor_name;
while (false !== ($this_world_name = readdir($chunkymapdata_handle))) { while (false !== ($this_world_name = readdir($chunkymapdata_handle))) {
if (substr($this_world_name, 0, 1) != ".") { if (substr($this_world_name, 0, 1) != ".") {
$this_world_path = $chunkymapdata_path."/".$this_world_name; $this_world_path = $chunkymapdata_worlds_path."/".$this_world_name;
echo "<li><a href=\"?world_name=$this_world_name"."$append_vars#$chunkymap_anchor_name"."\">$this_world_name</a></li>"; echo "<li><a href=\"?world_name=$this_world_name"."$append_vars#$chunkymap_anchor_name"."\">$this_world_name</a></li>";
} }
} }

BIN
web/chunkymapdata_default/images/compass-rose.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

0
web/images/chunkymap_start.png → web/chunkymapdata_default/images/start.png

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 563 B

0
web/images/chunkymap_target.png → web/chunkymapdata_default/images/target.png

Before

Width:  |  Height:  |  Size: 467 B

After

Width:  |  Height:  |  Size: 467 B

0
web/images/chunkymap_target_start.png → web/chunkymapdata_default/images/target_start.png

Before

Width:  |  Height:  |  Size: 530 B

After

Width:  |  Height:  |  Size: 530 B

0
web/images/chunkymap_zoom-in.png → web/chunkymapdata_default/images/zoom-in.png

Before

Width:  |  Height:  |  Size: 190 B

After

Width:  |  Height:  |  Size: 190 B

0
web/images/chunkymap_zoom-in_disabled.png → web/chunkymapdata_default/images/zoom-in_disabled.png

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 195 B

0
web/images/chunkymap_zoom-out.png → web/chunkymapdata_default/images/zoom-out.png

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 175 B

0
web/images/chunkymap_zoom-out_disabled.png → web/chunkymapdata_default/images/zoom-out_disabled.png

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 182 B

4
web/chunkymapdata_default/markers/chunk_markers_x0z0.yml

@ -1,4 +0,0 @@
-
label:spawn
location:0.0,0.0
image:images/chunkymap_start.png

4
web/chunkymapdata_default/world/markers/0.yml

@ -0,0 +1,4 @@
label:spawn
location:0.0,0.0
image:chunkymapdata/images/chunkymap_start.png
comment:formerly chunk_markers_x0z0.yml

0
web/chunkymapdata_default/players/singleplayer.png → web/chunkymapdata_default/world/players/singleplayer.png

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 231 B

Loading…
Cancel
Save