downforacross / downforacross.com

Web frontend for downforacross.com -- continuation of stevenhao/crosswordsio
https://downforacrosscom.downforacross1.now.sh
MIT License
220 stars 92 forks source link

.ipuz support please! :) #246

Closed frozenpandaman closed 1 year ago

frozenpandaman commented 1 year ago

Hi! Avid user of the site (and bug-reporter, haha). Just wanted to say that would be really wonderful to see support for uploading .ipuz files – an open, free, extensible format for crossword puzzles. It's underlyingly JSON and has detailed documentation available at that link, and there's already some good code out there for parsing it in JS. Not sure how/where in the codebase you're parsing the .puz files currently, but I can look into helping out with adding this feature or making a PR myself if you can point me in the right direction!

stevenhao commented 1 year ago

Cool, happy to review a PR!

this is the puz converter source, pretty much entirely home grown / adapted from puz converters in other languages :) https://github.com/downforacross/downforacross.com/blob/master/src/lib/converter/PUZtoJSON.js#L179

invoked here https://github.com/downforacross/downforacross.com/blob/11495fb8bef02a680f2169bd90104c6bdbd721e8/src/components/Upload/FileUploader.js

frozenpandaman commented 1 year ago

@stevenhao Oh, this is awesome, since it's just going from JSON to JSON haha. Should be very doable. Will get some time to poke into it soon. Thanks!

Hmm, I might even suggest you switch over to representing the puzzles following the ipuz standard under the hood… obviously that's a larger decision that you'd need to get on-board with, but looking at FileUploader.js, it's already like 90% there!

FYI, the basic structure of an ipuz file is just this:

{
  "version": "http://ipuz.org/v1",
  "kind": [ "http://ipuz.org/crossword#1" ],
  "dimensions": { "width": x, "height": y },
  "author": "...",
  "title": "...",
  "notes": "...",
  "copyright": "...", // all of these fields are optional
  "puzzle": [
    [1, 2, 3, 4, "#", "#", "#", 5, 6, 7, 8, 9, 10, 11, 12],
    // etc...
    // shaded square: {"cell": num, "style": {"color": "#dcdcdc"}}
    // circle in square: {"cell": num, "style": {"shapebg": "circle"}}
  ],
  "solution": [
    ["T", "E", "S", "T", "#", "#", "#", "REBUS", "E", "X", "A", "M", "P", "L", "E"],
    // etc...
  ],
  "clues": {
    "Across": [
      [1, "blah"],
      // etc...
    ],
    "Down": [
      [1, "blah"],
      // etc...
    ]
  }
}
stevenhao commented 1 year ago

closed in #267

frozenpandaman commented 1 year ago

Amazing, thank you @scouttyg!