Menu

MapToHtmlDoc.groovy - Basic and easy documentation using Freeplane

Alexandre
2017-06-10
2021-10-05
<< < 1 2 3 4 5 > >> (Page 4 of 5)
  • Quinbus

    Quinbus - 2017-11-22

    Alexandre,

    I love this script. Thank you so much for the hard, continuing work on our collective behalf.

    Sometimes the script throws a fatal error. I can't tell why--it doesn't do it on all maps. Here's a copy of the relevant log entries:

    Nov 22, 2017 9:36:06 AM org.freeplane.core.util.LogUtils warn
    WARNING: error executing script C:\Users\Bill\AppData\Roaming\Freeplane\1.6.x\scripts\MapToHtmlDoc.groovy - giving up
    groovy.lang.MissingPropertyException: No such property: value for class: java.lang.String
    Nov 22, 2017 9:36:06 AM org.freeplane.core.util.LogUtils warn
    WARNING: Error executing the script:
    No such property: value for class: java.lang.String at line -1
    
    STDOUT: message: No such property: value for class: java.lang.String
    STDOUT: Line number: -1Nov 22, 2017 9:36:31 AM org.freeplane.core.util.LogUtils warn
    WARNING: ExecuteScriptAction failed:
    groovy.lang.MissingPropertyException: No such property: value for class: java.lang.String
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
        at org.codehaus.groovy.runtime.callsite.PojoMetaClassGetPropertySite.callGetProperty(PojoMetaClassGetPropertySite.java:43)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetPropertySafe(AbstractCallSite.java:333)
        at MapToHtmlDoc$_run_closure2_closure7.doCall(MapToHtmlDoc.groovy:609)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.groovy.reflection.CachedMethod.invoke$original$QIUFQKd5(CachedMethod.java:90)
        at org.codehaus.groovy.reflection.CachedMethod.invoke$original$QIUFQKd5$accessor$DvDsztiU(CachedMethod.java)
        at org.codehaus.groovy.reflection.CachedMethod$auxiliary$GqnZjQY4.call(Unknown Source)
        at org.freeplane.securegroovy.CachedMethodInvocationInterceptor.intercept(CachedMethodInvocationInterceptor.java:19)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
        at groovy.lang.Closure.call(Closure.java:423)
        at groovy.lang.Closure.call(Closure.java:439)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1304)
        at org.codehaus.groovy.runtime.dgm$150.invoke(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at MapToHtmlDoc$_run_closure2.doCall(MapToHtmlDoc.groovy:606)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.groovy.reflection.CachedMethod.invoke$original$QIUFQKd5(CachedMethod.java:90)
        at org.codehaus.groovy.reflection.CachedMethod.invoke$original$QIUFQKd5$accessor$DvDsztiU(CachedMethod.java)
        at org.codehaus.groovy.reflection.CachedMethod$auxiliary$GqnZjQY4.call(Unknown Source)
        at org.freeplane.securegroovy.CachedMethodInvocationInterceptor.intercept(CachedMethodInvocationInterceptor.java:19)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
        at groovy.lang.Closure.call(Closure.java:423)
        at groovy.lang.Closure.call(Closure.java:439)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1373)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1366)
        at org.codehaus.groovy.runtime.dgm$149.invoke(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at MapToHtmlDoc.run(MapToHtmlDoc.groovy:446)
        at org.freeplane.plugin.script.GroovyScript.execute(GroovyScript.java:141)
        at org.freeplane.plugin.script.ExecuteScriptAction.actionPerformed(ExecuteScriptAction.java:92)
        at org.freeplane.core.ui.AccelerateableAction.actionPerformed(AccelerateableAction.java:91)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
        at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
    
     
    • Alexandre

      Alexandre - 2017-11-22

      Hi Quinbus,

      Thanks I'm glad you like it. I shared it because it seemed it could be useful for me. Freeplane makes it so easy to organize and restructure information, so it is nice that the same easiness can be transposed to a document or a webpage.

      I have a tone of improvements, I have another list of todo items not in the demo map, but I may not be able to add everything.

      I never had the error you reported here but at the same time I don't check the logs often.

      You could try to comment out these lines:

       iconPath = iconsMap.get(iconName)?.value
      
      and 
      
      || it.attributes.findAll{it.key.toLowerCase()=='type' && (it.value.toLowerCase()=='private' || it.value.toLowerCase()=='NOEXPORT')}.size() > 0
      

      And run the script again. If there is no error it would mean one of these 2 lines is causing it.
      Then comment only 1 of them.

      Tell me which one it is.

      If you can share the map I could test it, if not then we will try to find the cause anyway.

      Thanks again,

      Alexandre

       
  • Quinbus

    Quinbus - 2017-11-22

    Alexandre,

    I knew the second bit of coding was working (I have nodes marked "Private" in attributes and the script works perfectly), so I commented out the entire subsection containing the iconpath definition and the script executed exactly as it was supposed to.

    There is another bit of code that I've had to manually change with each update because my installation doesn't like it. Its the bit defining Freeplane Paths. The script fails at the line defining the USER_PATH to the 1.6x freeplane directory. Doesn't like the line:

    def USER_PATH = 'C:/Users/' + System.getenv("USERNAME") + '/AppData/Roaming/Freeplane/1.6.x/'
    

    I have to replace the 'System.getenv("USERNAME")' with my hardcoded user name and then it works fine. The computer I'm using is Windows XP so more likely that's the problem rather than your system call.

    Thanks again,

    Q!

     
    • Alexandre

      Alexandre - 2017-11-23

      Hi Quinbus,

      I will try to fix these 2 issues.

      Could you wrap the icon path section you commented in try catch like:

      try {
      // Put commented icon path section here
      }
      catch (all) {
          m(n.plainText)
      }
      

      This should show the text in the node that cause the issue. Hopefully it will show.

      For the other issue it is more an issue with groovy/java interaction with the operating system, so the script may need to detect the OS and then select another method if it is XP.

      Thanks,

      Alexandre

       
  • Quinbus

    Quinbus - 2017-11-23

    Alexandre,

    When I made the change you suggested the script runs fine, whereas before it would fail with the message provided above. Of course there is the output dialog box with the names of the "offending" nodes, but the script completes and writes to the output file correctly.

    I think maybe I see what's happening with this particular mindmap. Some years ago I got into creating my own icons by downloading images from the internet and converting them to icons and using them as such. Think, for example, Google's logo. I would use this "icon" in the node so that a meaningful image would appear in the same space with node text. Some of these are quite large in size, which is what I wanted in those instances. Works well for the look I was trying to accomplish, but results in a "customized" list of icons with non-standard sizes and file names.

    I would be happy to share a map to illustrate how I use these specialized images.

    I'll be out of town for the next several days (American Thanksgiving holiday), returning Monday next.

    Q!

     
    • Alexandre

      Alexandre - 2017-11-23

      Hi Quinbus,

      Could you please try the latest version:

      https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDoc.groovy

      I tried to address the 2 issues.

      I added an empty try-catch to the icons section, and I changed method to retrieve the username property so you will not have to change it manually.

      Please let me know if it works for you with your map and on Windows XP.

      Best regards,

      Alexandre

       
      • Quinbus

        Quinbus - 2017-11-27

        Alexandre,

        Works perfectly!

        Thanks for your great knowledge and willingness to share it!

        Q!

         
  • Alexandre

    Alexandre - 2017-11-24

    Hi,

    I have updated a little bit the script, I changed the breadcrumbs, so that the first link of it show "Table of contents" and the last link which is the current section would not be highlighted.

    Also the code for the breadcrumbs are now in a function because it was duplicated 3 times.

    https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDoc.groovy

    You can see how it looks now (you may need to hit the refresh button of you browser):
    https://viaa.github.io/MapToHtmlDocDemoMap.html

    Best regards,

    Alexandre

     
  • Alexandre

    Alexandre - 2017-11-27

    Fixed a issue with breadcrumbs: If the document was generated from a branch, the breadcrumbs were still generated from the root node of the map. Seems fixed.

    https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDoc.groovy

     
  • Alexandre

    Alexandre - 2017-11-27

    I did some small modifications, one for example is the name of the output file and the prefix for the linked images and files will be the text of the root node of the selected branch not the map root node.

     
    • Quinbus

      Quinbus - 2017-11-27

      Alexandre

      Not exactly sure what the use case is supposed to be in such cases, but I notice that when I export just a branch of a map, the output name is blank, as in ".html." In otherwords the filename is empty. When I export the entire map (from the Root Node) the output file name is "NAMEOFMAP.html"

      Q!

       
      • Quinbus

        Quinbus - 2017-11-27

        No, no. So sorry. It's working fine! What happened is that I attempted to export a branch that was barred from export (Attribute 'Type' with a value of 'Private.') There was nothing to export, thus the blank filename.

        My bad.

        Q!

         
        • Alexandre

          Alexandre - 2017-11-28

          Hi Quinbus,

          I added an error message if the root node or the branch root node is an ignored node, then the script exits.

          https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDoc.groovy

          Best regards,

          Alexandre

           
      • Alexandre

        Alexandre - 2017-11-27

        Hi Quinbus,

        The script is supposed to take the text of the branch root and truncate it if too long and set it as the name of the document. Is there text in the branch root node? If yes what is it?

        Thanks,

        Alexandre

         
  • Mike Petonic

    Mike Petonic - 2017-11-29

    Hi Alexandre -- I submitted a PR for the script on Github. I wanted to make it support Macs as well, and it seems to. Please check it out and if it works for you and doesn't break it for Windows folks (I hope that it doesn't) then please accept it so that Mac users can benefit from this awesome script, too. Thanks for writing it and making it available!

     
    • Alexandre

      Alexandre - 2017-11-29

      Hi Mike,

      I included code to detect the os and change paths based on your code.

      I will make it available when I finish the next update which will upload the html file to github or to other locations.

      Best regards,

      Alexandre

       
  • Alexandre

    Alexandre - 2017-11-29

    Hi All,

    MapToHtmlDoc.groovy can now upload the exported html document to the web.

    The idea basically is that the root node's note or the branch root node's note (depending if you export a branch) contains a shell script (PortableGit required on Windows) that will do the file copying, uploading or git stuff to upload the document to the web. It can do anything basically that a shell script does. It is executed after the creation of the html document.

    I have only tested with Github for now. There is a sample script in the documentation section and in the demo map itself in its root node that is used to upload its html exported document to Github.

    You can see the demo map document section here:
    https://viaa.github.io/MapToHtmlDoc_-_Demo_Map.html#ID_1977730383

    There may still be things to adjust but I did a few test and it seems to work but still will need some adjustments.

    The latests version of the script and demo map:

    https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDoc.groovy
    https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDocDemoMap.mm

    Best regards,

    Alexandre

     
    • Alexandre

      Alexandre - 2017-11-29

      Hi,

      I did some modifications to the code that uploads to the web and to the documentation about that. The shell script to upload has also changed, there was a bug in it, and there was also a bug in the execution of the script, but these are fixed now.
      It works much better now, it is more solid. I will still test it and improve it as it goes.

      You may want to see the documentation section changes:
      https://viaa.github.io/MapToHtmlDoc_-_Demo_Map.html#ID_1977730383

      The script and the demo map:
      https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDoc.groovy
      https://raw.githubusercontent.com/viaa/FreeplaneScripts/master/MapToHtmlDocDemoMap.mm

      Now the root branch node has to have the icon named 'executable' to have the script run its note shell script. I added this because when designing the document locally I didn't want to press escape each time because of the password box.
      Also it could be that some users don't want to upload the document but still want to put something in the root branch note, so this way their note won't be "executed".

      Best regards,

      Alexandre

       
  • Alexandre

    Alexandre - 2017-12-29

    Hi,

    I have discovered an issue with the sample shell script included with the demo map.
    Basically what happens is that it copies files it should not to the repository. It doesn't copy only the files concerned with the map but also from other branches that were rendered as html doc.

    I have deactivated the running of the shell script after the document is created.

    I will let you know when this is fixed and will reactivate the running of the script.

    If you have your own script then there shouldn't be an issue uncommenting:

                        /* def proc = bashCmd.execute() */
                        /* proc.waitFor() */ 
    

    to re-activate it.

    Sorry for that.

    Thanks,

    Alexandre

     
  • Alexandre

    Alexandre - 2018-01-18

    Hi,

    I did small updates on the script, mainly the only visible difference is that the list items (nodes that start with * will be rendered using the bullet char instead of the

  • tag.

    --

    • Added a new variable rHtml, to distinguish rawtext from rawhtml. Raw text is text without any tags, raw html is the html extracted from a node text (without the html and body tags and enclosing paragraph.

    • List items (nodes starting with * are now replaced by the bullet char instead of the

    • tag, this allows indentation of list item)

    • The rawText() function now removes the tag, this was necessary to have text starting with ' ' in bold to be detected as a list item (as starting with ' ' so '* ' can be replaced by the bullet char.

    --

    Best regards,

    Alexandre

 
<< < 1 2 3 4 5 > >> (Page 4 of 5)