From d7b657cb6467343cbc3c051c5038a0eaac5c6789 Mon Sep 17 00:00:00 2001 From: Michael Owens Date: Fri, 6 Dec 2013 10:21:35 +0100 Subject: [PATCH 1/6] Allow for tags at the end of an event with square brackets, e.g. [job] --- index.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index efdca7c..a860a9a 100644 --- a/index.html +++ b/index.html @@ -144,10 +144,13 @@

Life

list.forEach(function(l){ var matches = l.match(/\-\s+([\d\/\-\~]+)\s(.*)/i); var time = matches[1]; - var text = matches[2]; + var tagindex = matches[2].indexOf('['); + var text = matches[2].substring(0, tagindex); + var tag = (tagindex > -1 ? matches[2].substring(tagindex).replace(/[\[|\]]/gi, '') : ''); data.push({ time: life.parseTime(time), - text: text + text: text, + tag: tag }); }); return data; @@ -230,7 +233,7 @@

Life

} } - return '
' + d.time.title + ' ' + d.text + '  
'; + return '
' + d.time.title + ' ' + d.text + '  
'; return ''; }, render: function(title, data){ From 6ad29fcb454363d7ef36bace626178cadb2c8b54 Mon Sep 17 00:00:00 2001 From: Michael Owens Date: Fri, 6 Dec 2013 10:37:36 +0100 Subject: [PATCH 2/6] Improved tags to look for the last square brackets, so markdown links etc. still work. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 4f9e70e..796c71b 100644 --- a/index.html +++ b/index.html @@ -161,7 +161,7 @@

Life

list.forEach(function(l){ var matches = l.match(/\-\s+([\d\/\-\~]+)\s(.*)/i); var time = matches[1]; - var tagindex = matches[2].indexOf('['); + var tagindex = matches[2].lastIndexOf('['); var text = matches[2].substring(0, tagindex); var tag = (tagindex > -1 ? matches[2].substring(tagindex).replace(/[\[|\]]/gi, '') : ''); data.push({ From 4d28a5e5aa8fc16ce95f4c3378c6189a9c161cfa Mon Sep 17 00:00:00 2001 From: Michael Owens Date: Fri, 6 Dec 2013 11:00:24 +0100 Subject: [PATCH 3/6] Fixed events without tags --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 796c71b..765657d 100644 --- a/index.html +++ b/index.html @@ -162,7 +162,7 @@

Life

var matches = l.match(/\-\s+([\d\/\-\~]+)\s(.*)/i); var time = matches[1]; var tagindex = matches[2].lastIndexOf('['); - var text = matches[2].substring(0, tagindex); + var text = (tagindex > -1 ? matches[2].substring(0, tagindex) : matches[2]); var tag = (tagindex > -1 ? matches[2].substring(tagindex).replace(/[\[|\]]/gi, '') : ''); data.push({ time: life.parseTime(time), From 71fa8feaec92adb79389b91a12dbec20237a04f2 Mon Sep 17 00:00:00 2001 From: Michael Owens Date: Sat, 7 Dec 2013 16:47:02 +0100 Subject: [PATCH 4/6] Added .gitignore with config.json, life.md and phpstorm/webstorm project files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7c0dcfc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +config.json +life.md \ No newline at end of file From b6bd728e3364f86c1e9b3bfb40b7003e7c2661b5 Mon Sep 17 00:00:00 2001 From: Michael Owens Date: Sat, 7 Dec 2013 16:59:25 +0100 Subject: [PATCH 5/6] Added hashtags with a config to hide or show them --- config.example.json | 3 ++- index.html | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/config.example.json b/config.example.json index 83ce44a..927988d 100644 --- a/config.example.json +++ b/config.example.json @@ -1,5 +1,6 @@ { "customStylesheetURL": null, "yearLength": 120, - "hideAge": false + "hideAge": false, + "hideTags": false } \ No newline at end of file diff --git a/index.html b/index.html index 765657d..a7e9447 100644 --- a/index.html +++ b/index.html @@ -112,6 +112,7 @@

Life

config: { yearLength: 120, // 120px per year hideAge: false, // Hide age from year axis + hideTags: false, customStylesheetURL: null // Custom stylesheet }, start: function(){ @@ -161,13 +162,15 @@

Life

list.forEach(function(l){ var matches = l.match(/\-\s+([\d\/\-\~]+)\s(.*)/i); var time = matches[1]; - var tagindex = matches[2].lastIndexOf('['); - var text = (tagindex > -1 ? matches[2].substring(0, tagindex) : matches[2]); - var tag = (tagindex > -1 ? matches[2].substring(tagindex).replace(/[\[|\]]/gi, '') : ''); + var tags = []; + var text = matches[2].replace(/#(\w+)/gi, function (hashtag, cleantag) { + tags.push(cleantag); + return (life.config.hideTags ? '' : hashtag); + }); data.push({ time: life.parseTime(time), text: text, - tag: tag + tags: tags }); }); return data; @@ -262,7 +265,7 @@

Life

} return '
' - + '
' + + '
' + '' + d.time.title + ' ' + d.text + '  ' + '
'; return ''; From e69a81022618dc62e7d003cbc3ed188dc865ba01 Mon Sep 17 00:00:00 2001 From: Michael Owens Date: Sat, 7 Dec 2013 17:31:53 +0100 Subject: [PATCH 6/6] Moved tag classes to the .event div and prepended with "tag-" --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index a7e9447..76f602a 100644 --- a/index.html +++ b/index.html @@ -164,7 +164,7 @@

Life

var time = matches[1]; var tags = []; var text = matches[2].replace(/#(\w+)/gi, function (hashtag, cleantag) { - tags.push(cleantag); + tags.push('tag-' + cleantag); return (life.config.hideTags ? '' : hashtag); }); data.push({ @@ -264,8 +264,8 @@

Life

d.text = d.text.replace(link[0], "" + link[1] + ""); } - return '
' - + '
' + return '
' + + '
' + '' + d.time.title + ' ' + d.text + '  ' + '
'; return '';