Skip to content
Permalink
Browse files

Add feed parser for the qgis.org blog

  • Loading branch information
m-kuhn committed Aug 19, 2015
1 parent bb69f16 commit 881d83644c58f2ca41391d558d005a5aa7cd2248
Showing with 117 additions and 6 deletions.
  1. +89 −0 doc/whatsnew.html
  2. +18 −6 src/app/qgswelcomepage.cpp
  3. +1 −0 src/app/qgswelcomepage.h
  4. +5 −0 src/core/qgsapplication.cpp
  5. +4 −0 src/core/qgsapplication.h
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<head>
<style>
html {
font-family: "Open Sans", "Helvetica Neue", Ubuntu, Arial, sans-serif;
}
a {
text-decoration: none;
color: #08c;
}

.feed-element {
margin: 1em;
background-color: #eee;
border-radius: 9px;
padding: 1em;
border: 1px solid #999;
overflow: auto;
}

.description {
}

.date {
font-size: 70%;
font-style: italic;
margin-bottom: 1em;
color: #666;
}

.feed-element .content-image {
float: left;
margin-right: 1em;
}
</style>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">

google.load("feeds", "1");

function initialize() {
var feed = new google.feeds.Feed('http://blog.qgis.org/feed/');
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("feed");
result.feed.entries.forEach(
function(entry) {
var div = document.createElement("div");
div.setAttribute('class', 'feed-element')

var link = document.createElement("a");
link.setAttribute('href', entry.link);

var title = document.createElement("h2");
title.appendChild(document.createTextNode(entry.title));
link.appendChild(title);
div.appendChild(link);

var date = document.createElement("div");
date.setAttribute('class', 'date');
date.appendChild(document.createTextNode(entry.publishedDate));
div.appendChild(date);

var img = document.createElement("img");
img.setAttribute('src', entry.mediaGroups[0].contents[0].url);
img.setAttribute('class', 'content-image');
div.appendChild(img);

var description = document.createElement("div");
description.setAttribute('class', 'description');
description.innerHTML=entry.contentSnippet;
div.appendChild(description);

container.appendChild(div);
}
)
}
});
}
google.setOnLoadCallback(initialize);

</script>
</head>
<body>
<h1>QGIS News</h1>
<div id="feed"></div>
</body>
</html>
@@ -17,11 +17,13 @@
#include "qgsproject.h"
#include "qgisapp.h"
#include "qgsversioninfo.h"
#include "qgsapplication.h"

#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QListView>
#include <QSettings>
#include <QDesktopServices>

QgsWelcomePage::QgsWelcomePage( QWidget* parent )
: QWidget( parent )
@@ -38,25 +40,30 @@ QgsWelcomePage::QgsWelcomePage( QWidget* parent )
QListView* welcomeScreenListView = new QListView();
mModel = new QgsWelcomePageItemsModel();
welcomeScreenListView->setModel( mModel );
welcomeScreenListView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
layout->addWidget( welcomeScreenListView );
welcomeScreenListView->setStyleSheet( "QListView::item {"
" margin-top: 5px;"
" margin-bottom: 5px;"
" margin-left: 15px;"
" margin-right: 15px;"
" border-width: 1px;"
" border-color: #535353;"
" border-color: #999;"
" border-radius: 9px;"
" background: #cccccc;"
" background: #eee;"
" padding: 10px;"
"}"
"QListView::item:selected:active {"
" background: #aaaaaa;"
"}");

QgsWebView* webView = new QgsWebView();
webView->setUrl( QUrl( "http://blog.qgis.org" ) );
layout->addWidget( webView );
QgsWebView* whatsNewPage = new QgsWebView();
whatsNewPage->setUrl( QUrl::fromLocalFile( QgsApplication::whatsNewFilePath() ) );
whatsNewPage->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
whatsNewPage->setContextMenuPolicy( Qt::NoContextMenu );
whatsNewPage->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
layout->addWidget( whatsNewPage );
connect( whatsNewPage, SIGNAL(linkClicked(QUrl)), this, SLOT(whatsNewLinkClicked(QUrl)));

mVersionInformation = new QLabel;
mainLayout->addWidget( mVersionInformation );
@@ -84,7 +91,7 @@ void QgsWelcomePage::versionInfoReceived()
QgsVersionInfo* versionInfo = qobject_cast<QgsVersionInfo*>( sender() );
Q_ASSERT( versionInfo );

if ( versionInfo->isDevelopmentVersion() )
if ( versionInfo->newVersionAvailable() )
{
mVersionInformation->setVisible( true );
mVersionInformation->setText( QString( "<b>%1</b>: %2")
@@ -96,3 +103,8 @@ void QgsWelcomePage::versionInfoReceived()
"}");
}
}

void QgsWelcomePage::whatsNewLinkClicked(const QUrl& url)
{
QDesktopServices::openUrl( url );
}
@@ -33,6 +33,7 @@ class QgsWelcomePage : public QWidget
private slots:
void itemDoubleClicked(const QModelIndex& index );
void versionInfoReceived();
void whatsNewLinkClicked(const QUrl& url );

private:
QgsWelcomePageItemsModel* mModel;
@@ -447,6 +447,11 @@ const QString QgsApplication::developersMapFilePath()
{
return ABISYM( mPkgDataPath ) + QString( "/doc/developersmap.html" );
}

const QString QgsApplication::whatsNewFilePath()
{
return ABISYM( mPkgDataPath ) + QString( "/doc/whatsnew.html" );
}
/*!
Returns the path to the sponsors file.
*/
@@ -90,6 +90,10 @@ class CORE_EXPORT QgsApplication : public QApplication
* @note this function was added in version 2.7 */
static const QString developersMapFilePath();

/** Returns the path to the whats new html page
* @note this function was added in version 2.11 */
static const QString whatsNewFilePath();

/** Returns the path to the sponsors file. */
static const QString sponsorsFilePath();

0 comments on commit 881d836

Please sign in to comment.
You can’t perform that action at this time.