diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-31 09:59:57 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-31 09:59:57 -0400 |
commit | d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90 (patch) | |
tree | 3c46d8db66427a41ddff51e57c505d12ff2bc96c | |
parent | 09cb5b468d20820219e9e341ee25ae17c2a5e089 (diff) | |
download | infinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.tar.gz infinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.tar.bz2 infinite-d4c7cc7bf69b81c63c4229d4a7ae505a1180dc90.zip |
Added caption to tweets
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | infinite.cpp | 16 | ||||
m--------- | vendor/libtwittercpp | 0 | ||||
m--------- | vendor/verbly | 0 |
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) | |||
8 | add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) | 8 | add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) |
9 | 9 | ||
10 | find_package(PkgConfig) | 10 | find_package(PkgConfig) |
11 | pkg_check_modules(sqlite3 sqlite3>=3.8.3 REQUIRED) | ||
12 | pkg_check_modules(GraphicsMagick GraphicsMagick++ REQUIRED) | 11 | pkg_check_modules(GraphicsMagick GraphicsMagick++ REQUIRED) |
13 | 12 | ||
14 | include_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) | 13 | include_directories(${GraphicsMagick_INCLUDE_DIRS} vendor/verbly/lib vendor/libtwittercpp/src vendor/yaml-cpp/include) |
15 | link_directories(${sqlite3_LIBRARY_DIRS} ${GraphicsMagick_LIBRARY_DIRS}) | 14 | link_directories(${GraphicsMagick_LIBRARY_DIRS}) |
16 | add_executable(infinite infinite.cpp color.cpp fractal.cpp matrix3x3.cpp vector3d.cpp tinyxml2.cpp triangle.cpp) | 15 | add_executable(infinite infinite.cpp color.cpp fractal.cpp matrix3x3.cpp vector3d.cpp tinyxml2.cpp triangle.cpp) |
17 | set_property(TARGET infinite PROPERTY CXX_STANDARD 11) | 16 | set_property(TARGET infinite PROPERTY CXX_STANDARD 11) |
18 | set_property(TARGET infinite PROPERTY CXX_STANDARD_REQUIRED ON) | 17 | set_property(TARGET infinite PROPERTY CXX_STANDARD_REQUIRED ON) |
19 | target_link_libraries(infinite ${GraphicsMagick_LIBRARIES} verbly ${sqlite3_LIBRARIES} yaml-cpp twitter++ curlcpp) | 18 | target_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 | ||