From f577dfcc5c4cd1e4590e5cd0125e18eeb9a33312 Mon Sep 17 00:00:00 2001 From: Pysis Date: Tue, 18 Apr 2023 13:27:15 -0400 Subject: [PATCH 01/21] Starting TotK changes Customized index page data. Improved container name API and missing defaults for its data. Added new container with minimal data + sample. Dev doc migration samples and links, adding new game section, releasing. --- ajax/get_container_name.php | 56 +++- ...95637_container_update_and_add_defaults.rb | 9 + ...04517_container_add_basic_tot_k_support.rb | 7 + dev/db/samples/tingle/container.sql | 11 +- docs/Development.md | 51 +++- index.html | 258 +++++++++--------- 6 files changed, 231 insertions(+), 161 deletions(-) create mode 100644 dev/db/migrate/20230405195637_container_update_and_add_defaults.rb create mode 100644 dev/db/migrate/20230405204517_container_add_basic_tot_k_support.rb diff --git a/ajax/get_container_name.php b/ajax/get_container_name.php index cfe8f386..c7e83506 100644 --- a/ajax/get_container_name.php +++ b/ajax/get_container_name.php @@ -1,26 +1,56 @@ false, + "result" => 'No game parameter given.' + ))); - $query = "select name - from " . $map_prefix . "container c - where (c.id = '" . $game . "' - or c.short_name = '" . $game . "') - and c.visible = 1; - "; - $result = @$mysqli->query($query); + return 1; + } else { + $game = $_GET["game"]; + // debug_log("game: $game"); + } + + $query = " + SELECT `name` + FROM `${map_prefix}container` `c` + WHERE ( + `c`.`id` = '$game' + OR `c`.`short_name` = '$game' + ) AND `c`.`visible` = '1' + ; + "; + // debug_log("query: $query"); + + $result = @$mysqli->query($query); + // debug_log('mysqli info: '.@$mysqli->info); // Not helpful.. if(!$result) { print($mysqli->error); - return; + return 2; } - $row = $result->fetch_array(); - echo json_encode(array("success"=>true,"name"=>$row['name'])); + $row = $result->fetch_array(); + // debug_log("empty(row): ".empty($row)); + // debug_log("row: ".var_export($row, 1)); + // debug_log("row num_rows: ${$row->num_rows}"); + if(empty($row)) { + print(json_encode(array( + "success" => false, + "result" => 'No visible game container found.' + ))); + + return 3; + } + + print(json_encode(array( + "success" => true, + "name" => $row['name'] + ))); // debug_log("get_container_name END"); ?> diff --git a/dev/db/migrate/20230405195637_container_update_and_add_defaults.rb b/dev/db/migrate/20230405195637_container_update_and_add_defaults.rb new file mode 100644 index 00000000..64746803 --- /dev/null +++ b/dev/db/migrate/20230405195637_container_update_and_add_defaults.rb @@ -0,0 +1,9 @@ +class ContainerUpdateAndAddDefaults < ActiveRecord::Migration[7.0] + def change + change_table :container do |t| + t.change_default :marker_url , from: '/markers/', to: 'markers/' + t.change_default :icon_width , from: nil , to: 23 + t.change_default :icon_height , from: nil , to: 23 + end + end +end diff --git a/dev/db/migrate/20230405204517_container_add_basic_tot_k_support.rb b/dev/db/migrate/20230405204517_container_add_basic_tot_k_support.rb new file mode 100644 index 00000000..f66dddd6 --- /dev/null +++ b/dev/db/migrate/20230405204517_container_add_basic_tot_k_support.rb @@ -0,0 +1,7 @@ +class ContainerAddBasicTotKSupport < ActiveRecord::Migration[7.0] + def up + execute <<-SQL + INSERT INTO `container` (`short_name`, `name`, `icon`) VALUES ('TotK','Tears of the Kingdom', 'Tears-of-the-Kingdom'); + SQL + end +end diff --git a/dev/db/samples/tingle/container.sql b/dev/db/samples/tingle/container.sql index 7be2cb14..aba71a3e 100644 --- a/dev/db/samples/tingle/container.sql +++ b/dev/db/samples/tingle/container.sql @@ -26,7 +26,7 @@ CREATE TABLE `container` ( `id` int(11) NOT NULL AUTO_INCREMENT, `short_name` varchar(45) NOT NULL, `name` varchar(45) NOT NULL, - `marker_url` varchar(250) NOT NULL DEFAULT '/markers/' COMMENT 'Each map can have a set of different markers icons just by changing the marker url', + `marker_url` varchar(250) NOT NULL DEFAULT 'markers/' COMMENT 'Each map can have a set of different markers icons just by changing the marker url', `marker_ext` char(3) NOT NULL DEFAULT 'png', `background_color` char(7) NOT NULL DEFAULT '#DEECFD', `icon` varchar(60) NOT NULL, @@ -45,8 +45,8 @@ CREATE TABLE `container` ( `cluster_max_zoom` int(11) NOT NULL DEFAULT 4 COMMENT 'Max zoom to cluster the markers. Best -2 from the max zoom allowed (if 6 is the max, cluster should be 4)', `cluster_grid_size` int(11) NOT NULL DEFAULT 30 COMMENT 'Pixel size of grid (default 30)', `tile_size` int(11) NOT NULL DEFAULT 256 COMMENT 'Internet default is 256', - `icon_width` int(11) NOT NULL, - `icon_height` int(11) NOT NULL, + `icon_width` int(11) NOT NULL DEFAULT 23, + `icon_height` int(11) NOT NULL DEFAULT 23, `icon_small_width` int(11) NOT NULL DEFAULT 16, `icon_small_height` int(11) NOT NULL DEFAULT 16, `switch_icons_at_zoom` int(11) NOT NULL DEFAULT 5, @@ -55,7 +55,7 @@ CREATE TABLE `container` ( PRIMARY KEY (`id`), UNIQUE KEY `map_id_UNIQUE` (`id`), UNIQUE KEY `short_name_UNIQUE` (`short_name`) -) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -83,6 +83,7 @@ INSERT INTO `container` VALUES (16,'SS','Skyward Sword','markers/','png','#00000 INSERT INTO `container` VALUES (17,'ALBW','A Link Between Worlds','markers/','png','#000000','',0,1,1,0,1,0,0,0,0,-256,256,6,4,30,256,23,23,16,16,5,0,3); INSERT INTO `container` VALUES (18,'TFH','Tri Force Heroes','markers/','png','#000000','',0,1,1,0,1,0,0,0,0,-256,256,6,4,30,256,23,23,16,16,5,0,3); INSERT INTO `container` VALUES (19,'BotW','Breath of the Wild','markers/','png','#000000','Breath-of-the-Wild',0,1,1,0,1,112,-159,-49.875,34.25,-206,221,8,9,50,256,23,23,16,16,5,1,5); +INSERT INTO `container` VALUES (20,'TotK','Tears of the Kingdom','markers/','png','#DEECFD','Tears-of-the-Kingdom',0,1,1,0,1,128,-128,0,0,-256,256,6,4,30,256,23,23,16,16,5,0,3); /*!40000 ALTER TABLE `container` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -95,4 +96,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-03-30 14:31:35 +-- Dump completed on 2023-04-05 17:08:09 diff --git a/docs/Development.md b/docs/Development.md index 6f8e00c7..97003c80 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -20,13 +20,25 @@ # Releases - Done by Jason, from `master` to `production`. - - The release manager must manually set all user accounts `seen_latest_changelog` to `0` (`false`). - Don't want a fresh commit to do this before every release; that would be cruft. - Do this after you deploy the code, to prevent the edge case of a user visiting the site in the small window of time with the old and/or database without the new changelog entries, and would incorrectly set the `seen_latest_changelog`, and even the `last_login` field as well, so once the new data is present, it would not be triggered and shown to them. - Can use this script: `dev/db/resetUsersChangelogSeenPresence.sh` - Make sure to set the MySQL parameters appropriately. See the script header for more details. + - From `master` to `production` by the owner / release manager. + + - When changelog notifications are enabled: + - They must manually set all user accounts `seen_latest_changelog` to `0` (`false`). + - Don't want a fresh commit to do this before every release; that would be cruft. + - Do this after you deploy the code, with database changes. + - This is to prevent the edge case of a user visiting the site in the small window of time with the old database without the new changelog entries, which would incorrectly set the `seen_latest_changelog` flag again, so when the new data is present, it would not be triggered and shown to them. + - Can use this script: `dev/db/resetUsersChangelogSeenPresence.sh` + +# Add new game support + + - Add new database migration to add container entry. + - Source: `dev/db/migrate/20230405204517_container_add_basic_tot_k_support.rb` + - Update sample SQL data files in a focused style. + - `set -x tableNames (read)` + - `./dev/db/createSampleDatabaseExport/run.sh` + - Optional: + - Change default game parameter for container in index page script block, and any other specific SEO data in the head section. + - Test, commit, push, and create a PR! ## Version Info @@ -164,13 +176,27 @@ - Samples: - ActiveRecord Ruby Code - - Main benefit is hopefully more terse and efficient syntax, but also applies to automatically handling bidirectional migration/rollback support with declarative styling. + - Source: http://guides.rubyonrails.org/active_record_migrations.html + - Source: https://www.ralfebert.de/snippets/ruby-rails/models-tables-migrations-cheat-sheet/ + - Note: Main benefit is hopefully more terse and efficient syntax, but also applies to automatically handling bidirectional migration/rollback support with declarative styling. - Add column: - `t.column :hidden, :boolean, null: false, default: 0, after: :version_patch` - Source: `dev/db/migrate/20230403193442_changelog_add_hidden_field_and_disable_blank_content.rb` - - Change column null property: - - `t.change_null :content, false` - - Source: `dev/db/migrate/20230403193442_changelog_add_hidden_field_and_disable_blank_content.rb` + - Changing Columns: + - Source: https://guides.rubyonrails.org/active_record_migrations.html#changing-columns + - Change table common code: + - Source: https://guides.rubyonrails.org/active_record_migrations.html#changing-tables + - Source: https://api.rubyonrails.org/v7.0.4.2/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_table + - `change_table :table_name do |t|` + - Then refer to the specific section goal below with the reduced column variants. + - Change column null property: + - `t.change_null :content, false` + - Source: `dev/db/migrate/20230403193442_changelog_add_hidden_field_and_disable_blank_content.rb` + - Change column default value: + - `t.change_default :marker_url, from: '/markers/', to: 'markers/'` + - `change_column_default(:table_name, :column_name, '')` + - Source: `dev/db/migrate/20230405195637_container_update_and_add_defaults.rb` + - Source: https://api.rubyonrails.org/v7.0.4.2/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_column_default - Execute Raw SQL: - So far in the migration Ruby code just have the up method typically, but could always support down with the custom opposing statements in later habits where necessary. - Inline statement: @@ -187,9 +213,6 @@ ``` - Multiple Queries: - Add `.lines.each { |line| execute line if line != "\n" }` the string containing the queries separated by newlines. - - More Info: - - http://guides.rubyonrails.org/active_record_migrations.html - - https://www.ralfebert.de/snippets/ruby-rails/models-tables-migrations-cheat-sheet/ ## MySQL Workbench (MWB) File Handling diff --git a/index.html b/index.html index 6c6a6e37..080b064f 100644 --- a/index.html +++ b/index.html @@ -1,149 +1,149 @@ - - - - Breath of the Wild Interactive Map - Zelda Maps - - - - - - + + + + Tears of the Kingdom Interactive Map - Zelda Maps + + + + + + - - - - - - + + + + + + - - + + - - - + + + - + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - + }); + - - + + - - - -
-
- - - - -
-
- + + + +
+
+ - - - - -
+ document.getElementById('desktopAds').style.width = adsWidth + 'px'; + document.getElementById('desktopAds').style.height = adsHeight + 'px'; + + + + +
+ - - + + - + - + + + + - - - - +