Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for tags/hashtags, e.g. #job (updated) #34

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
config.json
life.md
3 changes: 2 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"customStylesheetURL": null,
"yearLength": 120,
"hideAge": false
"hideAge": false,
"hideTags": false
}
12 changes: 9 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ <h1 id="title">Life</h1>
config: {
yearLength: 120, // 120px per year
hideAge: false, // Hide age from year axis
hideTags: false,
customStylesheetURL: null // Custom stylesheet
},
start: function(){
Expand Down Expand Up @@ -161,10 +162,15 @@ <h1 id="title">Life</h1>
list.forEach(function(l){
var matches = l.match(/\-\s+([\d\/\-\~]+)\s(.*)/i);
var time = matches[1];
var text = matches[2];
var tags = [];
var text = matches[2].replace(/#(\w+)/gi, function (hashtag, cleantag) {
tags.push('tag-' + cleantag);
return (life.config.hideTags ? '' : hashtag);
});
data.push({
time: life.parseTime(time),
text: text
text: text,
tags: tags
});
});
return data;
Expand Down Expand Up @@ -258,7 +264,7 @@ <h1 id="title">Life</h1>
d.text = d.text.replace(link[0], "<a href='" + link[2] + "'" + link_attr + ">" + link[1] + "</a>");
}

return '<div class="event" style="margin-left: ' + offset.toFixed(2) + 'px">'
return '<div class="event ' + d.tags.join(' ') + '" style="margin-left: ' + offset.toFixed(2) + 'px">'
+ '<div class="time" style="width: ' + width.toFixed(2) + 'px"></div>'
+ '<b>' + d.time.title + '</b> ' + d.text + '&nbsp;&nbsp;'
+ '</div>';
Expand Down