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

replace jquery rssparser that used the google api that is not availab… #1228

Merged
merged 2 commits into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion compile.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"indexedDB",
"URL",
"sinon",
"XMLDocument"
"XMLDocument",
"RSSParser"
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@
"Node": "readonly",
"indexedDB": "readonly",
"URL": "readonly",
"sinon": "readonly"
"sinon": "readonly",
"RSSParser": "readonly"
}
}
}
99 changes: 90 additions & 9 deletions source/class/cv/plugins/Rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@


/**
* This plugins integrates zrssfeed to display RSS-Feeds via Google-API
* and a parser for local feeds using jQuery 1.5+ into CometVisu.
* rssfeedlocal is derived from simplerss and zrssfeed
* rssfeedlocal is mainly meant to be used with rsslog.php and plugins
* This plugins displays RSS-Feeds in the CometVisu.
*
* <pre class="sunlight-highlight-xml">
* &lt;rss src=&quot;/visu/plugins/rss/rsslog.php&quot; refresh=&quot;300&quot; link=&quot;false&quot; title=&quot;false&quot;&gt;&lt;/rss&gt;
Expand All @@ -32,7 +29,8 @@
*
* @author Michael Markstaller
* @since 2011
* @asset(plugins/rss/dep/zrssfeed/jquery.zrssfeed.js)
* @ignore(RSSParser)
* @asset(plugins/rss/rss-parser.min.js)
*/
qx.Class.define('cv.plugins.Rss', {
extend: cv.ui.structure.AbstractWidget,
Expand Down Expand Up @@ -106,15 +104,18 @@ qx.Class.define('cv.plugins.Rss', {
******************************************************
*/
members: {
_parser: null,

_getInnerDomString: function () {
const rssstyle = '' +
this.getWidth() ? 'width:' + this.getWidth() : '' +
this.getHeight() ? 'height:' + this.getHeight() : '';
return '<div class="actor"><div class="rss_inline" id="rss_' + this.getPath() + '" style="' + rssstyle + '"></div>';
return '<div class="actor"><ul class="rss_inline" style="' + rssstyle + '"></ul>';
},

_onDomReady: function () {
this.base(arguments);
this._parser = new RSSParser();
this.refreshRSS();
},

Expand All @@ -127,14 +128,94 @@ qx.Class.define('cv.plugins.Rss', {
},

refreshRSS: function () {
const data = cv.data.Model.getInstance().getWidgetData(this.getPath());
$('#' + this.getPath() + ' .rss_inline').rssfeed(this.getSrc(), data);
this._parser.parseURL(this.getSrc(), (err, feed) => {
const actor = this.getActor();
let target = actor.querySelector('.rss_inline');
if (err) {
this.error(err);
if (this.getShowerror()) {
target.textContent = 'ERROR: ' +err;
}
return;
}
if (this.getHeader()) {
let headline = actor.querySelector(':scope > h3');
if (!headline) {
headline = document.createElement('h3');
actor.insertBefore(headline, actor.firstElementChild);
}
headline.textContent = feed.title;
}

const elements = target.querySelectorAll(':scope > li');
for (let i = elements.length; i >= feed.items.length; i--) {
elements[i].remove();
}

const useLink = this.getLink();
const showContent = this.getContent();
const showDate = this.getDate();

feed.items.some((entry, i) => {
let elem = target.querySelector(':scope > li[data-row="'+i+'"]');
let a;
let content;
let date;
if (!elem) {
elem = document.createElement('li');
if (useLink) {
a = document.createElement('a');
a.setAttribute('target', this.getLinktarget());
elem.appendChild(a);
}
if (showContent) {
content = document.createElement('p');
content.classList.add('content');
elem.appendChild(content);
}
if (showDate) {
date = document.createElement('p');
date.classList.add('date');
elem.appendChild(date);
}
elem.setAttribute('data-row', ''+i);
target.appendChild(elem);
} else {
if (useLink) {
a = elem.querySelector(':scope > a');
}
if (showContent) {
content = elem.querySelector(':scope > p.content');
}
if (showDate) {
date = elem.querySelector(':scope > p.date');
}
}
if (useLink) {
a.textContent = entry.title;
a.setAttribute('href', entry.link);
} else {
elem.textContent = entry.title;
}
if (showContent) {
content.innerHTML = this.getSnippet() ? entry.contentSnippet : entry.content;
}
if (showDate) {
date.innerText = new Date(entry.isoDate).toLocaleString();
}
return i >= this.getLimit();
});
});
}
},

destruct: function() {
this._parser = null;
},

defer: function(statics) {
const loader = cv.util.ScriptLoader.getInstance();
loader.addScripts('plugins/rss/dep/zrssfeed/jquery.zrssfeed.js');
loader.addScripts('plugins/rss/rss-parser.min.js');
cv.parser.WidgetParser.addHandler('rss', cv.plugins.Rss);
cv.ui.structure.WidgetFactory.registerClass('rss', statics);
}
Expand Down
4 changes: 2 additions & 2 deletions source/resource/designs/metal/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,11 @@ div#demo_3 {
/* END: alignment of widgets */

/* fixes for plugin line-heights */
.widget .actor.rsslogBody, .widget .actor .diagram_inline {
.widget .actor.rsslogBody, .widget .actor .diagram_inline, .widget .actor .rss_inline {
line-height: normal;
}

.rsslog_popup ul li a { color: inherit; }
.rsslog_popup ul li a, ul.rss_inline li a { color: inherit; }


/*****************************************************************************/
Expand Down
77 changes: 0 additions & 77 deletions source/resource/plugins/rss/dep/zrssfeed/jquery.vticker.js

This file was deleted.

55 changes: 0 additions & 55 deletions source/resource/plugins/rss/dep/zrssfeed/jquery.zrssfeed.css

This file was deleted.