diff --git a/server/euronews.js b/server/euronews.js
index ab6acfc..ca98ccd 100644
--- a/server/euronews.js
+++ b/server/euronews.js
@@ -42,9 +42,11 @@ function doGetEuroNews() {
return new Promise((resolve, reject) => {
logger.info('Retrieving Euronews Headlines..');
+ // http://feeds.feedburner.com/euronews/en/home/
+ // http://feeds.feedburner.com/euronews/en/news/
const options = {
'hostname': 'feeds.feedburner.com',
- 'path': '/euronews/en/news/',
+ 'path': '/euronews/en/home/',
'method': 'GET',
'headers': headers
};
diff --git a/src/css/custom.scss b/src/css/custom.scss
index a362f6b..6890a6a 100644
--- a/src/css/custom.scss
+++ b/src/css/custom.scss
@@ -299,10 +299,10 @@ li {
}
#newsShell {
- height:225px;
+ /* height:225px;*/
}
#news{
- height: 275px;
+ height: 200px;
margin-top:15px;
}
diff --git a/src/service-worker.js b/src/service-worker.js
index 59aa446..c730c8c 100644
--- a/src/service-worker.js
+++ b/src/service-worker.js
@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-const CACHE_VERSION = { 'version': '0.0.401' };
+const CACHE_VERSION = { 'version': '0.0.464' };
const dataCacheName = 'jubileeData-v1';
const cacheName = 'jubilee-final-1';
const filesToCache = [
diff --git a/src/v1/index.html b/src/v1/index.html
index f1dba0c..ad2b83b 100644
--- a/src/v1/index.html
+++ b/src/v1/index.html
@@ -63,6 +63,9 @@
diff --git a/src/v1/js/News.js b/src/v1/js/News.js
index 64346a0..5a8a5b8 100644
--- a/src/v1/js/News.js
+++ b/src/v1/js/News.js
@@ -104,6 +104,14 @@ const NewsModel = Backbone.Model.extend({
const NewsView = Backbone.View.extend({
'className': '',
+ 'template': _.template(`
+
Latest news
+
+
+ arrow_forward More news
+
+ `),
+
'initialize': function(options) {
this.eventBus = options.eventBus;
this.newsCollection = newsCollection;
@@ -127,15 +135,21 @@ const NewsView = Backbone.View.extend({
this.$el.empty();
+ this.$el.append(this.template());
+
+ this.$news = this.$el.find('#news');
+
this.newsCollection.each(function(item) {
const niView = new newsItemView({ 'model': item });
- this.$el.append(niView.el);
+
+ this.$news.append(niView.el);
}, this);
- this.$el.parent().show();
- // console.log(this.$el.parent());
+ this.$el.show();
}, 'events': {
+ 'click #newsMore': 'doMoreNews',
'click .scrollCard': 'doClick'
+
}, 'doClick': function(d) {
console.log('Do click', d);
const id = get(d, 'currentTarget.dataset.guid', '');
@@ -150,6 +164,11 @@ const NewsView = Backbone.View.extend({
if (since > (60 * 1000 * 60) )
this.model.set('update', now);
+ },
+ 'doMoreNews': function() {
+ console.log('doMoreNews', this);
+
+ this.eventBus.trigger('showNewsList');
}
});
diff --git a/src/v1/js/NewsList.js b/src/v1/js/NewsList.js
new file mode 100644
index 0000000..d6b0e86
--- /dev/null
+++ b/src/v1/js/NewsList.js
@@ -0,0 +1,159 @@
+const $ = require('jquery');
+const _ = require('underscore');
+const Backbone = require('backbone');
+const request = require('request');
+const { get } = require('lodash');
+const { reduceEuronews } = require('./libs/reducers');
+const TimeFormat = require('hh-mm-ss');
+const { createPanel, addPanel } = require('./libs/panel');
+
+const NewsItem = Backbone.Model.extend({
+
+});
+
+const NewsCollection = Backbone.Collection.extend({
+ 'model': NewsItem
+});
+
+const newsCollection = new NewsCollection();
+
+const NewsItemView = Backbone.View.extend({
+ 'tagName': 'div',
+ 'className' : 'newsItem',
+ 'template': _.template(`
+
+
<%=title%>
+
<%=pubdate%>
+
+
<%=description%>
+
+ `),
+ 'initialize': function() {
+ this.render();
+ },
+ 'attributes': function() {
+ return {
+ 'data-guid': this.model.get('guid')
+ };
+ },
+
+ 'render': function() {
+ this.$el.html(this.template(this.model.toJSON()));
+ }, 'events': {
+ 'click': 'doClick'
+
+ }, 'doclick':function(d) {
+ console.log('>>> HERE');
+ console.lg(d);
+ }
+
+});
+
+const NewsListModel = Backbone.Model.extend({
+ 'defaults' : function (obj) {
+ // return a new object
+ return {
+ 'update' : new Date().getTime()
+ };
+ }, 'initialize': function() {
+ this.newsCollection = newsCollection;
+ this.listenTo(this, 'change:update', this.onChange);
+ this.getNews();
+ },
+ 'onChange': function() {
+ this.getNews();
+ },
+ 'getNews': function() {
+ // const ll = this.get('llShort');
+ console.info('>> News:request');
+ request({
+ 'url': `${window.loc}/news`,
+ 'method': 'GET', 'qs': {
+
+ }
+ }, function(err, res, body) {
+ if (err)
+ console.error(err);
+ else {
+ console.log('statusCode', res.statusCode);
+ const fsJSON = JSON.parse(body);
+ // console.log(body);
+ const newItems = [];
+
+ for (const item of fsJSON.items)
+ newItems.push(reduceEuronews(item));
+
+ this.newsCollection.reset(newItems);
+
+ this.logUpdate();
+ }
+ }.bind(this));
+ }, 'logUpdate': function() {
+ console.log('News logging:');
+
+ const time = new Date().getTime() ;
+
+ this.set('time', time);
+
+ this.timerID = setTimeout(
+ () => this.tick(),
+ 3.6e+6 + 1000
+ );
+
+ // console.log(this);
+ },
+ 'tick': function() {
+ console.log('Set update');
+ this.set('update', new Date().getTime());
+ }
+
+});
+
+const NewsListView = Backbone.View.extend({
+ 'initialize': function(options) {
+ this.eventBus = options.eventBus;
+
+ /* this.model.on('all', function(eventName) {
+ console.log(`${eventName } was triggered!`);
+ });*/
+
+ // this.model.bind('change:article', this.doRender, this);
+ this.model.newsCollection.bind('reset', this.render, this);
+ this.eventBus.on('showNewsList', this.showNewsListPanel, this);
+ },
+ 'showNewsListPanel': function() {
+ console.log('Showing news list');
+
+ this.model.set('update', new Date().getTime());
+ this.$newPanel = createPanel({ 'title':'More news', 'divId':'newsListP' });
+
+ this.$el = addPanel(this.$newPanel);
+
+ this.$el.empty();
+ this.$newPanel.show();
+ }, 'events': {
+ 'click': 'doClick'
+
+ }, 'doClick': function(d) {
+ console.log('Do click', d);
+ const id = get(d, 'currentTarget.dataset.guid', '');
+ console.log(id);
+ this.eventBus.trigger('showNews', id);
+ },
+ 'render' : function() {
+ console.log('>> Do render');
+
+ console.log(this.model.newsCollection);
+ this.model.newsCollection.each(function(item) {
+ const niView = new NewsItemView({ 'model': item });
+
+ this.$el.append(niView.el);
+ }, this);
+
+ console.log(this.$el);
+ console.log(this.el);
+ }
+
+});
+
+module.exports = { NewsListModel, NewsListView };
diff --git a/src/v1/js/app.js b/src/v1/js/app.js
index d5faeee..b3174c3 100644
--- a/src/v1/js/app.js
+++ b/src/v1/js/app.js
@@ -12,12 +12,13 @@ const { WeatherAlertModel, WeatherAlertView } = require('./WeatherAlert');
const { ForecastModel, ForecastView } = require('./Forecast');
const { NewsModel, NewsView } = require('./News');
const { NewsCardModel, NewsCardView } = require('./NewsViewer');
+const { NewsListModel, NewsListView } = require('./NewsList');
const { ByMeModel, ByMeView } = require('./RightByMe');
const { AgendaModel, AgendaView } = require('./Agenda');
const { TrafficModel, TrafficView } = require('./Traffic');
var app = app || {};
-const live = true;
+const live = false;
if (live) {
window.loc = 'https://jubilee.silvrtree.co.uk';
@@ -59,7 +60,9 @@ else
app.newsCard = new NewsCardView({ 'model': new NewsCardModel(), 'eventBus': app.eventBus });
- app.news = new NewsView({ 'model': new NewsModel(), 'eventBus': app.eventBus, 'el':'#news' });
+ app.newsList = new NewsListView({'model': new NewsListModel(), 'eventBus' : app.eventBus});
+
+ app.news = new NewsView({ 'model': new NewsModel(), 'eventBus': app.eventBus, 'el':'#newsShell' });
app.byMe = new ByMeView({ 'model': new ByMeModel(), 'eventBus': app.eventBus, 'location': app.locationModel, 'el':'#byme' });