TiddlyMap edge node styling by namespace

118 views
Skip to first unread message

Greg Hodgins

unread,
Dec 30, 2016, 8:44:11 AM12/30/16
to TiddlyWiki
I could have sworn I'd already done this, but perhaps not.  I can't crack it this AM after 30 minutes of searching.

Can I apply a style to TiddlyMap edge nodes based on namespace?

eg: I have several nodes such as clear: one, clear: two, clear: three, token: one, token: two, token:three

I want the clear edge nodes to be red while the token edge nodes are green - without visiting each of them individually.

Thanks.

P.S.  Is this group the correct group for TM questions????

Felix Küppers

unread,
Dec 30, 2016, 12:21:08 PM12/30/16
to tiddl...@googlegroups.com
Hi Greg,


Can I apply a style to TiddlyMap edge nodes based on namespace?

can you clarify what you mean by "edge nodes"?
Do you mean edges or nodes?

I assume you are talking about "edges". In this case you cannot mix edge styles based on a shared criteria (e.g. a common namespace) as it would be possible with node styles. Edges can only be styled via their assigned edge type.

Maybe at one point I will introduce a more advanced mechanism for styling edgetypes but this would require a massive code change and is not likely to come in the future. I still hope you can somehow manage to organize your maps!


P.S.  Is this group the correct group for TM questions????

In case of questions that are more TiddlyMap specific, such as yours, which do not directly involve or target "core" TiddlyWiki concepts, I think it is better to post them at TiddlyMap's GitHub repository. Nonetheless, since TiddlyMap is build on top of TiddlyWiki and some people in the community are using the plugin, you may be able to get some answers to your questions in this forum as well.

-Felix
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/12459010-94dc-42c8-915b-0cf955b5d272%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Greg Hodgins

unread,
Dec 30, 2016, 12:50:36 PM12/30/16
to TiddlyWiki
You guessed correctly on "edges".  I thought I recalled edges being referred to as edge nodes, but will drop that. :-)

I'll manage with some more manual effort.  I should learn how to script a little as I imagine it shouldn't be too difficult to find all the edges with a namespace and update their colour attribute.  Worst case I imagine I could perform some kind of search and replace on the underlying tiddlers.  As I write this I am left thinking I need to check and see if edges are represented by tiddlers.

I'll experiment further - no problem.  I just didn't want to continue spinning if it were something obviously I was missing.  I must have been thinking of node types.

Thanks as always.


On Friday, December 30, 2016 at 12:21:08 PM UTC-5, Felix Küppers wrote:
Hi Greg,

Can I apply a style to TiddlyMap edge nodes based on namespace?

can you clarify what you mean by "edge nodes"?
Do you mean edges or nodes?

I assume you are talking about "edges". In this case you cannot mix edge styles based on a shared criteria (e.g. a common namespace) as it would be possible with node styles. Edges can only be styled via their assigned edge type.

Maybe at one point I will introduce a more advanced mechanism for styling edgetypes but this would require a massive code change and is not likely to come in the future. I still hope you can somehow manage to organize your maps!

P.S.  Is this group the correct group for TM questions????

In case of questions that are more TiddlyMap specific, such as yours, which do not directly involve or target "core" TiddlyWiki concepts, I think it is better to post them at TiddlyMap's GitHub repository. Nonetheless, since TiddlyMap is build on top of TiddlyWiki and some people in the community are using the plugin, you may be able to get some answers to your questions in this forum as well.

-Felix

On 12/30/2016 02:44 PM, Greg Hodgins wrote:
I could have sworn I'd already done this, but perhaps not.  I can't crack it this AM after 30 minutes of searching.

Can I apply a style to TiddlyMap edge nodes based on namespace?

eg: I have several nodes such as clear: one, clear: two, clear: three, token: one, token: two, token:three

I want the clear edge nodes to be red while the token edge nodes are green - without visiting each of them individually.

Thanks.

P.S.  Is this group the correct group for TM questions????
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tidd...@googlegroups.com.

Greg Hodgins

unread,
Jan 2, 2017, 9:01:59 AM1/2/17
to TiddlyWiki
I thought I would share what I did to style my edges by namespace.  Basically I manipulated the files with sed based on filenames that include the namespace.

Initially I tried exporting the map to a JSON file, one edge of which was styled as desired with a simple colour change.  I added the color element to some more of the edges in the JSON and imported them back in.  However, while TW would see the file as an import file it would never indicate there were any tiddlers to import and indeed never imported anything. After a bit of fiddling I moved on.  It might be nice to know why this didn't work.

