24#include "blogpost_p.h"
30#include <kcal/journal.h>
37 : d_ptr( new BlogPostPrivate )
41 d_ptr->mPostId = post.
postId();
42 d_ptr->mTitle = post.
title();
43 d_ptr->mContent = post.
content();
45 d_ptr->mWpSlug = post.
slug();
47 d_ptr->mTags = post.
tags();
48 d_ptr->mMood = post.
mood();
50 d_ptr->mSummary = post.
summary();
51 d_ptr->mLink = post.
link();
52 d_ptr->mMusic = post.
music();
55 d_ptr->mError = post.
error();
57 d_ptr->mStatus = post.
status();
63 : d_ptr( new BlogPostPrivate )
66 d_ptr->mPrivate =
false;
72 : d_ptr( new BlogPostPrivate )
75 d_ptr->mPrivate =
false;
76 d_ptr->mPostId =
journal.customProperty(
"KBLOG",
"ID" );
77 d_ptr->mJournalId =
journal.uid();
79 d_ptr->mTitle =
journal.summary();
80 if (
journal.descriptionIsRich() ) {
81 d_ptr->mContent = d_ptr->cleanRichText(
journal.description() );
83 d_ptr->mContent =
journal.description();
85 d_ptr->mCategories =
journal.categories();
86 d_ptr->mCreationDateTime =
journal.dtStart();
110 QString url = blog.
url().url();
112 QString blogId = blog.
blogId();
114 QString
id = QLatin1String(
"kblog-") + url + QLatin1Char(
'-') + blogId + QLatin1Char(
'-') + username +
115 QLatin1Char(
'-') + d_ptr->mPostId;
116 KCal::Journal *
journal =
new KCal::Journal();
118 journal->setSummary( d_ptr->mTitle );
119 journal->setCategories( d_ptr->mCategories );
120 journal->setDescription( d_ptr->mContent,
true );
121 journal->setDtStart( d_ptr->mCreationDateTime );
122 journal->setCustomProperty(
"KBLOG",
"URL", url );
124 journal->setCustomProperty(
"KBLOG",
"BLOG", blogId );
125 journal->setCustomProperty(
"KBLOG",
"ID", d_ptr->mPostId );
131 return d_ptr->mJournalId;
136 return d_ptr->mPrivate;
141 d_ptr->mPrivate = privatePost;
146 return d_ptr->mPostId;
156 return d_ptr->mTitle;
161 d_ptr->mTitle =
title;
166 return d_ptr->mContent;
188 return d_ptr->mAdditionalContent;
198 return d_ptr->mWpSlug;
203 d_ptr->mWpSlug =
slug;
218 return d_ptr->mPermaLink;
223 d_ptr->mPermaLink = permalink;
228 return d_ptr->mCommentAllowed;
233 d_ptr->mCommentAllowed = commentAllowed;
238 return d_ptr->mCommentAllowed;
243 d_ptr->mTrackBackAllowed = allowTrackBacks;
248 return d_ptr->mSummary;
290 return d_ptr->mMusic;
295 d_ptr->mMusic =
music;
300 return d_ptr->mCategories;
310 return d_ptr->mCreationDateTime;
315 d_ptr->mCreationDateTime = datetime;
320 return d_ptr->mModificationDateTime;
325 d_ptr->mModificationDateTime = datetime;
330 return d_ptr->mStatus;
340 return d_ptr->mError;
345 d_ptr->mError =
error;
355QString BlogPostPrivate::cleanRichText( QString richText )
const
357 QRegExp getBodyContents( QLatin1String(
"<body[^>]*>(.*)</body>") );
358 if ( getBodyContents.indexIn( richText ) ) {
360 richText = getBodyContents.cap( 1 );
362 richText.remove( QRegExp( QLatin1String(
"^\\s+") ) );
365 richText.replace( QRegExp( QLatin1String(
"<p style=\"[^\"]*\">" )), QLatin1String(
"<p>") );
368 if ( richText == QLatin1String(
"<p></p>") ) {
This is the main interface for blogging APIs.
A class that represents a blog post on the server.
void setSlug(const QString &slug)
Sets the Wordpress slug property! (will use to set post's permalink) Currently just wordpress support...
KUrl permaLink() const
Returns the perma link path.
KDateTime creationDateTime() const
Returns the creation date time.
QString summary() const
Returns the summary.
bool isPrivate() const
Returns if the post is published or not.
void setPostId(const QString &postId)
Sets the post id value.
QString mood() const
Returns the mood.
void setCategories(const QStringList &categories)
Sets the categories.
void setPermaLink(const KUrl &permalink) const
Set the perma link path.
void setTrackBackAllowed(bool allowTrackBacks)
Set whether track back should be allowed.
QString journalId() const
Returns the ID used by the journal in creation, if created from a journal.
void setStatus(Status status)
Sets the status.
void setCreationDateTime(const KDateTime &datetime)
Sets the creation time.
void setContent(const QString &content)
Sets the content.
bool isCommentAllowed() const
Returns whether comments should be allowed.
void swap(BlogPost &other)
The swap operator.
QString content() const
Returns the content.
void setSummary(const QString &summary)
Set the summary.
virtual ~BlogPost()
Virtual default destructor.
KCal::Journal * journal(const Blog &blog) const
Returns a KCal journal from the blog post owned by the caller.
void setLink(const KUrl &link) const
Set the link path.
QStringList tags() const
Returns the tags list as a QStringList.
void setMusic(const QString &music)
Set the music.
KUrl link() const
Returns the link path.
QString music() const
Returns the music.
BlogPost(const KBlog::BlogPost &post)
Constructor.
KDateTime modificationDateTime() const
Returns the modification date time.
QString title() const
Returns the title.
void setError(const QString &error)
Sets the error.
QStringList categories() const
Returns the categories.
void setCommentAllowed(bool commentAllowed)
Set whether comments should be allowed.
void setTags(const QStringList &tags)
Set the tags list.
void setMood(const QString &mood)
Set the mood list.
QString additionalContent() const
Returns the additional content, (mt_text_more of MovableType API)
QString postId() const
Returns the postId.
BlogPost & operator=(const BlogPost &post)
The overloaed = operator.
void setAdditionalContent(const QString &additionalContent)
Sets the additional content, (mt_text_more of MovableType API)
Status
The enumartion of the different post status, reflecting the status changes on the server.
@ New
Status of a freshly constructed post on the client.
QString slug() const
Returns the Wordpress posts Slug (or permalink will use for post) Currently just wordpress supports t...
bool isTrackBackAllowed() const
Returns whether track back should be allowed.
QString error() const
Returns the last error.
void setTitle(const QString &title)
Sets the title.
void setPrivate(bool privatePost)
Sets the post to private viewings only.
void setModificationDateTime(const KDateTime &datetime)
Sets the modification time.
Status status() const
Returns the status on the server.
A class that provides methods to call functions on a supported blog web application.
QString username() const
Returns the username used in blog authentication.
QString blogId() const
Returns the unique ID for the specific blog on the server.
KUrl url() const
Get the URL for the blog's XML-RPC interface.
Namespace for blog related classes.