Completed the HTML exporter
[getaclue.git] / crosswordpuzzlecreator.py
index 1816ff6..5a0ae11 100644 (file)
@@ -194,17 +194,24 @@ class CrosswordPuzzleCreator:
                        sys.stderr.write ("Word cannot be added to a frozen puzzle.\n")
 
        # Export to image/HTML
                        sys.stderr.write ("Word cannot be added to a frozen puzzle.\n")
 
        # Export to image/HTML
-       def on_export_image (self, solution=False):
+       def on_export_image (self, solution=True):
                try:
                        sys.stdout.write (self.BLUE + "Exporting puzzle to image/HTML\n")
                try:
                        sys.stdout.write (self.BLUE + "Exporting puzzle to image/HTML\n")
-                       filename = raw_input (self.BRICKRED + "Filename (PNG): " + self.ENDCOL)
-
-                       self.puzzle.export_image (filename, solution)
-                       sys.stdout.write (self.BLUE + "Successfully exported to file: " +
-                                                       filename + "\n" + self.ENDCOL)
+                       pngfile = raw_input (self.BRICKRED + "Filename (PNG): " + self.ENDCOL)
+                       if solution is False:
+                               htmlfile = raw_input (self.BRICKRED + "Filename (HTML): " +
+                                                       self.ENDCOL)
+                               puztitle = raw_input (self.BRICKRED + "Title of puzzle: " +
+                                                       self.ENDCOL)
+                               self.puzzle.export_image (pngfile, htmlfile, puztitle, solution)
+                       else:
+                               self.puzzle.export_image (pngfile)
 
 
+                       sys.stdout.write (self.BLUE + "Successfully exported!")
                except crosswordpuzzle.FrozenGridException:
                except crosswordpuzzle.FrozenGridException:
-                       sys.stderr.write ("Cannot export as grid is not frozen/finalized")
+                       sys.stderr.write ("Cannot export as grid is not frozen/finalized\n")
+               except crosswordpuzzle.NoWordsException:
+                       sys.stderr.write ("No words to export!\n")
 
        # Export to across lite
        def on_export_acrosslite (self):
 
        # Export to across lite
        def on_export_acrosslite (self):
@@ -269,9 +276,9 @@ class CrosswordPuzzleCreator:
                                elif ch == "E" or ch == "e":
                                        self.on_export_acrosslite ()
                                elif ch == "H" or ch == "h":
                                elif ch == "E" or ch == "e":
                                        self.on_export_acrosslite ()
                                elif ch == "H" or ch == "h":
-                                       self.on_export_image ()
+                                       self.on_export_image (False)
                                elif ch == "I" or ch == "i":
                                elif ch == "I" or ch == "i":
-                                       self.on_export_image (True)
+                                       self.on_export_image ()
                                elif ch == "X" or ch == "x":
                                        break
 
                                elif ch == "X" or ch == "x":
                                        break