mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-15 10:00:51 -04:00
* Updated wiki service to support new MsgRelated data.
* Added Wiki Dummy pages to explain it briefly. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5821 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
81e172d6f8
commit
b5910e0314
4 changed files with 280 additions and 1 deletions
|
@ -482,6 +482,7 @@ HEADERS += retroshare/rsgame.h \
|
||||||
pqi/pqiqosstreamer.cc \
|
pqi/pqiqosstreamer.cc \
|
||||||
pqi/sslfns.cc \
|
pqi/sslfns.cc \
|
||||||
pqi/pqinetstatebox.cc
|
pqi/pqinetstatebox.cc
|
||||||
|
|
||||||
SOURCES += rsserver/p3discovery.cc \
|
SOURCES += rsserver/p3discovery.cc \
|
||||||
rsserver/p3face-config.cc \
|
rsserver/p3face-config.cc \
|
||||||
rsserver/p3face-msgs.cc \
|
rsserver/p3face-msgs.cc \
|
||||||
|
@ -495,9 +496,11 @@ HEADERS += retroshare/rsgame.h \
|
||||||
rsserver/rsloginhandler.cc \
|
rsserver/rsloginhandler.cc \
|
||||||
rsserver/rstypes.cc \
|
rsserver/rstypes.cc \
|
||||||
rsserver/p3serverconfig.cc
|
rsserver/p3serverconfig.cc
|
||||||
|
|
||||||
SOURCES += plugins/pluginmanager.cc \
|
SOURCES += plugins/pluginmanager.cc \
|
||||||
plugins/dlfcn_win32.cc \
|
plugins/dlfcn_win32.cc \
|
||||||
serialiser/rspluginitems.cc
|
serialiser/rspluginitems.cc
|
||||||
|
|
||||||
SOURCES += serialiser/rsbaseitems.cc \
|
SOURCES += serialiser/rsbaseitems.cc \
|
||||||
serialiser/rsbaseserial.cc \
|
serialiser/rsbaseserial.cc \
|
||||||
serialiser/rsblogitems.cc \
|
serialiser/rsblogitems.cc \
|
||||||
|
|
|
@ -125,6 +125,8 @@ virtual bool getCollections(const uint32_t &token, std::vector<RsWikiCollection>
|
||||||
virtual bool getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots) = 0;
|
virtual bool getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots) = 0;
|
||||||
virtual bool getComments(const uint32_t &token, std::vector<RsWikiComment> &comments) = 0;
|
virtual bool getComments(const uint32_t &token, std::vector<RsWikiComment> &comments) = 0;
|
||||||
|
|
||||||
|
virtual bool getRelatedSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots) = 0;
|
||||||
|
|
||||||
virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection) = 0;
|
virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection) = 0;
|
||||||
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot) = 0;
|
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot) = 0;
|
||||||
virtual bool submitComment(uint32_t &token, RsWikiComment &comment) = 0;
|
virtual bool submitComment(uint32_t &token, RsWikiComment &comment) = 0;
|
||||||
|
|
|
@ -40,10 +40,14 @@ p3Wiki::p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// Setup of dummy Pages.
|
||||||
|
mAboutActive = false;
|
||||||
|
mImprovActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3Wiki::service_tick()
|
void p3Wiki::service_tick()
|
||||||
{
|
{
|
||||||
|
dummyTick();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +140,44 @@ bool p3Wiki::getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &sn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool p3Wiki::getRelatedSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots)
|
||||||
|
{
|
||||||
|
GxsMsgRelatedDataMap msgData;
|
||||||
|
bool ok = RsGenExchange::getMsgRelatedData(token, msgData);
|
||||||
|
|
||||||
|
if(ok)
|
||||||
|
{
|
||||||
|
GxsMsgRelatedDataMap::iterator mit = msgData.begin();
|
||||||
|
|
||||||
|
for(; mit != msgData.end(); mit++)
|
||||||
|
{
|
||||||
|
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||||
|
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||||
|
|
||||||
|
for(; vit != msgItems.end(); vit++)
|
||||||
|
{
|
||||||
|
RsGxsWikiSnapshotItem* item = dynamic_cast<RsGxsWikiSnapshotItem*>(*vit);
|
||||||
|
|
||||||
|
if(item)
|
||||||
|
{
|
||||||
|
RsWikiSnapshot snapshot = item->snapshot;
|
||||||
|
snapshot.mMeta = item->meta;
|
||||||
|
snapshots.push_back(snapshot);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Not a WikiSnapshot Item, deleting!" << std::endl;
|
||||||
|
delete *vit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3Wiki::getComments(const uint32_t &token, std::vector<RsWikiComment> &comments)
|
bool p3Wiki::getComments(const uint32_t &token, std::vector<RsWikiComment> &comments)
|
||||||
{
|
{
|
||||||
GxsMsgDataMap msgData;
|
GxsMsgDataMap msgData;
|
||||||
|
@ -264,10 +306,44 @@ std::string p3Wiki::genRandomId()
|
||||||
return randomId;
|
return randomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int about_len = 10;
|
||||||
|
const std::string about_txt[] =
|
||||||
|
{ "Welcome to RsWiki, a fully distributed Wiki system that anyone can edit.",
|
||||||
|
"Please read through these dummy Wiki pages to learn how it should work\n",
|
||||||
|
"Basic Functionality:",
|
||||||
|
" - New Group: creates a collection of Wiki Pages, the creator of group",
|
||||||
|
" and anyone they share the publish keys with) is the moderator\n",
|
||||||
|
" - New Page: Create a new Wiki Page, only Group Moderators can do this\n",
|
||||||
|
" - Edit: Anyone Can Edit the Wiki Page, and the changes form a tree under the original\n",
|
||||||
|
" - RePublish: This is used by the Moderators to accept and reject Edits.",
|
||||||
|
" the republished page becomes a new version of the Root Page, allowing more edits to be done\n",
|
||||||
|
"Please read the improvements section to see how we envision the wiki's working",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const int improvements_len = 14;
|
||||||
|
const std::string improvements_txt[] =
|
||||||
|
{ "As you can see, the current Wiki is a basic framework waiting to be expanded.",
|
||||||
|
"There are lots of potential improvements... some of my ideas are listed below\n",
|
||||||
|
"Ideas:",
|
||||||
|
" - Formatting: No HTML, lets use Markdown or something similar.\n",
|
||||||
|
" - Diffs, lots of edits will lead to complex merges - a robust merge tool is essential\n",
|
||||||
|
" - Read Mode... hide all the Edits, and only show the most recently published versions\n",
|
||||||
|
" - Easy Duplication - to take over an Abandoned or badly moderated Wiki. Copies All base versions to a new group\n",
|
||||||
|
" - WikiLinks. A generic Wiki Cross Linking system. This should be combined with Easy Duplication option,\n",
|
||||||
|
" to allow easy replacement of groups if necessary... A good design here is critical to a successful Wiki ecosystem",
|
||||||
|
" the republished page becomes a new version of the Root Page, allowing more edits to be done\n",
|
||||||
|
" - work out how to include media (photos, audio, video, etc) without embedding in pages",
|
||||||
|
" this would leverage the turtle transfer system somehow - maybe like channels.\n",
|
||||||
|
" - Comments, reviews etc can be incorporated - ideas here are welcome.\n",
|
||||||
|
" - Any other suggestion???"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void p3Wiki::generateDummyData()
|
void p3Wiki::generateDummyData()
|
||||||
{
|
{
|
||||||
|
|
||||||
#define GEN_COLLECTIONS 10
|
#define GEN_COLLECTIONS 0
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < GEN_COLLECTIONS; i++)
|
for(i = 0; i < GEN_COLLECTIONS; i++)
|
||||||
|
@ -280,7 +356,191 @@ void p3Wiki::generateDummyData()
|
||||||
uint32_t dummyToken = 0;
|
uint32_t dummyToken = 0;
|
||||||
submitCollection(dummyToken, wiki);
|
submitCollection(dummyToken, wiki);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RsWikiCollection wiki;
|
||||||
|
wiki.mMeta.mGroupFlags = 0;
|
||||||
|
wiki.mMeta.mGroupName = "About RsWiki";
|
||||||
|
|
||||||
|
submitCollection(mAboutToken, wiki);
|
||||||
|
|
||||||
|
wiki.mMeta.mGroupFlags = 0;
|
||||||
|
wiki.mMeta.mGroupName = "RsWiki Improvements";
|
||||||
|
|
||||||
|
submitCollection(mImprovToken, wiki);
|
||||||
|
|
||||||
|
mAboutLines = 0;
|
||||||
|
mImprovLines = 0;
|
||||||
|
|
||||||
|
mAboutActive = true;
|
||||||
|
mImprovActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool generateNextDummyPage(const RsGxsMessageId &threadId, const int lines, const RsGxsGrpMsgIdPair &parentId,
|
||||||
|
const std::string *page_lines, const int num_pagelines, RsWikiSnapshot &snapshot)
|
||||||
|
{
|
||||||
|
snapshot.mMeta.mGroupId = parentId.first;
|
||||||
|
|
||||||
|
// Create an About Page.
|
||||||
|
#define NUM_SUB_PAGES 3
|
||||||
|
|
||||||
|
if ((lines % NUM_SUB_PAGES == 0) || (lines == num_pagelines))
|
||||||
|
{
|
||||||
|
/* do a new baseline */
|
||||||
|
snapshot.mMeta.mOrigMsgId = threadId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snapshot.mMeta.mParentId = parentId.second;
|
||||||
|
snapshot.mMeta.mThreadId = threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string page;
|
||||||
|
for(int i = 0; (i < lines) && (i < num_pagelines); i++)
|
||||||
|
{
|
||||||
|
snapshot.mPage += page_lines[i];
|
||||||
|
snapshot.mPage += '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (lines <= num_pagelines);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void p3Wiki::dummyTick()
|
||||||
|
{
|
||||||
|
if (mAboutActive)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wiki::dummyTick() AboutActive";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mAboutToken);
|
||||||
|
|
||||||
|
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wiki::dummyTick() AboutActive, Lines: " << mAboutLines;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
if (mAboutLines == 0)
|
||||||
|
{
|
||||||
|
/* get the group Id */
|
||||||
|
RsGxsGroupId groupId;
|
||||||
|
if (!acknowledgeTokenGrp(mAboutToken, groupId))
|
||||||
|
{
|
||||||
|
std::cerr << " ERROR ";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mAboutActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create baseline snapshot */
|
||||||
|
RsWikiSnapshot page;
|
||||||
|
page.mMeta.mGroupId = groupId;
|
||||||
|
page.mPage = "Baseline page... a placeholder for About Wiki";
|
||||||
|
page.mMeta.mMsgName = "About RsWiki";
|
||||||
|
|
||||||
|
submitSnapshot(mAboutToken, page);
|
||||||
|
mAboutLines++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* get the msg Id, and generate next snapshot */
|
||||||
|
RsGxsGrpMsgIdPair msgId;
|
||||||
|
if (!acknowledgeTokenMsg(mAboutToken, msgId))
|
||||||
|
{
|
||||||
|
std::cerr << " ERROR ";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mAboutActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mAboutLines == 1)
|
||||||
|
{
|
||||||
|
mAboutThreadId = msgId.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsWikiSnapshot page;
|
||||||
|
page.mMeta.mMsgName = "About RsWiki";
|
||||||
|
if (!generateNextDummyPage(mAboutThreadId, mAboutLines, msgId, about_txt, about_len, page))
|
||||||
|
{
|
||||||
|
std::cerr << "About Pages Done";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mAboutActive = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mAboutLines++;
|
||||||
|
submitSnapshot(mAboutToken, page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mImprovActive)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wiki::dummyTick() ImprovActive";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mImprovToken);
|
||||||
|
|
||||||
|
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wiki::dummyTick() ImprovActive, Lines: " << mImprovLines;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
if (mImprovLines == 0)
|
||||||
|
{
|
||||||
|
/* get the group Id */
|
||||||
|
RsGxsGroupId groupId;
|
||||||
|
if (!acknowledgeTokenGrp(mImprovToken, groupId))
|
||||||
|
{
|
||||||
|
std::cerr << " ERROR ";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mImprovActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create baseline snapshot */
|
||||||
|
RsWikiSnapshot page;
|
||||||
|
page.mMeta.mGroupId = groupId;
|
||||||
|
page.mPage = "Baseline page... a placeholder for Improv Wiki";
|
||||||
|
page.mMeta.mMsgName = "Improv RsWiki";
|
||||||
|
|
||||||
|
submitSnapshot(mImprovToken, page);
|
||||||
|
mImprovLines++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* get the msg Id, and generate next snapshot */
|
||||||
|
RsGxsGrpMsgIdPair msgId;
|
||||||
|
if (!acknowledgeTokenMsg(mImprovToken, msgId))
|
||||||
|
{
|
||||||
|
std::cerr << " ERROR ";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mImprovActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mImprovLines == 1)
|
||||||
|
{
|
||||||
|
mImprovThreadId = msgId.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsWikiSnapshot page;
|
||||||
|
page.mMeta.mMsgName = "Improv RsWiki";
|
||||||
|
if (!generateNextDummyPage(mImprovThreadId, mImprovLines, msgId, improvements_txt, improvements_len, page))
|
||||||
|
{
|
||||||
|
std::cerr << "Improv Pages Done";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mImprovActive = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mImprovLines++;
|
||||||
|
submitSnapshot(mImprovToken, page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,8 @@ virtual bool getCollections(const uint32_t &token, std::vector<RsWikiCollection>
|
||||||
virtual bool getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots);
|
virtual bool getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots);
|
||||||
virtual bool getComments(const uint32_t &token, std::vector<RsWikiComment> &comments);
|
virtual bool getComments(const uint32_t &token, std::vector<RsWikiComment> &comments);
|
||||||
|
|
||||||
|
virtual bool getRelatedSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots);
|
||||||
|
|
||||||
virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection);
|
virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection);
|
||||||
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot);
|
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot);
|
||||||
virtual bool submitComment(uint32_t &token, RsWikiComment &comment);
|
virtual bool submitComment(uint32_t &token, RsWikiComment &comment);
|
||||||
|
@ -68,6 +70,18 @@ std::string genRandomId();
|
||||||
// RsMutex mWikiMtx;
|
// RsMutex mWikiMtx;
|
||||||
|
|
||||||
|
|
||||||
|
// Dummy Stuff.
|
||||||
|
void dummyTick();
|
||||||
|
|
||||||
|
bool mAboutActive;
|
||||||
|
uint32_t mAboutToken;
|
||||||
|
int mAboutLines;
|
||||||
|
RsGxsMessageId mAboutThreadId;
|
||||||
|
|
||||||
|
bool mImprovActive;
|
||||||
|
uint32_t mImprovToken;
|
||||||
|
int mImprovLines;
|
||||||
|
RsGxsMessageId mImprovThreadId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue