13 #include <curl/curl.h>
19 #include <gdwtcore/gdToolbar.h>
28 void* hndl = dlopen(
"libarchive.so", RTLD_NOW | RTLD_GLOBAL);
30 fprintf(stderr,
"cannot load libarchive.so shared library! %s\n", dlerror());
50 string path = WApplication::instance()->internalPath();
52 std::string prop(user->
getProperty(path,
"WsModTwitter",
"twitter_enable",
"true"));
53 m_cb =
new WCheckBox(
"Enable twitter ?");
54 if ( prop ==
"true" ) {
56 m_cb->setCheckState(Wt::Checked);
59 m_cb->setCheckState(Wt::Unchecked);
67 string path = WApplication::instance()->internalPath();
88 if ( asString(
option(
"inContentMenuBar")) ==
"false" )
124 m_buttonReTweet->setIcon(wApp->theme()->resourcesUrl() +
"wittyshare/Icons/Twitter_Retweet-16x16.png");
134 std::string curPath = wApp->internalPath();
135 boost::algorithm::replace_all(curPath,
"&",
"&");
136 std::string tFile = pUser->
getRootPath() + curPath;
137 if ( boost::filesystem::is_directory(tFile) )
return;
140 wApp->log(
"notice") <<
"WsModTwitter::handleTwitterClick() : Path = " << curPath <<
", getAccessRoot() is null";
143 NodePtr pNode = pRootNode.get()->eatPath(curPath);
145 wApp->log(
"notice") <<
"WsModTwitter::handleTwitterClick() : Path = " << curPath <<
", getAccessRoot() eatPath is null";
148 std::string sText = pNode.get()->getDisplayName(
true);
150 std::string sFullUrl = sServerUrl + curPath;
151 char* pCurl = curl_escape(sFullUrl.c_str(), sFullUrl.size());
152 std::string sCurl(pCurl);
154 boost::algorithm::replace_all(sCurl,
"/",
"%2F");
155 boost::algorithm::replace_all(sCurl,
" ",
"%20");
156 pCurl = curl_escape(sText.c_str(), sText.size());
157 std::string sTextEnc(pCurl);
159 boost::algorithm::replace_all(sTextEnc,
"/",
"%2F");
160 boost::algorithm::replace_all(sTextEnc,
" ",
"%20");
161 std::string twitterUrl;
162 twitterUrl +=
"https://twitter.com/intent/tweet?original_referer=";
166 twitterUrl +=
"&text=";
169 twitterUrl += sTextEnc;
170 twitterUrl +=
"&tw_p=tweetbutton&url=";
174 twitterUrl +=
"&via=";
175 twitterUrl += asString(
option(
"account")).narrow();
181 return "WsModTwitter wittyShare module";
WsModulesLoader & WsModules()
boost::shared_ptr< WsAbstractNode > NodePtr
std::string pathWithoutPrefix(const std::string &path)
int saveProperty(const std::string &path, const std::string §ion, const std::string &attr, const std::string &val)
sets one property of the node and save it on disk.
std::string getProperty(const std::string &path, const std::string §ion, const string &attr, const std::string &def)
returns one property of a node If the property does not exist, a empty string is returned.
static WsApplication * wsInstance()
Facility function to access the application object.
WsContentButtonsBar * contentButtonsBar()
WittyShare provide a container to add some buttons like export page in pdf, ..., This function allow ...
Interface that provides differents methods for accessing the FsTree as well as other features...
virtual void destroyContentsMenuBar()
const boost::any & option(const std::string &attribute) const
Get an options value.
std::string get(const std::string §ion, const std::string &id, const std::string &def)
const std::string getRootPath()
return the root path of the filesystem tree, example : /var/www/demo_site
#define WsApp
Define a shortcut to the application instance.
static WsGlobalProperties * instance()
NodePtr getAccessRoot()
return the root node of the access tree starting from the root