1.1 --- a/moinformat/serialisers/html/graphviz.py Mon Aug 06 15:45:11 2018 +0200
1.2 +++ b/moinformat/serialisers/html/graphviz.py Mon Aug 06 15:50:16 2018 +0200
1.3 @@ -69,17 +69,17 @@
1.4
1.5 # Special methods for graph production.
1.6
1.7 - def _tag(self, tagname, attrname, filename, attributes, closing):
1.8 - l = ["%s='%s'" % (attrname, escape_attr(filename))]
1.9 + def _tag(self, tagname, attrname, target, attributes, closing):
1.10 + l = ["%s='%s'" % (attrname, escape_attr(target))]
1.11 for key, value in attributes.items():
1.12 l.append("%s='%s'" % (key, value))
1.13 self.out("<%s %s%s>" % (tagname, " ".join(l), closing and " /"))
1.14
1.15 - def image(self, filename, attributes):
1.16 - self._tag("img", "src", filename, attributes, True)
1.17 + def image(self, target, attributes):
1.18 + self._tag("img", "src", target, attributes, True)
1.19
1.20 - def object(self, filename, attributes):
1.21 - self._tag("object", "data", filename, attributes, False)
1.22 + def object(self, target, attributes):
1.23 + self._tag("object", "data", target, attributes, False)
1.24 self.out("</object>")
1.25
1.26 def raw(self, text):
1.27 @@ -97,16 +97,27 @@
1.28 format = self.directives.get("format", ["svg"])[0]
1.29 transforms = self.directives.get("transform", [])
1.30
1.31 + # Graph output is stored for a known page only.
1.32 +
1.33 + if not self.pagename:
1.34 + return
1.35 +
1.36 # Get an identifier and usable filename to store the output.
1.37
1.38 - identifier = "%s.%s" % (get_output_identifier(text), format)
1.39 - filename = self.output.get_filename(identifier)
1.40 + identifier = get_output_identifier(text)
1.41 + attachment = "%s.%s" % (identifier, format)
1.42 + filename = self.output.get_attachment_filename(self.pagename, attachment)
1.43
1.44 # Handle situations where no independent output is permitted.
1.45
1.46 if not filename:
1.47 return
1.48
1.49 + # Make sure that page attachments can be stored.
1.50 +
1.51 + self.output.ensure_attachments(self.pagename)
1.52 + target, label = self.linker.translate("attachment:%s" % attachment)
1.53 +
1.54 # Permit imagemaps only for image formats.
1.55
1.56 if format in IMAGE_FORMATS:
1.57 @@ -135,12 +146,12 @@
1.58 self.raw(graphviz.get_output())
1.59 attributes["usemap"] = "#%s" % im_attributes["id"]
1.60
1.61 - self.image(identifier, attributes)
1.62 + self.image(target, attributes)
1.63
1.64 # For other output, create a file and embed the object.
1.65
1.66 else:
1.67 - self.object(identifier, attributes)
1.68 + self.object(target, attributes)
1.69
1.70 serialiser = HTMLGraphvizSerialiser
1.71