Ifsitegen.py

Here’s my weekend hack:

https://eblong.com/zarf/blorb/ifsitegen.py
or
https://github.com/erkyrath/glk-dev/blob/master/ifsitegen.py

This script does essentially the same job as the “Release along with an interpreter” option of Inform 7. The differences are:

  • You can run this on any Z-code or Glulx game file.
  • It generates the playable game page as the primary page, rather than starting with a game information page. (The playable game is at index.html, not play.html.)

This is useful for making Inform 6 games and older games available on a web site. It can also make a playable Glulx file with images, which Inform 7 (as of 6M62) cannot.

File types supported: .z3 through .z8, .ulx, .zblorb, .gblorb

You must install Inform 7 to use this script. (It relies on template files that are distributed as part of Inform 7.) However, you don’t need to run Inform 7.

The simplest way to use this:

python3 ifsitegen.py Game.ulx

This will look for Inform 7 in its default installation location (on your OS). It will use the “Standard” web site template and the “Quixe” or “Parchment” interpreter, depending on the game file type. If you have installed updated templates in your Inform document library, those will be used instead.

The “Standard” template includes the game title and author on the page. You should supply these:

python3 ifsitegen.py --author 'Bob Zod' --title 'Pow!' Game.ulx

If you provide a Blorb file which contains cover art, that will be used on the web page. Otherwise, you can use the --cover argument:

python3 ifsitegen.py --cover my-cover-art.jpeg Game.ulx

If you have installed Inform 7 in a non-standard place, or given it a non-standard name, you must pass this with the -a argument:

python3 ifsitegen.py -a /Applications/Local/I7.app Game.ulx

Similarly, you can use the -l argument to refer to your document library directory.

Default locations:

  • MacOS: /Applications/Inform.app, ~/Library/Inform
  • Windows: C:\Program Files\Inform 7, ~\My Documents\Inform
  • Linux: /usr/local/share/inform7, ~/Inform

You can select a different web site template with the -w option, or a different interpreter template with the -i option:

python3 ifsitegen.py -i Vorple -w Classic Game.ulx

(For more information about Inform’s templates, see chapters 25.10 - 25.14 of the Inform manual.)

The -i and -w options can also refer to a directory or a zip file containing a template:

python3 ifsitegen.py -i ~/Downloads/Quixe-220.zip Game.ulx

Finally, if you have a Glulx game with images, pass the --unpack option to unpack the .gblorb file into separate image files. This is not required! The game will play fine either way. However, --unpack reduces the processing and memory load on the client browser.

15 Likes

I’ve put in the default paths for Windows and Linux, but I’ve only tested this on Mac. If I screwed anything up, let me know.

Love the idea! This will be so much easier than the alternatives we’ve had to suggest before.

The templates in Inform are over 5 years old now. How would you feel about adding an option within the script to download parchment-for-inform7.zip and use it? Maybe even the default? (It would be better if the zip was in the master branch… but if you want to add this then I can switch things around so that it is.)

1 Like

I7’s Quixe is out of date too, but I don’t want to hard-code URLs in the script.

I suppose the argument could accept URLs and download them to the library directory. It’s a bit more work than I want to put in, though.

How about I just add the current links to the documentation and recommend downloading the latest version. Hopefully, it won’t be too long before I7 is updated anyhow.

3 Likes

16 posts were split to a new topic: Broken Parchment for Inform 7 template

This is amazing.

I don’t know too much about how Inform templates work (the Templates folders don’t seem to actually have any HTML files in them, just a manifest file with some HTML in variables?), but would it be possible to have a command line argument that removes the sidebar like in this post?

There are two kinds of templates: web site and interpreter. In the Inform app’s Templates directory, Classic and Standard are web site templates: these contain HTML and CSS. Parchment, Quixe, and Vorple are interpreter templates; they contain JS and CSS, plus (as you note) some HTML snippets in (manifest).txt.

