summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-05-31 09:59:57 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-05-31 09:59:57 -0400
commitd4c7cc7bf69b81c63c4229d4a7ae505a1180dc90 (patch)
tree3c46d8db66427a41ddff51e57c505d12ff2bc96c
parent09cb5b468d20820219e9e341ee25ae17c2a5e089 (diff)
downloadinfinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.tar.gz
infinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.tar.bz2
infinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.zip
Added caption to tweets
-rw-r--r--CMakeLists.txt7
-rw-r--r--infinite.cpp16
m---------vendor/libtwittercpp0
m---------vendor/verbly0
4 files changed, 16 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 900f8d4..1c72ef4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -8,12 +8,11 @@ add_subdirectory(vendor/verbly)
8add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) 8add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL)
9 9
10find_package(PkgConfig) 10find_package(PkgConfig)
11pkg_check_modules(sqlite3 sqlite3>=3.8.3 REQUIRED)
12pkg_check_modules(GraphicsMagick GraphicsMagick++ REQUIRED) 11pkg_check_modules(GraphicsMagick GraphicsMagick++ REQUIRED)
13 12
14include_directories(${GraphicsMagick_INCLUDE_DIRS} ${sqlite3_INCLUDE_DIR} vendor/verbly/lib vendor/libtwittercpp/src vendor/yaml-cpp/include vendor/libtwittercpp/vendor/json/src vendor/libtwittercpp/vendor/curlcpp/include) 13include_directories(${GraphicsMagick_INCLUDE_DIRS} vendor/verbly/lib vendor/libtwittercpp/src vendor/yaml-cpp/include)
15link_directories(${sqlite3_LIBRARY_DIRS} ${GraphicsMagick_LIBRARY_DIRS}) 14link_directories(${GraphicsMagick_LIBRARY_DIRS})
16add_executable(infinite infinite.cpp color.cpp fractal.cpp matrix3x3.cpp vector3d.cpp tinyxml2.cpp triangle.cpp) 15add_executable(infinite infinite.cpp color.cpp fractal.cpp matrix3x3.cpp vector3d.cpp tinyxml2.cpp triangle.cpp)
17set_property(TARGET infinite PROPERTY CXX_STANDARD 11) 16set_property(TARGET infinite PROPERTY CXX_STANDARD 11)
18set_property(TARGET infinite PROPERTY CXX_STANDARD_REQUIRED ON) 17set_property(TARGET infinite PROPERTY CXX_STANDARD_REQUIRED ON)
19target_link_libraries(infinite ${GraphicsMagick_LIBRARIES} verbly ${sqlite3_LIBRARIES} yaml-cpp twitter++ curlcpp) 18target_link_libraries(infinite ${GraphicsMagick_LIBRARIES} verbly yaml-cpp twitter++)
diff --git a/infinite.cpp b/infinite.cpp index 0016178..1086169 100644 --- a/infinite.cpp +++ b/infinite.cpp
@@ -733,10 +733,11 @@ int main(int argc, char** argv)
733 733
734 closedir(fontdir); 734 closedir(fontdir);
735 735
736 std::string subaction = action;
736 std::string font = fonts[rand() % fonts.size()]; 737 std::string font = fonts[rand() % fonts.size()];
737 if (font == "Le_Super_Type_SemiBold.ttf") 738 if (font == "Le_Super_Type_SemiBold.ttf")
738 { 739 {
739 std::transform(std::begin(action), std::end(action), std::begin(action), [] (char ch) { 740 std::transform(std::begin(subaction), std::end(subaction), std::begin(subaction), [] (char ch) {
740 return std::toupper(ch); 741 return std::toupper(ch);
741 }); 742 });
742 } 743 }
@@ -747,7 +748,7 @@ int main(int argc, char** argv)
747 textimage.fontPointsize(72.0); 748 textimage.fontPointsize(72.0);
748 textimage.font("fonts/" + font); 749 textimage.font("fonts/" + font);
749 750
750 auto words = verbly::split<std::list<std::string>>(action, " "); 751 auto words = verbly::split<std::list<std::string>>(subaction, " ");
751 std::string towrite = ""; 752 std::string towrite = "";
752 std::string curline = ""; 753 std::string curline = "";
753 Magick::TypeMetric metric; 754 Magick::TypeMetric metric;
@@ -788,8 +789,17 @@ int main(int argc, char** argv)
788 continue; 789 continue;
789 } 790 }
790 791
792 std::string tweetText;
793 size_t tweetLim = 140 - client.getConfiguration().getCharactersReservedPerMedia() - 2;
794 if (action.length() > tweetLim)
795 {
796 tweetText = "\"" + action.substr(0, tweetLim - 1) + "…\"";
797 } else {
798 tweetText = "\"" + action + "\"";
799 }
800
791 twitter::tweet tw; 801 twitter::tweet tw;
792 resp = client.updateStatus("", tw, {media_id}); 802 resp = client.updateStatus(tweetText, tw, twitter::tweet(), {media_id});
793 if (resp != twitter::response::ok) 803 if (resp != twitter::response::ok)
794 { 804 {
795 std::cout << "Twitter error while tweeting: " << resp << std::endl; 805 std::cout << "Twitter error while tweeting: " << resp << std::endl;
diff --git a/vendor/libtwittercpp b/vendor/libtwittercpp
Subproject f465dce27cf0f07039e29d8975ad98939f0df3a Subproject aceb3cc33ee78cce1077252aff8a8808a3195ff
diff --git a/vendor/verbly b/vendor/verbly
Subproject e7299f7bf66df7e62bf36ef42ab7810086d088c Subproject 6c2aca03c89b37e136ab4c7ea58b485dadc85bc