Skip to content

Commit

Permalink
yarr@jtoberling: Enhancements, V1.0.0 release (#931)
Browse files Browse the repository at this point in the history
* Update desklet.js

Fix missing class

* V1.0.0
  • Loading branch information
jtoberling authored Oct 17, 2023
1 parent 7ff5a28 commit 323a6de
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 27 deletions.
114 changes: 91 additions & 23 deletions yarr@jtoberling/files/yarr@jtoberling/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ class YarrDesklet extends Desklet.Desklet {

delay = 300;

refreshEnabled = true;

httpSession = null;

xmlutil = null;

ITEMLIMIT = 100;
items = new Map();

dataBox = null; // Object holder for display
Expand All @@ -52,9 +53,11 @@ class YarrDesklet extends Desklet.Desklet {
this.settings.bind("height", "height", this.onDisplayChanged);
this.settings.bind("width", "width", this.onDisplayChanged);
this.settings.bind("transparency", "transparency", this.onDisplayChanged);
this.settings.bind("backgroundColor", "backgroundColor", this.backgroundColor);
this.settings.bind("font", "font", this.onSettingsChanged);
this.settings.bind("text-color", "color", this.onSettingsChanged);
this.settings.bind("backgroundColor", "backgroundColor", this.onDisplayChanged);
this.settings.bind("font", "font", this.onDisplayChanged);
this.settings.bind("text-color", "color", this.onDisplayChanged);
this.settings.bind("numberofitems", "itemlimit", this.onSettingsChanged, 50);
this.settings.bind("listfilter", "listfilter", this.onSetttingChanged);

if (Soup.MAJOR_VERSION === 2) {
this.httpSession = new Soup.SessionAsync();
Expand All @@ -64,8 +67,9 @@ class YarrDesklet extends Desklet.Desklet {

this._signals = new SignalManager.SignalManager(null);

this.buildInitialDisplay();
this.onDisplayChanged();
this.onSettingsChanged();
this.buildDisplay();

this.setUpdateTimer(1);

Expand All @@ -84,6 +88,11 @@ class YarrDesklet extends Desklet.Desklet {


onSettingsChanged() {
this.setUpdateTimer(1);
}

onDisplayChanged() {

let fontprep = this.font.split(' ');
let fontsize = fontprep.pop();
let fontweight = '';
Expand Down Expand Up @@ -111,15 +120,8 @@ class YarrDesklet extends Desklet.Desklet {
"text-shadow: " + "0px 1px 6px rgba(" + this.invertbrightness(this.color) + ", 0.2); " +
"padding: 2px 2px;").toLowerCase();

this.setUpdateTimer(1);
}

onDisplayChanged() {
this.mainBox.set_size(this.width, this.height);
this.setTransparency();
}

setTransparency() {
this.mainBox.style = "background-color: rgba(" + (this.backgroundColor.replace('rgb(', '').replace(')', '')) + "," + this.transparency + ")";
}

Expand Down Expand Up @@ -209,7 +211,21 @@ class YarrDesklet extends Desklet.Desklet {
this.setUpdateTimer(3);
}

buildDisplay() {
onClickedToggleRefresh(selfObj, p2, context) {

if (context.refreshEnabled) {
context.toggleRefresh.set_label(_('Enable refresh'));
context.toggleRefresh.set_style_class_name('toggleButtonOff');
context.refreshEnabled = false;
} else {
context.toggleRefresh.set_label(_('Disable refresh'));
context.toggleRefresh.set_style_class_name('toggleButtonOn');
context.refreshEnabled = true;
context.setUpdateTimer(3);
}
}

buildInitialDisplay() {

this.setHeader(_('Yarr'));

Expand All @@ -225,24 +241,28 @@ class YarrDesklet extends Desklet.Desklet {

this.headTitle = new St.Label({});

this.headTitle.set_text('Loading: feeds ...' );
this.headTitle.set_text(_('Loading: feeds ...' ));

let paddingBox = new St.Bin({ width: 10 });

this.refreshButton = new St.Button();
this.refreshButton = new St.Button({style_class: 'feedRefreshButton'});
this.refreshIcon = new St.Icon({
icon_name: 'reload',
icon_size: 20,
icon_type: St.IconType.SYMBOLIC
});
this.refreshButton.set_child(this.refreshIcon);
this.refreshButton.connect("clicked", Lang.bind(this, this.onRefreshClicked));


this.toggleRefresh = new St.Button({ label: _("Disable refresh"), style_class: 'toggleButtonOn'});
let context = this;
this._signals.connect( this.toggleRefresh, 'clicked', (...args) => this.onClickedToggleRefresh(...args, this) );

this.headBox.add(this.headTitle);
this.headBox.add(paddingBox, { expand: true });
this.headBox.add_actor(this.toggleRefresh);
this.headBox.add_actor(this.refreshButton);

this.mainBox.add(this.headBox);


Expand All @@ -256,9 +276,6 @@ class YarrDesklet extends Desklet.Desklet {

this.setContent(this.mainBox);

this.setTransparency();


}

hashCode(str) {
Expand Down Expand Up @@ -287,14 +304,61 @@ class YarrDesklet extends Desklet.Desklet {
let i=0;
for( let [key, value] of context.items ) {
i++;
if (i > context.ITEMLIMIT) {
if (i > context.itemlimit) {
context.items.delete(key);
}
}
}

inGlobalFilter(context, title, catStr, description) {

let found = false;

let itemRegexArr = [];


for(let i=0; i < context.listfilter.length ; i++ ) {

let filterElem = context.listfilter[i];

if (filterElem.active) {
if (filterElem.unmatch) {
found = true;
}

let itemRegexp = new RegExp(filterElem.filter);

if (filterElem.inTitle) {
if (itemRegexp.test(title)) {
found = (filterElem.unmatch)?false:true;
break;
}
}

if (filterElem.inCategory) {
if (itemRegexp.test(catStr)) {
found = (filterElem.unmatch)?false:true;
break;
}
}

if (filterElem.inDescription) {
if (itemRegexp.test(description)) {
found = (filterElem.unmatch)?false:true;
break;
}
}
}
}
return found;
}

collectFeeds() {

if (!this.refreshEnabled) {
return;
}

let freshItems = [];

for(let i=0; i < this.feeds.length; i++ ) {
Expand All @@ -308,7 +372,7 @@ class YarrDesklet extends Desklet.Desklet {
null, // headers
null, // post
function(context, message, result) {

let resJSON = null;
try {
resJSON = fromXML(result);
Expand All @@ -326,6 +390,10 @@ class YarrDesklet extends Desklet.Desklet {
doInsert = feedRegexp.test(catStr);
}

if (context.listfilter.length > 0 && context.inGlobalFilter(context, item.title, catStr, item.description)) {
doInsert = false;
}

if (doInsert) {
let parsedDate = new Date(item.pubDate);
context.additems(
Expand All @@ -343,7 +411,7 @@ class YarrDesklet extends Desklet.Desklet {
);
}
}

context.displayItems(context);

} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions yarr@jtoberling/files/yarr@jtoberling/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"max-instances": "1",
"description": "Yet Another RSS Reader - now as Cinnamon Desklet",
"name": "Yet Another RSS Reader",
"version": "0.0.4",
"version": "1.0.0",
"uuid": "yarr@jtoberling",
"multiversion": true,
"author": "jtoberling",
"prevent-decorations": true
}
}
25 changes: 24 additions & 1 deletion yarr@jtoberling/files/yarr@jtoberling/settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@
"default": "rgb(255,255,255)",
"description": "Text color",
"tooltip": "Click the button to select a new text color"
}
},
"numberofitems": {
"type": "spinbutton",
"default": 50,
"min": 10,
"max": 300,
"step": 1,
"description": "Number of displayed articles",
"tooltip": "Number of displayed articles in the list window."
},
"listfilter" : {
"type" : "list",
"description" : "Message RegExp filters",
"columns" : [
{"id": "name", "title": "Name", "type": "string"},
{"id": "active", "title": "Active", "type": "boolean" , "default": true },
{"id": "unmatch", "title": "Unmatch", "type": "boolean" , "default": false },
{"id": "filter", "title": "Filter (Regexp eg: '.*')", "type": "string", "default": "", "description": "Regexp filter on channels", "tooltip": "Leave empty for all"},
{"id": "inTitle", "title": "Match in Title", "type": "boolean", "default": true },
{"id": "inCategory", "title": "Match in Category", "type": "boolean", "default": true },
{"id": "inDescription", "title": "Match in Description", "type": "boolean", "default": false }
],
"default" : []
}
}

37 changes: 36 additions & 1 deletion yarr@jtoberling/files/yarr@jtoberling/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,39 @@
.quotes-reader {
border-radius: 8px;
padding: 4px 4px;
}
}


.toggleButtonOn {
border-radius: 8px;
padding: 4px 4px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
color: white;
background-color: green;
}

.toggleButtonOff {
border-radius: 8px;
padding: 4px 4px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
color: white;
background-color: maroon;
}

.feedRefreshButton {
border-radius: 8px;
padding: 4px 4px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
color: white;
background-color: navz;
}

0 comments on commit 323a6de

Please sign in to comment.