google / blockly-games

Games for tomorrow's programmers.
https://blockly.games/
Apache License 2.0
1.28k stars 603 forks source link

Content Not Loading - Master Version #119

Open alanmvarela opened 4 years ago

alanmvarela commented 4 years ago

Hi I'm having an issue similar to the previously reported on All content not loading #18 I followed the procedure to set up the Master version on an Apache Server, cloning git repository, and i build everything in English and index and maze in all languages using:

make en;
make index;
make maze;

The application index works fine, but when entering any of the games i get the game directory content instead of the game itself. I tried the offline version and it works just fine, but as i need to use the storage.js implementation of the master version to get the status of the games in local-storage is of no use for me.

Can you help me figure out why the master version if not working for me? Please let me know if you need any further information on this.

Best Regards

NeilFraser commented 4 years ago

Oh, try going to maze.html instead of maze/

alanmvarela commented 4 years ago

Hi Neil, after changing the url to /maze.html it loads the game just fine. Any idea on what i'm missing on the index to map to correct URL?

NeilFraser commented 4 years ago

If you were using App Engine instead of Apache, then the app.yaml file would tell the server to redirect /maze to maze.html. For Apache, there are two approaches: 1) Translate the directives in app.yaml to Apache's configuration. 2) Edit js/lib-games.js and set BlocklyGames.IS_HTML = true; (then rebuild)

However, if you want storage to work, then you'll also need to rewrite storage.py to be some sort of CGI script that Apache can run, backed by some form of database. Currently it is designed to run under App Engine. Fortunately it's not a very complicated system: you give it code, it stores it and returns a key -- you give it a key, it returns the previously stored code.

alanmvarela commented 4 years ago

I modified js/lib-games.js and set BlocklyGames.IS_HTML = true; after this i rebuild index and maze as indicated and everything is working fine now.

Regarding storage.py, i understand that i should modify below methods on /appengine/common/storage.js file right? My intention is to have the code and key saved to a local database instead of creating a request to the cloud.

/**
 * Save blocks or JavaScript to database and return a link containing the key.
 */
BlocklyStorage.link = function() {
  var code = BlocklyInterface.getCode();
  BlocklyStorage.makeRequest_('/storage', 'xml', code);
};

/**
 * Retrieve XML text from database using given key.
 * @param {string} key Key to XML, obtained from href.
 */
BlocklyStorage.retrieveXml = function(key) {
  BlocklyStorage.makeRequest_('/storage', 'key', key);
};