Addling links to an Archi exported .svg file -> web-clickable image

Started by Fustbariclation, December 03, 2014, 06:08:35 AM

Previous topic - Next topic

It would be useful for .svg images to be clickable to a URL

Very useful
0 (0%)
Quite useful
0 (0%)
I'd like to have this, but also the ability to add HTML5 features to objects
0 (0%)
I don't see the point
0 (0%)
I never use .svg files
0 (0%)

Total Members Voted: 0

Voting closed: March 24, 2015, 05:26:47 AM

Fustbariclation

As discussed in another thread, it would be good if Archi could export .svg files with clickable links, so they can be loaded straight onto a web server to work automatically.

In the mean time, there is an alternative to manually fixing each link by hand. You'll have to modify the script to fit your environment, but, to get my exports converted, I used this awk script.

You have to make sure that the object names appear properly in the diagram. If a name is on two lines, it will appear as two objects, if a name is too big for the box, the object will be called, say, 'archi...' instead of 'archimate' - you need to widen the box so it fits or use a smaller font.

To run simply:

$awk -f add_links_svg.awk <archi_exported.svg >archi_exported_with_links.svg

The code for add_links_svg.awk is:

"
BEGIN {
web_base_name = "http://www.mywebsite/";  #replace with the base name of your site
page_suffix = ".html"; # replace with the type of file - could be .html .php or just blank - "" for blank
}
BEGIN {
web_base_name = "http://takingserviceforward.org/wiki//index.php?title=";  #replace with the base name of your site
page_suffix = ""; # replace with the type of file - could be .html .php or just blank - "" for blank
}
/<text /   {if (found == 0 ) found = 1;}  # The script works because lines with Archi objects are preceded with a 'text' line
      {if ( found == 3)
   {
      found=0;
      string = string $0;
      sub("</text[ ]*>","</text></a>",string);
      print string;
      string="";
   }
         else
         if ( found == 2) { 
      found++;string = string $0;
                start_string = match(string,">[^<]")+1;
                end_string = index(string,"</text") ;
                string_end = end_string - start_string;
                object=substr(string,start_string,string_end); # This pulls out the object name
      gsub(","," ",object); # remove commas from the URL
      gsub("[ ][ ]*"," ",object); # trim spaces
                gsub(" ","_",object); # You need to replace blanks in the URL with underscores "_"
      gsub("__","_",object); # trim
      gsub("_$","",object); # trim (there are some very obstinate strings)
      print object >"objects_found"
            sub("><","><a xlink:href=\"" web_base_name object page_suffix "\" ><",string);
            print web_base_name object page_suffix >"page_links_needed"; # The script makes this file with the page names referenced
                     }
         else
         if ( found == 1) {found++;string = string $0;}
            else
               print $0;}
"

[updated to more general case on 6/12/2014