Skip to content

Commit

Permalink
Add feed parser for the qgis.org blog
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 19, 2015
1 parent bb69f16 commit 881d836
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 6 deletions.
89 changes: 89 additions & 0 deletions doc/whatsnew.html
Original file line number Diff line number Diff line change
@@ -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>
24 changes: 18 additions & 6 deletions src/app/qgswelcomepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 );
Expand Down Expand Up @@ -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")
Expand All @@ -96,3 +103,8 @@ void QgsWelcomePage::versionInfoReceived()
"}");
}
}

void QgsWelcomePage::whatsNewLinkClicked(const QUrl& url)
{
QDesktopServices::openUrl( url );
}
1 change: 1 addition & 0 deletions src/app/qgswelcomepage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 881d836

Please sign in to comment.