Data URI in _server.pbl

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Atreides
Posts: 1055
Joined: March 30th, 2019, 10:38 pm
Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off

Data URI in _server.pbl

Post by Atreides »

Is there a way to have icon= point to another file that contains the actual data? Including it in the pbl file makes it hard to edit as the data is 1 line 80,000 columns wide and Kate doesn't like it and has to reload it with a temporary limit raise on width.

What I've already tried is this:

icon={~/data/add-ons/Lonely_Era/servicon.txt}

the txt file of course contains an exact copy of the data uri that works when included in the pbl file.
The error given when trying this is invalid icon path.
User avatar
Pentarctagon
Project Manager
Posts: 5526
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Data URI in _server.pbl

Post by Pentarctagon »

I don't believe there's currently a way to do that. What you tried to do with servicon.txt is use a macro file inclusion, however pbl files are not handled by the preprocessor, so the contents of servicon.txt are never replaced.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
gnombat
Posts: 682
Joined: June 10th, 2010, 8:49 pm

Re: Data URI in _server.pbl

Post by gnombat »

If your editor has issues with long lines, it may be better to generate the _server.pbl file with the icon rather than trying to edit it manually. For example, you could create a file named _server-header.pbl with your editor containing everything except the icon= line, and then run the following commands:

Code: Select all

cp _server-header.pbl _server.pbl
echo -n 'icon="data:image/png;base64,' >> _server.pbl
base64 --wrap=0 path/to/your/icon.png >> _server.pbl
echo '"' >> _server.pbl
The first command copies the _server-header.pbl file to _server.pbl. Then the next three commands append the icon= line with the data URI to the _server.pbl file.
User avatar
Atreides
Posts: 1055
Joined: March 30th, 2019, 10:38 pm
Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off

Re: Data URI in _server.pbl

Post by Atreides »

Thanks for the replies!

Pent, I was half expecting that... :-)

gnom, that's really clever! Alas my editor (Kate) actually has no real problem with the long line, it's just an extra click when the warning pops up to fix it. I may use it anyways, drop it in a "batch" file and run it when needed. Ironically I've already placed the icon=data at the end of the pbl file to make it easier to edit it.
Post Reply