If you want a different layout, you should make a new web site template. I did this (as a sample) here: https://eblong.com/zarf/glulx/quixe/OneColumn.zip .

2 Likes

Side note: a member from the Puny Discord server created this GitHub - joshwarecom/edgecase-parchment. While I was not able to make @zarf’s IFsitegen generate a working game bundle, Edgecase Parchment did work for me. Still no idea if Parchment is the problem here but at least three individuals face the same issue currently. Fingers crossed for a fix, because IFsitegen is definitely way more flexible, as everything can be controlled with command line parameters. Yes, that transcript feature is posh. EDIT: Parchment has been fixed, ifsitegen works like a charm.

1 Like

Some comments:

  • Could the “Unable to locate template” error messages specify if it’s searching for the web or the interpreter template?
  • The default install location for gnome-inform7 (off the Inform7 site) in Debian/Ubuntu is /usr/share/gnome-inform7/, so it would be good if that was supported.

(I split off the comments about the broken Parchment template to Problems with the Parchment for Inform 7 template. The bug has now been fixed.)

Yep, will look at those. Thanks.

EDIT-ADD: Done.

1 Like

Thanks! I still think the relationship between “website” and “interpreter” is pretty confusing in Inform though, haha. Releasing with a website just creates the information index page, while releasing with an interpreter also releases with a website, and both the index and the play pages use the website template.

So to use a non-default layout for the play page in Inform, you actually have to write Release with a "OneColumn" website and an interpreter (and then delete the index page and rename play.html to index.html to achieve what this script does). Is that about right?

I am not experienced in Windows programming so it took me some time to figure out what to change in ifsitegen.py to make it work on a 64-bit Windows 10 machine.

I simply had to change part of the path in line 180 from:

/Program Files/
To:
/Program Files (x86)/

One question: As Parchment also can handle Hugo, TADS and Adrift 4 games, would it be simple to make ifsitegen.py handle such files too?

1 Like

Unfortunately no, because the templates only include interpreters for Z-code and Glulx. And because the other interpreters use WASM it would also be harder to make them run from local file: urls. Not impossible, but not simple.

2 Likes

Ok, thanks :slight_smile:

Had a go with this for the first time today. I can get it to work with the basic python ifsitegen.py mygame.z5 but if I add any of the options for author name, title, etc., it won’t produce any output. Anyone have any tips?

2 Likes

I presume you’re doing this in order to get a game running in Parchment. If so, this thread is very useful. You can skim the whole thread, but most of the best stuff is in the solution by @StJohnLimbo.

Using Parchment is a dark art. I struggled with it for weeks and wasn’t able to get my page looking quite how I wanted it. If you need any further help, do a search for Parchment or send me a PM and I’ll help you get started. I have to get back into this myself anyway in the next day or two.

3 Likes

I tried the solution in that thread but ended up with a game page stuck on ‘loading’. I’ll give it another go today to see if I did something wrong, but if I can’t get it to work I’ll message you. Thanks!

Assuming Windows is your operating system, try the following:

  1. Update Parchment that came with Inform 7 to the latest version. You can do so by downloading the current package from here Parchment for Inform 7.

  2. For the Puny BuildTools I created a simple Windows Powershell script that automates building a game using Ifsitegen.py. It also cleans up the the old version before it builds new. You probably need to apply other directories but in general, this should hopefully work for you. Just place this script in every project you’d like, alter it one time and you’re good to go. Puddle-BuildTools/modern.ps1 at master · ByteProject/Puddle-BuildTools · GitHub

PS: Python and Powershell needs to be installed on your Windows PC of course. I think Powershell is installed by default now and Python you get from the Windows App Store. I am using Python 3.9 on my machine.

2 Likes

I’ll have a look at that. Thanks!

1 Like

Just curious, where would you like to play your game online? I am asking because, depending on what you are trying to do, you may not even need a Python script.