From f2766d7604f0f7ab02a8fbe4a8cf47dd4b41de53 Mon Sep 17 00:00:00 2001 From: Framawiki Date: Fri, 5 May 2017 19:13:45 +0200 Subject: [PATCH 1/5] Add support of "~/.stikkit/private" --- README.md | 1 + stikkit/configuration.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index be6a53d..63e5b72 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Within this directory, there are a few key files worth creating. - *apikey* - If your stikked installation requires an API key, save it in here - *expiry* - The default expiry time (in minutes) for a paste, if needed - *author* - The default author name if you wish to use one + - *private* - If you want to mark the paste as private (not visible in recent pastes), create this empty file Tips ===== diff --git a/stikkit/configuration.cpp b/stikkit/configuration.cpp index 912836b..a51e8a5 100644 --- a/stikkit/configuration.cpp +++ b/stikkit/configuration.cpp @@ -92,6 +92,13 @@ void Configuration::Init() Configuration::Author = lineauth; } fauth.close(); + + //private + std::ifstream fpriv(homedir + "/.stikkit/private"); + if(fpriv.good()) + { + Configuration::Private = true; + } } if (Configuration::Author.length() < 1) { From 02b2d5a99c8d3ddcbab038dc64286dd652e06bd6 Mon Sep 17 00:00:00 2001 From: Framawiki Date: Fri, 5 May 2017 19:20:34 +0200 Subject: [PATCH 2/5] Small changes --- README.md | 10 +++++----- stikkit/main.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 63e5b72..89741d3 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ Checkout this repository cd stikkit cmake . make -make install +sudo make install ``` -NOTE: you need to have libcurl-dev installed in your system +NOTE: you need to have `libcurl-dev` installed in your system Usage ===== @@ -53,9 +53,9 @@ The url parameter can be stored to configuration file (stikkit will ask you in c Configuration ===== -The default configuration pulls the URL from /etc/stikkit/url - however, the better approach is to create your own config directory. The stikkit software will look for ".stikkit" in your home directory. +The default configuration pulls the URL from `/etc/stikkit/url` - however, the better approach is to create your own config directory. -Within this directory, there are a few key files worth creating. +The stikkit software will look for `.stikkit` in your home directory. Within this directory, there are a few key files worth creating. - *url* - Contains your base installation URL for stikked - *apikey* - If your stikked installation requires an API key, save it in here @@ -68,4 +68,4 @@ Tips Do you have a server and want to setup default pastebin site for all users in system? -Create /etc/stikkit/url which contains the url of default pastebin site. Users will be able to override it, but by default everyone on system will use this +Create `/etc/stikkit/url` which contains the url of default pastebin site. Users will be able to override it, but by default everyone on system will use this diff --git a/stikkit/main.cpp b/stikkit/main.cpp index 75ee00b..fe0f347 100644 --- a/stikkit/main.cpp +++ b/stikkit/main.cpp @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, "stikkit"); - /* Perform the request, res will get the return code */ + /* Perform the request, res will get the return HTTP code */ res = curl_easy_perform(curl); /* Check for errors */ if(res != CURLE_OK) From 82475fd04d704af822fdd9b0bd178b0370de0f2c Mon Sep 17 00:00:00 2001 From: Framawiki Date: Fri, 5 May 2017 21:33:23 +0200 Subject: [PATCH 3/5] Print output on a new line --- stikkit/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/stikkit/main.cpp b/stikkit/main.cpp index fe0f347..0bc851b 100644 --- a/stikkit/main.cpp +++ b/stikkit/main.cpp @@ -131,6 +131,7 @@ int main(int argc, char *argv[]) /* Perform the request, res will get the return HTTP code */ res = curl_easy_perform(curl); /* Check for errors */ + cerr << "\n"; if(res != CURLE_OK) { cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << endl; From 62b1a0fa0d1f2b16e20a66a2db40ac0d6b79616a Mon Sep 17 00:00:00 2001 From: Framawiki Date: Fri, 5 May 2017 21:39:49 +0200 Subject: [PATCH 4/5] Add "--help" in README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 89741d3..8b925fe 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ NOTE: you need to have `libcurl-dev` installed in your system Usage ===== +See `stikkit --help` for detailed help about options. + ``` stikkit -b url # now type text and hit ctrl+d to exit From e6ab4d245cdffdd66dbc065ce75e370de712bf59 Mon Sep 17 00:00:00 2001 From: Framawiki Date: Sat, 6 May 2017 01:11:28 +0200 Subject: [PATCH 5/5] Add version in useragent --- stikkit/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stikkit/main.cpp b/stikkit/main.cpp index 0bc851b..783bd1b 100644 --- a/stikkit/main.cpp +++ b/stikkit/main.cpp @@ -123,10 +123,12 @@ int main(int argc, char *argv[]) post += "&private=1"; if (Stikkit::Configuration::Expiry != "0") post += "&expire=" + Stikkit::Configuration::Expiry; + string useragent; + useragent = "Stikkit " + Stikkit::Configuration::Version + " (https://github.com/benapetr/stikkit/)"; curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_URL, Stikkit::Configuration::URL.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str()); - curl_easy_setopt(curl, CURLOPT_USERAGENT, "stikkit"); + curl_easy_setopt(curl, CURLOPT_USERAGENT, useragent.c_str()); /* Perform the request, res will get the return HTTP code */ res = curl_easy_perform(curl);