Updated Plugins (textile => markdown)
parent
0e6f74f1f0
commit
e2aae84726
2 changed files with 74 additions and 49 deletions
74
Plugins.md
Normal file
74
Plugins.md
Normal file
|
@ -0,0 +1,74 @@
|
|||
This is a example plugin to get you started. It removes posts which contain one of the stopwords. Save the code in a file `~/Library/Application Support/Tentia/Plugin.js`. You have to create this directory yourself.
|
||||
|
||||
You can add CSS too, create the file `~/Library/Application Support/Tentia/Plugin.css` where you can put your personal CSS.
|
||||
|
||||
***
|
||||
|
||||
## Hide posts with stopwords plugin
|
||||
|
||||
$(document).ready(function() {
|
||||
if(tentia_instance.action == "timeline") {
|
||||
tentia_instance.body.addEventListener( 'DOMNodeInserted', filter, false );
|
||||
}
|
||||
});
|
||||
|
||||
function filter(e) {
|
||||
var stopwords = [
|
||||
// Add the stopwords here
|
||||
"apple",
|
||||
"#iPhone"
|
||||
];
|
||||
var element = e.target;
|
||||
var parent = element.parentNode;
|
||||
if(parent != tentia_instance.body) return;
|
||||
var text = element.innerHTML;
|
||||
for(var i=0, count=stopwords.length; i<count; ++i) {
|
||||
if(text.indexOf(stopwords[i]) > -1) {
|
||||
parent.removeChild(element);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
You can use the embeded jQuery too, here for example a plugin which lets you mark particular posts so you don't forget them in your timeline:
|
||||
|
||||
## Mark post plugin
|
||||
|
||||
$("ol").delegate('a', 'click dblclick', function(e) {
|
||||
e.stopPropagation();
|
||||
}).delegate('li', 'dblclick', function(e) {
|
||||
var li = $(this);
|
||||
if(li.hasClass("selected")) {
|
||||
li.removeClass("selected");
|
||||
} else {
|
||||
li.addClass("selected");
|
||||
}
|
||||
});
|
||||
|
||||
And add this to your CSS plugin file.
|
||||
|
||||
.selected {
|
||||
border-right: 5px solid green;
|
||||
}
|
||||
|
||||
## Fuzzy location plugin
|
||||
|
||||
if (tentia_instance.action == "timeline") {
|
||||
(function() {
|
||||
var fuzzyness = 1; // Set how fuzzy it should be rounded. 0 ≈ country, 1 ≈ city, 6 = very exact
|
||||
function shortenDecimals(number, decimals) {
|
||||
return Math.round(number * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
||||
}
|
||||
tentia_instance.original_sendNewMessage = tentia_instance.sendNewMessage;
|
||||
tentia_instance.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location) {
|
||||
if (location) {
|
||||
location = [
|
||||
shortenDecimals(location[0], fuzzyness),
|
||||
shortenDecimals(location[1], fuzzyness)
|
||||
];
|
||||
}
|
||||
tentia_instance.original_sendNewMessage(content, in_reply_to_status_id, in_reply_to_entity, location);
|
||||
}
|
||||
})();
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
This is a example plugin to get you started. It removes posts which contain one of the stopwords. Save the code in a file @~/Library/Application Support/Tentia/Plugin.js@. You have to create this directory yourself.
|
||||
|
||||
``` js
|
||||
$(document).ready(function() {
|
||||
if(tentia_instance.action == "timeline") {
|
||||
tentia_instance.body.addEventListener( 'DOMNodeInserted', filter, false );
|
||||
}
|
||||
});
|
||||
function filter(e) {
|
||||
var stopwords = [
|
||||
// Add the stopwords here
|
||||
"apple",
|
||||
"#iPhone"
|
||||
];
|
||||
var element = e.target;
|
||||
var parent = element.parentNode;
|
||||
if(parent != tentia_instance.body) return;
|
||||
var text = element.innerHTML;
|
||||
for(var i=0, count=stopwords.length; i<count; ++i) {
|
||||
if(text.indexOf(stopwords[i]) > -1) {
|
||||
parent.removeChild(element);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can use the embeded jQuery too, here for example a plugin which lets you mark particular posts so you don't forget them in your timeline:
|
||||
|
||||
``` js
|
||||
$("ol").delegate('a', 'click dblclick', function(e) {
|
||||
e.stopPropagation();
|
||||
}).delegate('li', 'dblclick', function(e) {
|
||||
var li = $(this);
|
||||
if(li.hasClass("selected")) {
|
||||
li.removeClass("selected");
|
||||
} else {
|
||||
li.addClass("selected");
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
And you can add CSS too, create the file @~/Library/Application Support/Tentia/Plugin.css@ where you can put your personal CSS:
|
||||
|
||||
``` css
|
||||
.selected {
|
||||
border-right: 5px solid green;
|
||||
}
|
||||
```
|
Reference in a new issue