A year ago as a project to learn JavaScript and CSS, I wrote a
deck planner for Magic: Duels of the Planeswalkers. One of the features was a rich HTML card list which could be posted to the Wizards.com forums. This was broken by the big forum change, and I'm investigating doing something similar or even better here. The result looked like this inside a user's post:
In this example, the cards are grouped by "Purpose", a set of custom categories that I defined in the deck planner for each deck. You can also group the cards by casting cost, type, or some other things. Within each group are subgroups based on card cost (with color banding for each subgroup). I gave each deck in the game its own color scheme.
Being able to create posts with these neat, informative deck lists became very popular in the old DotP forum. One thing I'd like to explore with you is whether we can come up with a scheme where non-DotP Magic players at these forums could somehow have the option to create fancy listings like this, without needing a third-party app like my deck planner. I'm not aware of any other forum that has something like this, so this could be a feature to make NoGoblinsAllowed really stand out in the Magic community.
A mockup of the table in HTML is
here for you to inspect. Note that the prefix and postfix text is wrapped in a table to protect it from the random line breaks that the old forums used to insert, which won't be necessary here. The main things to know are that a nested table is used to put the sideboard on the side, and the color banding is done at the <tbody> level.
These forums don't support direct posting of HTML code, so we'd have to work something out using custom BB tags. I can see a few options. Once we agree on a plan, I'll design the exact tags for you.
Some phpBB questionsI would figure these out myself instead of bugging you, but the documentation is lousy, and I don't have access to an installation that I can experiment with.
Question 1 The phpBB documentation has no technical details about custom tag parsing, just examples, so I don't know exactly what the rules are. From what I understand, you define the tag something like this:
Code:
[customtag={SIMPLETEXT1},{SIMPLETEXT2},{SIMPLETEXT3}]{TEXT}[/customtag]
Do the = and , characters have special meaning to the parser, or can I use anything there and just expect it to be matched character by character? For example, can I use a # or | character to separate the parameters instead of a comma?
Question 2 I assume that you can't do optional parameters. In the example above, would it be possible to use the tag with one parameter?
Code:
[customtag=abc]defgh[/customtag]
I'm guessing that would be treated as invalid and remain unsubstituted. How about if I appended two commas with no parameter text? Would SIMPLETEXT2 and SIMPLETEXT3 become empty strings, or would that be invalid also?
Question 3 The built-in url tag takes an optional parameter -- is that a magic feature, or is it just defined as two separate custom tags, one with parameter and one without?
Question 4 The {TEXT} regex says that it accepts any characters. I assume it halts when it sees the characters for the closing tag. What if you want to use multiple {TEXT} fields -- how do you separate them? Can you define a tag like this?
Code:
[customtag]{TEXT1}%%{TEXT2}%%{TEXT3}[/customtag]
and have it work when used as
[customtag]This is part 1!%%I am 10% sure this is part2.%%part3?[/customtag]
Question 5 Can you execute custom code at the time a tag is being processed, so that you can do something more complex than just substituting matched parameters into an HTML template? Is this a no-no for performance reasons, or would it be ok for simple things like a quick text replacement? How do you guys implement the "deck" and "card" tags to do autocarding? Is the tag substitution done at post time and the output cached, or does the work get done every single time the post is rendered?
Question 6 Are inner nested tags fully processed before the outer tag gets parsed, or is the overall tag structure determined before any substitutions are made? For example, say I have these tags:
Code:
[inner]{TEXT}[/inner] -----------> ***{TEXT}***
[outer]{TEXT1}***{TEXT2}***{TEXT3}[/outer] -----------> (({TEXT1})) (({TEXT2})) (({TEXT3}))
What happens when the user types this?
Code:
[outer]left [inner]inside[/inner] right[/outer]
If the inner tag is fully processed first, I expect to get "((left )) ((inside)) (( right))".
If the outer matching is done first, I expect a failed match that turns into
Code:
[outer]left ***inside*** right[/outer]
Which one happens?
Option 1: low-level formatting codes, imitating HTMLWe define some tags (prefixed with d for deck).
Code:
[d_table], [d_tbody], [d_tr], [d_td]
that just create an HTML tag. Sadly, there's no way to specify the entire style in one tag parameter, because phpBB doesn't provide a regex that will accept colon and semicolon (other than the unsafe {TEXT}). So I guess the custom tags would need a bunch of parameters to make room for all the style attributes.
Code:
[d_table_style5={IDENTIFIER1},{SIMPLETEXT1},{IDENTIFIER2},{SIMPLETEXT2},{IDENTIFIER3},{SIMPLETEXT3},{IDENTIFIER4},{SIMPLETEXT4},{IDENTIFIER5},{SIMPLETEXT5}]{TEXT}[/d_table_style5]
which would translate into
<table style="{IDENTIFIER1}:{SIMPLETEXT1}; {IDENTIFIER2}:{SIMPLETEXT2}; {IDENTIFIER3}:{SIMPLETEXT3}; {IDENTIFIER4}:{SIMPLETEXT4}; {IDENTIFIER5}:{SIMPLETEXT5};">{TEXT}</table>
This assumes that parameters can be either omitted (see Question 2 above) or given as a blank space. If fewer than 5 attributes were given, some invalid empty style attributes ":;" would be generated. I don't think that would cause problems for browsers reading the HTML, but I'm not positive. If I needed more than 5 properties, I could ask you for a {d_table_style10} with more slots. It would be nice if you could run a regex replace so that I could provide the style as one string using say ++ and +++ as separators which you could turn into colon and semicolon, so let me know if that's possible.
Pros+ Extremely flexible.
+ I and others can use these tags to create new table formats without having to bug you for new custom tags.
Cons- Unreadable to humans
- Not creatable or editable by users
- Take up a lot of space, stuffing posts with dozens of lines of gobbledygook in edit mode (including when quoted)
- Specifying HTML tag attributes, e.g. COLSPAN on <TD> tags, requires a new custom tag with different parameters
Option 2: low-level semantic codes, imitating XMLWe could create higher level tags specific to the layout used in my tables. A motivated human being would be able to create or edit tables using these tags, although it would not be trivial.
Code:
[d_deck], [d_group], [d_subgroup], [d_card], [d_sideboard]
These would take high level parameters containing the relevant data, and hide the HTML details.
d_deck creates a <table> and takes these params
- border color
d_group creates a <tbody> with a <tr> for the heading
- group label parameter (which would have to be given in the body of the tag, as in Question 6 above
- background color
d_subgroup creates a <tbody>
- background color
- subgroup label (but there is a problem -- see below)
d_card creates a <tr> and all the contained <td> cells for a card
- card count
- card name
- card mana cost (as rich text including mc tags)
d_sideboard- contains a bunch of text which should ideally get autocarded automatically
The subgroup label is a problem. As you can see in the example image, I stuff the subgroup label into the first cell of the first card row in that subgroup. Later cards in that subgroup show nothing in that first cell. Unfortunately, while parsing the d_subgroup tag, we can't "save a global variable" with the label for use by the d_card tags. Depending on your answer to Question 6, I think there might be a (hacky!) way to do surgery on the generated HTML for the card rows to stuff the subgroup label in. This could be a breaking issue, so if you know a clean way to do something like this, let me know.
Pros+ Human readable
+ Somewhat human editable
+ Should take up fewer lines in a post while being edited
+ More formatting can be done via CSS instead of repeated in every post as tag-level HTML styles
Cons- Inflexible -- the structure and formatting are baked into the tags, so if someone wants to make a different kind of table (e.g. for collectors), they need to create new custom tags
- Even in my case, I have a second format for sealed decks that breaks the large sideboard into a group of blocks by card color below the main table, so I'd need more custom tags for that feature
- The subgroup label issue mentioned above may wreck the whole idea
Option 3: the whole enchiladaThe dream is to just define a tag called "fancydeck" which takes a list of card names like the "deck" tag. This would scan a card data file on the server, group and reorder the cards, and populate an HTML table with additional data about each card automatically.
Obviously this requires server-side code to run (see Question 5 above). I may be able to help with code to generate the card data file, as I have to do that myself for the deck planner.
Pros+ Super easy and awesome
+ Best forum deck lists in existence
+ Completely human readable and human editable tag text
Cons- May not actually be possible
- Questions about performance
- NoGoblinsAllowed staff responsible for rebuilding the card data file every month or two when Wizards releases a new card set
The planI guess that option 1 is the most straightforward choice. I could make it work in the deck planner with some work. If someone wants to build, e.g. a collection manager app that generates card lists with set/condition/price information, they could use these tags to build a fancy card list in the same way that I do.
Neither options 1 nor 2 will see any takeup by the community here--I would be the only one using them. It would be cool if people in the other Magic forums could make fancy deck lists too. Perhaps the post interface could gain a "fancy deck" button which pops up a small form where the user can set a few parameters and include a list of cards, and then generate the codes for a fancy card list? This could be about as easy to use as option 3, but without the performance issues. Actually building the table isn't too complicated, but again you guys would have to be responsible for maintaining an up-to-date card data file for the code to use.
Some forums (like the old Wizards forums) pop up a special tag-building UI like this when you click the "link" button, giving you an easy way to enter the URL and other properties. I don't know if this is easy in phpBB.
Whew! If I knew more about what is easy and what is hard for you folks to do with the forum software, I could ask more targeted questions. Now that you get the idea, let me know if you've got any tricks that could help. Once we settle on an approach, I'll generate the exact custom tag templates that are needed and then we can test things out. Thanks for your willingness to investigate this.