mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-06-05 22:52:45 +02:00
2020-05-18 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDRssSchemas' class. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
1923e9840c
commit
3e671d7697
@ -19942,3 +19942,5 @@
|
|||||||
2020-05-17 Fred Gleason <fredg@paravelsystems.com>
|
2020-05-17 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Updated interlocking logic in the 'Edit Feed' dialog in
|
* Updated interlocking logic in the 'Edit Feed' dialog in
|
||||||
rdadmin(1) to handle image assignments correctly.
|
rdadmin(1) to handle image assignments correctly.
|
||||||
|
2020-05-18 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added 'RDRssSchemas' class.
|
||||||
|
@ -199,6 +199,7 @@ dist_librd_la_SOURCES = dbversion.h\
|
|||||||
rdreport.cpp rdreport.h\
|
rdreport.cpp rdreport.h\
|
||||||
rdringbuffer.cpp rdringbuffer.h\
|
rdringbuffer.cpp rdringbuffer.h\
|
||||||
rdripc.cpp rdripc.h\
|
rdripc.cpp rdripc.h\
|
||||||
|
rdrssschemas.cpp rdrssschemas.h\
|
||||||
rdschedcartlist.cpp rdschedcartlist.h\
|
rdschedcartlist.cpp rdschedcartlist.h\
|
||||||
rdschedcode.cpp rdschedcode.h\
|
rdschedcode.cpp rdschedcode.h\
|
||||||
rdschedcodes_dialog.cpp rdschedcodes_dialog.h\
|
rdschedcodes_dialog.cpp rdschedcodes_dialog.h\
|
||||||
|
@ -141,6 +141,7 @@ SOURCES += rdrehash.cpp
|
|||||||
SOURCES += rdrenderer.cpp
|
SOURCES += rdrenderer.cpp
|
||||||
SOURCES += rdreport.cpp
|
SOURCES += rdreport.cpp
|
||||||
SOURCES += rdripc.cpp
|
SOURCES += rdripc.cpp
|
||||||
|
SOURCES += rdrssschemas.cpp
|
||||||
SOURCES += rdschedcode.cpp
|
SOURCES += rdschedcode.cpp
|
||||||
SOURCES += rdsegmeter.cpp
|
SOURCES += rdsegmeter.cpp
|
||||||
SOURCES += rdsettings.cpp
|
SOURCES += rdsettings.cpp
|
||||||
@ -281,6 +282,7 @@ HEADERS += rdrehash.h
|
|||||||
HEADERS += rdrenderer.h
|
HEADERS += rdrenderer.h
|
||||||
HEADERS += rdreport.h
|
HEADERS += rdreport.h
|
||||||
HEADERS += rdripc.h
|
HEADERS += rdripc.h
|
||||||
|
HEADERS += rdrssschemas.h
|
||||||
HEADERS += rdschedcode.h
|
HEADERS += rdschedcode.h
|
||||||
HEADERS += rdsegmeter.h
|
HEADERS += rdsegmeter.h
|
||||||
HEADERS += rdsettings.h
|
HEADERS += rdsettings.h
|
||||||
|
128
lib/rdfeed.cpp
128
lib/rdfeed.cpp
@ -79,6 +79,8 @@ RDFeed::RDFeed(const QString &keyname,RDConfig *config,QObject *parent)
|
|||||||
feed_keyname=keyname;
|
feed_keyname=keyname;
|
||||||
feed_config=config;
|
feed_config=config;
|
||||||
|
|
||||||
|
feed_schemas=new RDRssSchemas();
|
||||||
|
|
||||||
sql=QString("select ID from FEEDS where ")+
|
sql=QString("select ID from FEEDS where ")+
|
||||||
"KEY_NAME=\""+RDEscapeString(keyname)+"\"";
|
"KEY_NAME=\""+RDEscapeString(keyname)+"\"";
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
@ -105,6 +107,8 @@ RDFeed::RDFeed(unsigned id,RDConfig *config,QObject *parent)
|
|||||||
feed_id=id;
|
feed_id=id;
|
||||||
feed_config=config;
|
feed_config=config;
|
||||||
|
|
||||||
|
feed_schemas=new RDRssSchemas();
|
||||||
|
|
||||||
sql=QString().sprintf("select KEY_NAME from FEEDS where ID=%u",id);
|
sql=QString().sprintf("select KEY_NAME from FEEDS where ID=%u",id);
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
if(q->first()) {
|
if(q->first()) {
|
||||||
@ -114,6 +118,12 @@ RDFeed::RDFeed(unsigned id,RDConfig *config,QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RDFeed::~RDFeed()
|
||||||
|
{
|
||||||
|
delete feed_schemas;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RDFeed::exists() const
|
bool RDFeed::exists() const
|
||||||
{
|
{
|
||||||
return RDDoesRowExist("FEEDS","KEY_NAME",feed_keyname);
|
return RDDoesRowExist("FEEDS","KEY_NAME",feed_keyname);
|
||||||
@ -387,14 +397,14 @@ void RDFeed::setPurgePassword(const QString &str) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RDFeed::RssSchema RDFeed::rssSchema() const
|
RDRssSchemas::RssSchema RDFeed::rssSchema() const
|
||||||
{
|
{
|
||||||
return (RDFeed::RssSchema)RDGetSqlValue("FEEDS","KEY_NAME",feed_keyname,
|
return (RDRssSchemas::RssSchema)RDGetSqlValue("FEEDS","KEY_NAME",feed_keyname,
|
||||||
"RSS_SCHEMA").toUInt();
|
"RSS_SCHEMA").toUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RDFeed::setRssSchema(RDFeed::RssSchema schema) const
|
void RDFeed::setRssSchema(RDRssSchemas::RssSchema schema) const
|
||||||
{
|
{
|
||||||
SetRow("RSS_SCHEMA",(unsigned)schema);
|
SetRow("RSS_SCHEMA",(unsigned)schema);
|
||||||
}
|
}
|
||||||
@ -1141,10 +1151,6 @@ QString RDFeed::rssXml(QString *err_msg,bool *ok)
|
|||||||
RDSqlQuery *q;
|
RDSqlQuery *q;
|
||||||
RDSqlQuery *q1;
|
RDSqlQuery *q1;
|
||||||
|
|
||||||
QString header_template;
|
|
||||||
QString channel_template;
|
|
||||||
QString item_template;
|
|
||||||
|
|
||||||
if(ok!=NULL) {
|
if(ok!=NULL) {
|
||||||
*ok=false;
|
*ok=false;
|
||||||
}
|
}
|
||||||
@ -1186,21 +1192,16 @@ QString RDFeed::rssXml(QString *err_msg,bool *ok)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(rssSchema()) {
|
//
|
||||||
case RDFeed::CustomSchema:
|
// Load the XML Templates
|
||||||
|
//
|
||||||
|
QString header_template=rssSchemas()->headerTemplate(rssSchema());
|
||||||
|
QString channel_template=rssSchemas()->channelTemplate(rssSchema());
|
||||||
|
QString item_template=rssSchemas()->itemTemplate(rssSchema());
|
||||||
|
if(rssSchema()==RDRssSchemas::CustomSchema) {
|
||||||
header_template=q->value(10).toString();
|
header_template=q->value(10).toString();
|
||||||
channel_template=q->value(11).toString();
|
channel_template=q->value(11).toString();
|
||||||
item_template=q->value(12).toString();
|
item_template=q->value(12).toString();
|
||||||
break;
|
|
||||||
|
|
||||||
case RDFeed::Rss202Schema:
|
|
||||||
header_template=RSS_2_0_2_HEADER_XML;
|
|
||||||
channel_template= RSS_2_0_2_CHANNEL_XML;
|
|
||||||
item_template=RSS_2_0_2_ITEM_XML;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RDFeed::LastSchema:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1277,6 +1278,12 @@ QString RDFeed::rssXml(QString *err_msg,bool *ok)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RDRssSchemas *RDFeed::rssSchemas() const
|
||||||
|
{
|
||||||
|
return feed_schemas;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned RDFeed::create(const QString &keyname,bool enable_users,
|
unsigned RDFeed::create(const QString &keyname,bool enable_users,
|
||||||
QString *err_msg,const QString &exemplar)
|
QString *err_msg,const QString &exemplar)
|
||||||
{
|
{
|
||||||
@ -1306,9 +1313,9 @@ unsigned RDFeed::create(const QString &keyname,bool enable_users,
|
|||||||
sql=QString("insert into FEEDS set ")+
|
sql=QString("insert into FEEDS set ")+
|
||||||
"KEY_NAME=\""+RDEscapeString(keyname)+"\","+
|
"KEY_NAME=\""+RDEscapeString(keyname)+"\","+
|
||||||
"ORIGIN_DATETIME=now(),"+
|
"ORIGIN_DATETIME=now(),"+
|
||||||
"HEADER_XML=\""+RDEscapeString(RSS_2_0_2_HEADER_XML)+"\","+
|
"HEADER_XML=\"\","+
|
||||||
"CHANNEL_XML=\""+RDEscapeString(RSS_2_0_2_CHANNEL_XML)+"\","+
|
"CHANNEL_XML=\"\","+
|
||||||
"ITEM_XML=\""+RDEscapeString(RSS_2_0_2_ITEM_XML)+"\"";
|
"ITEM_XML=\"\"";
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
feed_id=q->lastInsertId().toUInt();
|
feed_id=q->lastInsertId().toUInt();
|
||||||
delete q;
|
delete q;
|
||||||
@ -1474,81 +1481,6 @@ QString RDFeed::errorString(RDFeed::Error err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString RDFeed::rssSchemaString(RDFeed::RssSchema schema)
|
|
||||||
{
|
|
||||||
QString ret="Unknown";
|
|
||||||
|
|
||||||
switch(schema) {
|
|
||||||
case RDFeed::CustomSchema:
|
|
||||||
ret="[custom schema]";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RDFeed::Rss202Schema:
|
|
||||||
ret="RSS 2.0.2";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RDFeed::LastSchema:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDFeed::rssHeaderTemplate(RDFeed::RssSchema schema)
|
|
||||||
{
|
|
||||||
QString ret;
|
|
||||||
|
|
||||||
switch(schema) {
|
|
||||||
case RDFeed::Rss202Schema:
|
|
||||||
ret=RSS_2_0_2_HEADER_XML;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RDFeed::CustomSchema:
|
|
||||||
case RDFeed::LastSchema:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDFeed::rssChannelTemplate(RDFeed::RssSchema schema)
|
|
||||||
{
|
|
||||||
QString ret;
|
|
||||||
|
|
||||||
switch(schema) {
|
|
||||||
case RDFeed::Rss202Schema:
|
|
||||||
ret=RSS_2_0_2_CHANNEL_XML;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RDFeed::CustomSchema:
|
|
||||||
case RDFeed::LastSchema:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDFeed::rssItemTemplate(RDFeed::RssSchema schema)
|
|
||||||
{
|
|
||||||
QString ret;
|
|
||||||
|
|
||||||
switch(schema) {
|
|
||||||
case RDFeed::Rss202Schema:
|
|
||||||
ret=RSS_2_0_2_ITEM_XML;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RDFeed::CustomSchema:
|
|
||||||
case RDFeed::LastSchema:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDFeed::imageFilename(int feed_id,int img_id,const QString &ext)
|
QString RDFeed::imageFilename(int feed_id,int img_id,const QString &ext)
|
||||||
{
|
{
|
||||||
return QString().sprintf("img%06d_%06d.",feed_id,img_id)+ext;
|
return QString().sprintf("img%06d_%06d.",feed_id,img_id)+ext;
|
||||||
|
31
lib/rdfeed.h
31
lib/rdfeed.h
@ -25,28 +25,12 @@
|
|||||||
|
|
||||||
#include <rdapplication.h>
|
#include <rdapplication.h>
|
||||||
#include <rdconfig.h>
|
#include <rdconfig.h>
|
||||||
|
#include <rdrssschemas.h>
|
||||||
#include <rdsettings.h>
|
#include <rdsettings.h>
|
||||||
#include <rdstation.h>
|
#include <rdstation.h>
|
||||||
#include <rduser.h>
|
#include <rduser.h>
|
||||||
#include <rdweb.h>
|
#include <rdweb.h>
|
||||||
|
|
||||||
//
|
|
||||||
// RSS-2.0.2 Templates
|
|
||||||
//
|
|
||||||
#define RSS_2_0_2_NAME "RSS 2.0.2"
|
|
||||||
|
|
||||||
#define RSS_2_0_2_IMAGE_MIN_SIZE QSize(88,31)
|
|
||||||
#define RSS_2_0_2_IMAGE_MAX_SIZE QSize(144,400)
|
|
||||||
#define RSS_2_0_2_IMAGE_IN_ITEM false
|
|
||||||
|
|
||||||
#define RSS_2_0_2_HEADER_XML "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"
|
|
||||||
|
|
||||||
#define RSS_2_0_2_CHANNEL_XML "<title>%TITLE%</title>\n<description>%DESCRIPTION%</description>\n<category>%CATEGORY%</category>\n<link>%LINK%</link>\n<language>%LANGUAGE%</language>\n<copyright>%COPYRIGHT%</copyright>\n<lastBuildDate>%BUILD_DATE%</lastBuildDate>\n<pubDate>%PUBLISH_DATE%</pubDate>\n<managingEditor>%EDITOR%</managingEditor>\n<webMaster>%WEBMASTER%</webMaster>\n<generator>%GENERATOR%</generator>\n<image>\n <url>%IMAGE_URL%</url>\n <title>%TITLE%</title>\n <link>%LINK%</link>\n <width>%IMAGE_WIDTH%</width>\n <height>%IMAGE_HEIGHT%</height>\n <description>%IMAGE_DESCRIPTION%</description>\n</image>\n<atom:link href=\"%FEED_URL%\" rel=\"self\" type=\"application/rss+xml\" />"
|
|
||||||
|
|
||||||
#define RSS_2_0_2_ITEM_XML "<title>%ITEM_TITLE%</title>\n<link>%ITEM_LINK%</link>\n<guid isPermaLink=\"false\">%ITEM_GUID%</guid>\n<description>%ITEM_DESCRIPTION%</description>\n<author>%ITEM_AUTHOR%</author>\n<comments>%ITEM_COMMENTS%</comments>\n<source url=\"%ITEM_SOURCE_URL%\">%ITEM_SOURCE_TEXT%</source>\n<enclosure url=\"%ITEM_AUDIO_URL%\" length=\"%ITEM_AUDIO_LENGTH%\" type=\"audio/mpeg\" />\n<category>%ITEM_CATEGORY%</category>\n<pubDate>%ITEM_PUBLISH_DATE%</pubDate>"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define RDFEED_TOTAL_POST_STEPS 4
|
#define RDFEED_TOTAL_POST_STEPS 4
|
||||||
|
|
||||||
class RDFeed : public QObject
|
class RDFeed : public QObject
|
||||||
@ -56,9 +40,9 @@ class RDFeed : public QObject
|
|||||||
enum Error {ErrorOk=0,ErrorNoFile=1,ErrorCannotOpenFile=2,
|
enum Error {ErrorOk=0,ErrorNoFile=1,ErrorCannotOpenFile=2,
|
||||||
ErrorUnsupportedType=3,ErrorUploadFailed=4,ErrorGeneral=5};
|
ErrorUnsupportedType=3,ErrorUploadFailed=4,ErrorGeneral=5};
|
||||||
enum MediaLinkMode {LinkNone=0,LinkDirect=1,LinkCounted=2};
|
enum MediaLinkMode {LinkNone=0,LinkDirect=1,LinkCounted=2};
|
||||||
enum RssSchema {CustomSchema=0,Rss202Schema=1,LastSchema=2};
|
|
||||||
RDFeed(const QString &keyname,RDConfig *config,QObject *parent=0);
|
RDFeed(const QString &keyname,RDConfig *config,QObject *parent=0);
|
||||||
RDFeed(unsigned id,RDConfig *config,QObject *parent=0);
|
RDFeed(unsigned id,RDConfig *config,QObject *parent=0);
|
||||||
|
~RDFeed();
|
||||||
QString keyName() const;
|
QString keyName() const;
|
||||||
unsigned id() const;
|
unsigned id() const;
|
||||||
bool exists() const;
|
bool exists() const;
|
||||||
@ -98,8 +82,8 @@ class RDFeed : public QObject
|
|||||||
void setPurgeUsername(const QString &str) const;
|
void setPurgeUsername(const QString &str) const;
|
||||||
QString purgePassword() const;
|
QString purgePassword() const;
|
||||||
void setPurgePassword(const QString &str) const;
|
void setPurgePassword(const QString &str) const;
|
||||||
RssSchema rssSchema() const;
|
RDRssSchemas::RssSchema rssSchema() const;
|
||||||
void setRssSchema(RssSchema schema) const;
|
void setRssSchema(RDRssSchemas::RssSchema schema) const;
|
||||||
QString headerXml() const;
|
QString headerXml() const;
|
||||||
void setHeaderXml(const QString &str);
|
void setHeaderXml(const QString &str);
|
||||||
QString channelXml() const;
|
QString channelXml() const;
|
||||||
@ -155,13 +139,10 @@ class RDFeed : public QObject
|
|||||||
bool log_debug,RDConfig *config);
|
bool log_debug,RDConfig *config);
|
||||||
int totalPostSteps() const;
|
int totalPostSteps() const;
|
||||||
QString rssXml(QString *err_msg,bool *ok=NULL);
|
QString rssXml(QString *err_msg,bool *ok=NULL);
|
||||||
|
RDRssSchemas *rssSchemas() const;
|
||||||
static unsigned create(const QString &keyname,bool enable_users,
|
static unsigned create(const QString &keyname,bool enable_users,
|
||||||
QString *err_msg,const QString &exemplar="");
|
QString *err_msg,const QString &exemplar="");
|
||||||
static QString errorString(RDFeed::Error err);
|
static QString errorString(RDFeed::Error err);
|
||||||
static QString rssSchemaString(RDFeed::RssSchema schema);
|
|
||||||
static QString rssHeaderTemplate(RssSchema schema);
|
|
||||||
static QString rssChannelTemplate(RssSchema schema);
|
|
||||||
static QString rssItemTemplate(RssSchema schema);
|
|
||||||
static QString imageFilename(int feed_id,int img_id,const QString &ext);
|
static QString imageFilename(int feed_id,int img_id,const QString &ext);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -173,6 +154,7 @@ class RDFeed : public QObject
|
|||||||
QString ResolveItemWildcards(const QString &tmplt,RDSqlQuery *item_q,
|
QString ResolveItemWildcards(const QString &tmplt,RDSqlQuery *item_q,
|
||||||
RDSqlQuery *chan_q);
|
RDSqlQuery *chan_q);
|
||||||
QString GetTempFilename() const;
|
QString GetTempFilename() const;
|
||||||
|
void LoadSchemas();
|
||||||
void SetRow(const QString ¶m,int value) const;
|
void SetRow(const QString ¶m,int value) const;
|
||||||
void SetRow(const QString ¶m,const QString &value) const;
|
void SetRow(const QString ¶m,const QString &value) const;
|
||||||
void SetRow(const QString ¶m,const QDateTime &value,
|
void SetRow(const QString ¶m,const QDateTime &value,
|
||||||
@ -183,6 +165,7 @@ class RDFeed : public QObject
|
|||||||
RDConfig *feed_config;
|
RDConfig *feed_config;
|
||||||
QByteArray feed_xml;
|
QByteArray feed_xml;
|
||||||
int feed_xml_ptr;
|
int feed_xml_ptr;
|
||||||
|
RDRssSchemas *feed_schemas;
|
||||||
friend size_t __RDFeed_Readfunction_Callback(char *buffer,size_t size,
|
friend size_t __RDFeed_Readfunction_Callback(char *buffer,size_t size,
|
||||||
size_t nitems,void *userdata);
|
size_t nitems,void *userdata);
|
||||||
};
|
};
|
||||||
|
110
lib/rdrssschemas.cpp
Normal file
110
lib/rdrssschemas.cpp
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
// rdrssschemas.cpp
|
||||||
|
//
|
||||||
|
// RSS schema definitions for Rivendell
|
||||||
|
//
|
||||||
|
// (C) Copyright 2020 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public
|
||||||
|
// License along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "rdrssschemas.h"
|
||||||
|
|
||||||
|
RDRssSchemas::RDRssSchemas()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Names
|
||||||
|
//
|
||||||
|
c_names.push_back("Custom"); // CustomSchema
|
||||||
|
c_names.push_back("RSS 2.0.2"); // Rss202Schema
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Minimum Images Sizes
|
||||||
|
//
|
||||||
|
c_minimum_image_sizes.push_back(QSize(0,0)); // CustomSchema
|
||||||
|
c_minimum_image_sizes.push_back(QSize(88,31)); // Rss202Schema
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Maximum Image Sizes
|
||||||
|
//
|
||||||
|
c_maximum_image_sizes.push_back(QSize(0,0)); // CustomSchema
|
||||||
|
c_maximum_image_sizes.push_back(QSize(144,400)); // Rss202Schema
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Header Templates
|
||||||
|
//
|
||||||
|
// CustomSchema
|
||||||
|
c_header_templates.push_back("");
|
||||||
|
|
||||||
|
// Rss202Schema
|
||||||
|
c_header_templates.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">");
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Channel Templates
|
||||||
|
//
|
||||||
|
// CustomSchema
|
||||||
|
c_channel_templates.push_back("");
|
||||||
|
|
||||||
|
// Rs202Schema
|
||||||
|
c_channel_templates.push_back("<title>%TITLE%</title>\n<description>%DESCRIPTION%</description>\n<category>%CATEGORY%</category>\n<link>%LINK%</link>\n<language>%LANGUAGE%</language>\n<copyright>%COPYRIGHT%</copyright>\n<lastBuildDate>%BUILD_DATE%</lastBuildDate>\n<pubDate>%PUBLISH_DATE%</pubDate>\n<managingEditor>%EDITOR%</managingEditor>\n<webMaster>%WEBMASTER%</webMaster>\n<generator>%GENERATOR%</generator>\n<image>\n <url>%IMAGE_URL%</url>\n <title>%TITLE%</title>\n <link>%LINK%</link>\n <width>%IMAGE_WIDTH%</width>\n <height>%IMAGE_HEIGHT%</height>\n <description>%IMAGE_DESCRIPTION%</description>\n</image>\n<atom:link href=\"%FEED_URL%\" rel=\"self\" type=\"application/rss+xml\" />");
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Item Templates
|
||||||
|
//
|
||||||
|
// CustomSchema
|
||||||
|
c_item_templates.push_back("");
|
||||||
|
|
||||||
|
// Rss202Schema
|
||||||
|
c_item_templates.push_back("<title>%ITEM_TITLE%</title>\n<link>%ITEM_LINK%</link>\n<guid isPermaLink=\"false\">%ITEM_GUID%</guid>\n<description>%ITEM_DESCRIPTION%</description>\n<author>%ITEM_AUTHOR%</author>\n<comments>%ITEM_COMMENTS%</comments>\n<source url=\"%ITEM_SOURCE_URL%\">%ITEM_SOURCE_TEXT%</source>\n<enclosure url=\"%ITEM_AUDIO_URL%\" length=\"%ITEM_AUDIO_LENGTH%\" type=\"audio/mpeg\" />\n<category>%ITEM_CATEGORY%</category>\n<pubDate>%ITEM_PUBLISH_DATE%</pubDate>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDRssSchemas::name(RssSchema schema) const
|
||||||
|
{
|
||||||
|
return c_names.at(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QSize RDRssSchemas::minimumImageSize(RssSchema schema) const
|
||||||
|
{
|
||||||
|
return c_minimum_image_sizes.at(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QSize RDRssSchemas::maximumImageSize(RssSchema schema) const
|
||||||
|
{
|
||||||
|
return c_maximum_image_sizes.at(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDRssSchemas::headerTemplate(RssSchema schema) const
|
||||||
|
{
|
||||||
|
return c_header_templates.at(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDRssSchemas::channelTemplate(RssSchema schema) const
|
||||||
|
{
|
||||||
|
return c_channel_templates.at(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDRssSchemas::itemTemplate(RssSchema schema) const
|
||||||
|
{
|
||||||
|
return c_item_templates.at(schema);
|
||||||
|
}
|
51
lib/rdrssschemas.h
Normal file
51
lib/rdrssschemas.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// rdrssschemas.h
|
||||||
|
//
|
||||||
|
// RSS schema definitions for Rivendell
|
||||||
|
//
|
||||||
|
// (C) Copyright 2020 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public
|
||||||
|
// License along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef RDRSSSCHEMAS_H
|
||||||
|
#define RDRSSSCHEMAS_H
|
||||||
|
|
||||||
|
#include <qlist.h>
|
||||||
|
#include <qstring.h>
|
||||||
|
#include <qsize.h>
|
||||||
|
#include <qstringlist.h>
|
||||||
|
|
||||||
|
class RDRssSchemas
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum RssSchema {CustomSchema=0,Rss202Schema=1,LastSchema=2};
|
||||||
|
RDRssSchemas();
|
||||||
|
QString name(RssSchema schema) const;
|
||||||
|
QSize minimumImageSize(RssSchema schema) const;
|
||||||
|
QSize maximumImageSize(RssSchema schema) const;
|
||||||
|
QString headerTemplate(RssSchema schema) const;
|
||||||
|
QString channelTemplate(RssSchema schema) const;
|
||||||
|
QString itemTemplate(RssSchema schema) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QStringList c_names;
|
||||||
|
QList<QSize> c_minimum_image_sizes;
|
||||||
|
QList<QSize> c_maximum_image_sizes;
|
||||||
|
QStringList c_header_templates;
|
||||||
|
QStringList c_channel_templates;
|
||||||
|
QStringList c_item_templates;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // RDRSSSCHEMAS_H
|
@ -382,10 +382,10 @@ EditFeed::EditFeed(const QString &feed,QWidget *parent)
|
|||||||
// RSS Schema
|
// RSS Schema
|
||||||
//
|
//
|
||||||
feed_rss_schema_box=new QComboBox(this);
|
feed_rss_schema_box=new QComboBox(this);
|
||||||
for(int i=0;i<RDFeed::LastSchema;i++) {
|
for(int i=0;i<RDRssSchemas::LastSchema;i++) {
|
||||||
feed_rss_schema_box->
|
feed_rss_schema_box->
|
||||||
insertItem(feed_rss_schema_box->count(),
|
insertItem(feed_rss_schema_box->count(),
|
||||||
RDFeed::rssSchemaString((RDFeed::RssSchema)i),i);
|
feed_feed->rssSchemas()->name((RDRssSchemas::RssSchema)i),i);
|
||||||
}
|
}
|
||||||
connect(feed_rss_schema_box,SIGNAL(activated(int)),
|
connect(feed_rss_schema_box,SIGNAL(activated(int)),
|
||||||
this,SLOT(comboboxActivatedData(int)));
|
this,SLOT(comboboxActivatedData(int)));
|
||||||
@ -458,7 +458,7 @@ EditFeed::EditFeed(const QString &feed,QWidget *parent)
|
|||||||
feed_purge_url_edit->setText(feed_feed->purgeUrl());
|
feed_purge_url_edit->setText(feed_feed->purgeUrl());
|
||||||
feed_purge_username_edit->setText(feed_feed->purgeUsername());
|
feed_purge_username_edit->setText(feed_feed->purgeUsername());
|
||||||
feed_purge_password_edit->setText(feed_feed->purgePassword());
|
feed_purge_password_edit->setText(feed_feed->purgePassword());
|
||||||
RDFeed::RssSchema schema=feed_feed->rssSchema();
|
RDRssSchemas::RssSchema schema=feed_feed->rssSchema();
|
||||||
for(int i=0;i<feed_rss_schema_box->count();i++) {
|
for(int i=0;i<feed_rss_schema_box->count();i++) {
|
||||||
if(feed_rss_schema_box->itemData(i).toInt()==schema) {
|
if(feed_rss_schema_box->itemData(i).toInt()==schema) {
|
||||||
feed_rss_schema_box->setCurrentItem(i);
|
feed_rss_schema_box->setCurrentItem(i);
|
||||||
@ -625,7 +625,7 @@ void EditFeed::okData()
|
|||||||
feed_feed->setPurgeUsername(feed_purge_username_edit->text());
|
feed_feed->setPurgeUsername(feed_purge_username_edit->text());
|
||||||
feed_feed->setPurgePassword(feed_purge_password_edit->text());
|
feed_feed->setPurgePassword(feed_purge_password_edit->text());
|
||||||
feed_feed->
|
feed_feed->
|
||||||
setRssSchema((RDFeed::RssSchema)feed_rss_schema_box->
|
setRssSchema((RDRssSchemas::RssSchema)feed_rss_schema_box->
|
||||||
itemData(feed_rss_schema_box->currentIndex()).toUInt());
|
itemData(feed_rss_schema_box->currentIndex()).toUInt());
|
||||||
feed_feed->setHeaderXml(feed_header_xml_edit->text());
|
feed_feed->setHeaderXml(feed_header_xml_edit->text());
|
||||||
feed_feed->setChannelXml(feed_channel_xml_edit->text());
|
feed_feed->setChannelXml(feed_channel_xml_edit->text());
|
||||||
@ -774,8 +774,8 @@ void EditFeed::UpdateControlState()
|
|||||||
bool redirected=feed_redirect_check->isChecked();
|
bool redirected=feed_redirect_check->isChecked();
|
||||||
bool custom_schema=
|
bool custom_schema=
|
||||||
feed_rss_schema_box->itemData(feed_rss_schema_box->currentIndex()).toInt()==
|
feed_rss_schema_box->itemData(feed_rss_schema_box->currentIndex()).toInt()==
|
||||||
RDFeed::CustomSchema;
|
RDRssSchemas::CustomSchema;
|
||||||
bool item_image=feed_rss_schema_box->itemData(feed_rss_schema_box->currentIndex()).toInt()!=RDFeed::Rss202Schema;
|
bool item_image=feed_rss_schema_box->itemData(feed_rss_schema_box->currentIndex()).toInt()!=RDRssSchemas::Rss202Schema;
|
||||||
|
|
||||||
feed_is_superfeed_label->setDisabled(redirected);
|
feed_is_superfeed_label->setDisabled(redirected);
|
||||||
feed_is_superfeed_box->setDisabled(redirected);
|
feed_is_superfeed_box->setDisabled(redirected);
|
||||||
|
@ -10008,30 +10008,6 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0;i<RDFeed::LastSchema;i++) {
|
|
||||||
RDFeed::RssSchema schema=(RDFeed::RssSchema)i;
|
|
||||||
sql=QString("insert into RSS_SCHEMAS set ")+
|
|
||||||
QString().sprintf("ID=%u,",schema)+
|
|
||||||
"NAME=\""+RDEscapeString(RDFeed::rssSchemaString(schema))+"\"";
|
|
||||||
if(!RDFeed::rssHeaderTemplate(schema).isEmpty()) {
|
|
||||||
sql+=",HEADER_XML=\""+
|
|
||||||
RDEscapeString(RDFeed::rssHeaderTemplate(schema))+
|
|
||||||
"\"";
|
|
||||||
}
|
|
||||||
if(!RDFeed::rssChannelTemplate(schema).isEmpty()) {
|
|
||||||
sql+=",CHANNEL_XML=\""+
|
|
||||||
RDEscapeString(RDFeed::rssChannelTemplate(schema))+"\"";
|
|
||||||
}
|
|
||||||
if(!RDFeed::rssItemTemplate(schema).isEmpty()) {
|
|
||||||
sql+=",ITEM_XML=\""+
|
|
||||||
RDEscapeString(RDFeed::rssItemTemplate(schema))+
|
|
||||||
"\"";
|
|
||||||
}
|
|
||||||
if(!RDSqlQuery::apply(sql,err_msg)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sql=QString("alter table FEEDS add column ")+
|
sql=QString("alter table FEEDS add column ")+
|
||||||
"RSS_SCHEMA int unsigned not null default 0 after PURGE_PASSWORD";
|
"RSS_SCHEMA int unsigned not null default 0 after PURGE_PASSWORD";
|
||||||
if(!RDSqlQuery::apply(sql,err_msg)) {
|
if(!RDSqlQuery::apply(sql,err_msg)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user