11 #include "huggleweb.hpp"
12 #include "ui_huggleweb.h"
14 using namespace Huggle;
20 CurrentPage =
"No page is displayed now";
23 HuggleWeb::~HuggleWeb()
28 QString HuggleWeb::CurrentPageName()
37 throw new Exception(
"WikiPage *page must not be NULL",
"void HuggleWeb::DisplayPreFormattedPage(WikiPage *page)");
39 ui->webView->history()->clear();
46 ui->webView->history()->clear();
47 ui->webView->load(url +
"&action=render");
48 CurrentPage = ui->webView->title();
51 void HuggleWeb::DisplayPage(QString url)
53 ui->webView->load(url);
58 ui->webView->setContent(html.toUtf8());
61 QString HuggleWeb::Encode(
const QString &
string)
64 for(
int i=0;i<
string.size();++i)
66 QChar ch =
string.at(i);
67 if(ch.unicode() > 255)
69 encoded += QString(
"&#%1;").arg((
int)ch.unicode());
76 encoded = encoded.replace(
"<",
"<");
77 encoded = encoded.replace(
">",
">");
83 ui->webView->history()->clear();
86 throw new Exception(
"The page of edit was NULL in HuggleWeb::DisplayDiff(*edit)");
88 if (edit->
Page == NULL)
90 throw new Exception(
"The page of edit was NULL in HuggleWeb::DisplayDiff(*edit)");
92 if (edit->DiffText ==
"")
94 Core::Log(
"Warning, unable to retrieve diff for edit " + edit->
Page->
PageName +
" fallback to web rendering");
96 + QString::number(edit->
Diff) +
"&action=render");
106 size =
"+" + QString::number(edit->
Size);
109 size = QString::number(edit->
Size);
115 Summary =
"<font color=red>No summary was provided</font>";
118 Summary = Encode(edit->
Summary);
121 Summary +=
"<b> Size change: " + size +
"</b>";
123 ui->webView->setHtml(
Core::HtmlHeader +
"<tr></td colspan=2><b>Summary:</b> "
124 + Summary +
"</td></tr>" + edit->DiffText
static QString GetProjectScriptURL()
Return a script url like http://en.wikipedia.org/w/.
static void Log(QString Message)
Write text to terminal as well as ring log.
static QString HtmlHeader
This string contains a html header.
HuggleWeb(QWidget *parent=0)
static QString HtmlFooter
This string contains a html footer.
void DisplayPreFormattedPage(WikiPage *page)
Retrieve a page in render mode on currently selected project.
QString Summary
Summary of edit.
Every exception raised by huggle is defined by this class.
int Size
Size of change of edit.
void DisplayDiff(WikiEdit *edit)
void RenderHtml(QString html)
QString PageName
Name of page.
WikiPage * Page
Page that was changed by edit.