{
  "edges": [
    {
      "id": "9ed087ce-abff-48df-a043-18afab924a18",
      "from": "51b38c02-0bf1-4de0-b391-1cc0dfe96476",
      "to": "c04185d7-ea68-4ca1-8125-98cdbf5e9187",
      "type": "flow clear:  POS_BLTYESBP",
      "label": "  POS_BLTYESBP",
      "color": {
        "color": "rgba(209,19,26,1)"
      }
    },
    {
      "id": "7f7c655d-8408-42c4-a0cb-d296dbfd3a18",
      "from": "d1a1826b-bd43-4b99-9055-f75f2b5e028f",
      "to": "2bdf023d-580b-4201-96f6-c81ecdc51a7d",
      "type": "flow clear:  APIGW_LDMS",
      "label": "  APIGW_LDMS"


Aside from the lengthy names that start with a dollar sign (why? - I'm certain there is a good reason but you have to escape the dollar sign at times), the edge tiddlers themselves are obviously quite simple as seen below.

created: 20161230124851953
description: Clear [[POS Services|POS_BLTYESBP]]
modified: 20161231214952583
style: {"color":{"color":"rgba(255,0,0,1)"}}
title: $:/plugins/felixhayashi/tiddlymap/graph/edgeTypes/flow clear:  POS_BLTYESBP
type: text/vnd.tiddlywiki

With some concern over ordering (the file with style added through TW had the color statement in the middle of the file), I used sed to append different color statements to the last line of the file based on the file name that included my name space of flow_clear or flow_token.

find . -name "*flow_clear*" -exec sed -i '$ a style: {"color":{"color":"rgba(255,0,0,1)"}}' {} \;
find . -name "*flow_token*" -exec sed -i '$ a style: {"color":{"color":"rgba(0,255,0,1)"}}' {} \;   

While the files were being updated I was getting some funky results - things not updating even after a restart of the server.  I noticed that some files were showing an extended access control indicator with a plus sign at the end of the permissions. (rw_rw_r__+)  On getting the extended acl with getfacl, the file name appeared garbage.  It just showed ".tid".  A little playing around revealed either I cannot or should not be editing these files with the node server is up. I'm not sure if this is expected/common of something to do with the Google Drive drivers, but stopping the server, doing the editing, and starting worked.  Also note that the Google Drive access is VERY slow.  I am mildly concerned.

Finally, one other niggle during the process caused a little consternation. The changes were still not showing up given the combination of the sed command I used and the construct of the file.  It turned out to be the blank line above my new color statement.  The following sed command removed the blank lines.

find . -name "*flow_token*" -exec sed -i '/^$/d' {} \;

I'd love to figure out how to script this from within TW, but working with some more familiar tools (even though it's probably been almost 10 years since I've actively used Linux) got the job done for now.

Greg 

Felix Küppers

unread,
Jan 5, 2017, 4:54:18 PM1/5/17
to TiddlyWiki
Hi Greg,


Initially I tried exporting the map to a JSON file, one edge of which was styled as desired with a simple colour change.  I added the color element to some more of the edges in the JSON and imported them back in.  However, while TW would see the file as an import file it would never indicate there were any tiddlers to import and indeed never imported anything. After a bit of fiddling I moved on.  It might be nice to know why this didn't work.

This json is only "export" only, this doesn't work as import. I agree this is a bit confusing...
 

{
  "edges": [
    {
      "id": "9ed087ce-abff-48df-a043-18afab924a18",
      "from": "51b38c02-0bf1-4de0-b391-1cc0dfe96476",
      "to": "c04185d7-ea68-4ca1-8125-98cdbf5e9187",
      "type": "flow clear:  POS_BLTYESBP",
      "label": "  POS_BLTYESBP",
      "color": {
        "color": "rgba(209,19,26,1)"
      }
    },
    {
      "id": "7f7c655d-8408-42c4-a0cb-d296dbfd3a18",
      "from": "d1a1826b-bd43-4b99-9055-f75f2b5e028f",
      "to": "2bdf023d-580b-4201-96f6-c81ecdc51a7d",
      "type": "flow clear:  APIGW_LDMS",
      "label": "  APIGW_LDMS"


Aside from the lengthy names that start with a dollar sign (why? - I'm certain there is a good reason but you have to escape the dollar sign at times), the edge tiddlers themselves are obviously quite simple as seen below.

The dollar sign marks the tiddler as "system tiddler".
 

created: 20161230124851953
description: Clear [[POS Services|POS_BLTYESBP]]
modified: 20161231214952583
style: {"color":{"color":"rgba(255,0,0,1)"}}
title: $:/plugins/felixhayashi/tiddlymap/graph/edgeTypes/flow clear:  POS_BLTYESBP
type: text/vnd.tiddlywiki

With some concern over ordering (the file with style added through TW had the color statement in the middle of the file), I used sed to append different color statements to the last line of the file based on the file name that included my name space of flow_clear or flow_token.

however, make sure you are not breaking the json format using sed ;)
 
I'd love to figure out how to script this from within TW, but working with some more familiar tools (even though it's probably been almost 10 years since I've actively used Linux) got the job done for now.

within tw and your browser, your js-console is your only option. Maybe I find the time to post a js console command that iterates over all edges with a given name and adds a certain property (e.g. color) to it...


Best wishes
Felix
Reply all
Reply to author
Forward
0 new messages