“Right, it will be very complex to support action on the text(s) of a diagram image.”
That was my first impression but, since I’ve dug in and done it manually, I now disagree!
Have you taken a look at the example I provided with the anon version?
If not, I suggest you do. Read the notes.txt first.
It entails
- Identify the glossary terms.
VP obviously already does that, in order to highlight the term and underscore it. Whatever part of the code is doing that, needs a hook for the new routine. The new routine will
- identify the point of origin (co-ordinates) of the term within the diagram
- capture the font and length of the term
- create a matching transparent hotspot (based on an existing “shape”) at precisely the same co-ordinates, ordered “on top”
- capture the unique glossary id (the “system data” buried in the glossary)
- create a relative url based on your existing url naming convention
i.e “Glossary_(unique_id)” yielding something like: …\content\Glossary_TdWYV_qGAqACRAwT.html
- embed the url in the hotspot’s reference field.
Job done.
That is essentially what I’ve done manually and it works a treat. But it is a pain in the arse doing that manually for an average of 40-60 links per page and 65 pages. It takes about an hour per page. I suspect you could complete and test the code to make VP do all that before I complete my manual version!
There is only one complication with the above and that arises from the obvious fact that my hotspots aren’t logically bound to their underlying glossary texts. So if I alter the text or move the element, the hotspots can be separated from their texts. The workaround for that is, on completion of any large element (like an extensive note with a couple of dozen links in it) I “group” the whole thing so they can’t get accidentally separated. But that complication wouldn’t arise if you automated it because there would be a logical link between each glossary term and its hotspot.
“Btw, there is no problem to support highlighted term(s) in pure text.”
apart from your presentation which is in a new window for each term. That’s bizarre. NOBODY creates a web page like that. They should be appearing in popups over the relevant diagram.
My web developer created the quick and dirty (but very effective) bash script to convert all the “new window” calls to popups for every diagram where I’ve completed the hotspots.
The point of including it is
a) if any other poor sod is wading through the same job I’m doing, they’re welcome to use it but more importantly,
b) just to show that it can be done, in short order.
again, it would be a lot easier for us if you were to incorporat these changes into your code and it would make your html output at least 10 times more useful than it currently is.
#!/bin/bash
DIR=“content/”
AD=“ActivityDiagram*”
#AD=“ActivityDiagram_BiLYkfqGAqAACh7y.html”
EXC=“menu”
F_POPUP_HEADER=“basicPopup.inj”
#F_POPUP_HEADER=“test.inj”
#S_POPUP_HEADER=“script>\n</head>”
S_POPUP_HEADER=“script>
</head>”
OUT=“”
sanity
if [ ! -d “$DIR” ]; then
echo “Folder $DIR doesn’t exist, exiting.”
exit 1
fi
if [ ! -f “./$F_POPUP_HEADER” ]; then
echo “$F_POPUP_HEADER not found!”
exit 2
fi
load files into vars
R_POPUP_HEADER=cat $F_POPUP_HEADER
cd $DIR
inject html diagram files
for f in $AD; do
if [[ ! $f == “$EXC” ]]; then
# header
#sed "s/${S_POPUP_HEADER}/${R_POPUP_HEADER}/" ${f} > ${f}.new
perl -p0e "s/${S_POPUP_HEADER}/${R_POPUP_HEADER}/g" ${f} > ${f}.new.html
# popup
#sed "s/href.*(onmouseover=\"storeReferenceAndSubdiagramInfos)/onclick=\"basicPopup('ActivityAction_81X74fqGAqAAChJ2.html');return false\" onmouseover=storeReferenceAndSubdiagramInfos/g" ${f}.new > ${f}.new.html
# perl -p0e "s/href.*(onmouseover=\"storeReferenceAndSubdiagramInfos)/onclick=\"basicPopup('ActivityAction_81X74fqGAqAAChJ2.html');return false\" onmouseover=storeReferenceAndSubdiagramInfos/g" ${f}.new > ${f}.new.html
# MATCH links to glossary
# S=`perl -ne "print if/<area.*javascript:window.open.*storeReferenceAndSubdiagramInfos/" ${f}.new.html`
# MATCH links to glossary
S=`perl -ne "print if/<area.*href.*javascript:window.open.*/" ${f}.new.html`
while read -r line
do
# If not matched, exit loop
if [ -z "$S" ]; then
break
fi
# Breaking circular buffer to retain persistence
if [ -n "$OUT" ]; then
echo "$OUT" > ${f}.new.html
fi
# show original line
#echo $line
# replace stuff within the line
fixed=`echo "$line" | perl -p0e "s/href/onclick/g" | perl -p0e "s/javascript:window.open/basicPopup/g" | perl -p0e "s/;void\(0\)/;return false/g"`
#echo $fixed
# replace within the file with the fixed-up line
#perl -p0e "s/${esc_line}/${esc_fixed}/g" ${f} > ${f}.new.fixed.html
#sed "s|${line}|${fixed}|" ${f}.new.html > ${f}.new.fixed.html
OUT=$(sed "s|${line}|${fixed}|" ${f}.new.html)
done <<< "$S"
# Output only if not empty
if [ -n "$OUT" ]; then
echo "$OUT" > ${f}.new.fixed.html
echo $(ls -alh ${f}.new.fixed.html)
# overwrite the ofiginal file?
mv ${f}.new.fixed.html ${f}
fi
fi
OUT=“”
done
Tidy up, remove fragments
rm *html.new.html
echo “Done.”
“Can you explain (capture me a screenshot?) how ugly on your results?”
Here’s an example from the anon version:
First, I’m not too concerned about the font size. If the punter can’t read it, they can zoom the window
BUT note:
- It is NOT auto-wrapping and worse
- there’s no scroll bar to move right to see the hidden text
- Its deleted all the carriage returns which makes it read as paragraphs within VP, so it all jumbles together.