The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   Automatically Diagram XML data? (http://forums.omnigroup.com/showthread.php?t=112)

Angostura 2009-11-01 01:21 PM

Hmm, I commented out the line and Omnigraffle Professional (5.2.1) Put the initial homepage node in, but that was it. Another vote for major celebration if anyone can get this working. Or is it possible to grab an old copy of Omnigraffle from anywhere?

deny 2010-01-11 07:53 AM

How to use this site mapping script with 5.2.1 ?
 
Having no luck using this with OmniGraffle Pro version 5.2.1

Anybody figure out what the tweaks are ?

deny 2010-01-11 07:58 AM

got it to compile with this

change:
[B]set children to back to front ordering[/B]
to
[B]--set children to back to front ordering[/B]

unfortunately, no sitemap generated rom the resulting XML :-(

shines 2010-03-22 06:08 AM

Process
 
For those of you who are having troubles, I just want to talk through the process again:

First, copy the script from jeremybrown's post into Script Editor:
[url]http://forums.omnigroup.com/showpost.php?p=12059&postcount=10[/url]

Try to compile the script. You may be asked to show where the application Omnigraffle is. If it doesn't compile, the issue is typically the back to front ordering line, which you can comment out by placing a double hypen at the beginning of the line (--):
-- set children to bottom to top ordering

Then Save As an 'application' and place where you like.

When you want to create a new sitemap, just drag your xml file onto the AppleScript Application and it will load OmniGraffle and start creating the document in the frontmost canvas.

It can take a little while if there's a lot of pages so give it a few minutes.

Hope that helps someone!

Shines

jdkunesh 2010-08-05 10:24 AM

New Sitemap.xml diagramming tool
 
Hi everybody-

I've been following this thread for awhile and re-wrote some of the code here to create my own version of this script. You run the script, find your sitemap.xml file, and it does the rest, I believe. Let me know if it works for you as well as it does for me.

[URL="http://blog.fuzzymath.com/2010/08/omnigraffle-sitemap-generator-from-sitemap-xml/"]Here's a link to the blog post[/URL]. It contains instructions and the download.

Here's the code so you can see how I did it:


[CODE]
-- v0. works but includes http:// as a base node *duh*
-- v1. removes http:// baseline, improves performance
-- v2. is a minor re-write
-- v3. removes notion of folder vs. uri shapes
-- prompt user to select sitemap.xml file

-- function that draws each type of box
on makeShape(aTitle, aURL)
tell application "OmniGraffle Professional 5"
tell canvas of front window
return make new shape with properties {text:aTitle, url:aURL, vertical padding:5, autosizing:full, side padding:10, magnets:{{1, 0}, {-1, 0}, {-1, 1}, {-1, -1}}, origin:{(x of canvasSize) / 2.0, (y of canvasSize) / 2.0}}
end tell
end tell
end makeShape

on findShape(shapeText)
tell application "OmniGraffle Professional 5"
set matchingShapes to shapes of canvas of front window whose url is shapeText
if (count of matchingShapes) is greater than 0 then
return item 1 of matchingShapes
end if
end tell
end findShape

on drawConnectingLine(aSource, aDestination)
tell application "OmniGraffle Professional 5"
tell aSource
set aLine to connect to aDestination with properties {line type:straight}
end tell
set tail magnet of aLine to 1
end tell
end drawConnectingLine

on makeNewSitemap()
tell application "OmniGraffle Professional 5"
make new document
tell layout info of canvas of front window
set type to left to right
-- set children to back to front ordering
end tell
end tell
end makeNewSitemap

on cleanupSitemap()

tell application "OmniGraffle Professional 5"

tell canvas of front window
layout
page adjust
end tell

end tell
end cleanupSitemap

set sitemapFile to choose file with prompt "Please select a sitemap.xml file." of type {"XML"}
set sitemapXML to open for access sitemapFile

set uriList to {}

set isDone to false

-- got to be a better way here.
repeat until isDone -- end of sitemapXML
try
-- read up to a tag, and see what the tag is
read sitemapXML before "<"
set theTag to read sitemapXML before ">"

-- if it is a <loc> tag, then read the contents
if theTag is "loc" then
-- jumps to next < start of tag
set uriText to read sitemapXML before "<"
-- strip the "http://" is 7 characters
set uriText to text 8 thru (length of uriText) of uriText
copy uriText to the end of uriList
end if

on error errStr number errorNumber
-- you'll want the next line if you want to see error messages
-- display dialog errorNumber
set isDone to true
end try
end repeat
close access sitemapXML

makeNewSitemap()

set savedDelimiters to AppleScript's text item delimiters
set text item delimiters to "/"

set nodeList to {}

repeat with currentURI in uriList
if last character of currentURI is "/" then
set currentURI to text 1 thru ((length of currentURI) - 1) of currentURI
end if

set currentItems to text items of currentURI
repeat with i from 1 to count of items in currentItems
-- cItem in currentItems
set cItem to item i of currentItems

if contents of cItem is in nodeList then
-- find the matching shape within the list, and make it the node parent node
-- do nothing
-- log " cItem in nodeList "
else
-- add this item to the list of nodes
copy contents of cItem to the end of nodeList
-- create this shape
set childNode to makeShape(cItem, cItem)

if i is greater than 1 then
-- this must be a child node, so we must find the previous node's shape

set parentText to contents of item (i - 1) of currentItems
set parentNode to findShape(parentText)
drawConnectingLine(parentNode, childNode)
end if

end if
-- makeShape(cItem, cItem)

end repeat
end repeat

set text item delimiters to savedDelimiters

cleanupSitemap()[/CODE]

iNik 2011-06-03 11:00 AM

I recently came on this thread, and Jason's work is phenomenal. I found a number of opportunities for improvement and put those into a fork of his original project. (Thanks for making it open source, Jason!) This one does a lot, including applying a template to your file (so it's pretty), and adding the full page text so you can search the diagram for page text.

You can download the binary on my site:

[url]http://nik.me/crappysoftware[/url]

Or get the source on GitHub:

[url]https://github.com/nikjft/Omnigraffle-Sitemap-Generator[/url]


All times are GMT -8. The time now is 01:19 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.