@@ -4,5 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface CommentRepositoryInterface |
| 6 | 6 | { |
| 7 | - public function getActiveCommentsBySite($site, $limit = null, $offset= 0); |
|
| 7 | + public function getActiveCommentsBySite($site, $limit = null, $offset= 0); |
|
| 8 | 8 | } |
@@ -7,26 +7,26 @@ discard block |
||
| 7 | 7 | class MysqlCommentRepository implements CommentRepositoryInterface |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | - protected $connections; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 15 | - */ |
|
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 18 | - $this->connections = $connections; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function getActiveCommentsBySite($site, $limit = null, $offset = 0) |
|
| 22 | - { |
|
| 23 | - if ($site == 'blog') { |
|
| 24 | - $site_id = 2; |
|
| 25 | - } else { |
|
| 26 | - throw new Exception('Unrecognized site id in comment repository'); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - $query = " |
|
| 10 | + /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | + protected $connections; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @param Aura\Sql\ConnectionLocator $connections |
|
| 15 | + */ |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + { |
|
| 18 | + $this->connections = $connections; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function getActiveCommentsBySite($site, $limit = null, $offset = 0) |
|
| 22 | + { |
|
| 23 | + if ($site == 'blog') { |
|
| 24 | + $site_id = 2; |
|
| 25 | + } else { |
|
| 26 | + throw new Exception('Unrecognized site id in comment repository'); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + $query = " |
|
| 30 | 30 | SELECT `comment_meta`.`id`, `comment_meta`.`date`, `comment`.`body`, `commenter`.`name`, |
| 31 | 31 | `post`.`title`, `post`.`category`, `post`.`path` |
| 32 | 32 | FROM `jpemeric_comment`.`comment_meta` |
@@ -39,21 +39,21 @@ discard block |
||
| 39 | 39 | `post`.`display` = :display_post |
| 40 | 40 | WHERE `comment_meta`.`display` = :active_comment |
| 41 | 41 | ORDER BY `comment_meta`.`date` DESC"; |
| 42 | - if ($limit != null) { |
|
| 43 | - $query .= " |
|
| 42 | + if ($limit != null) { |
|
| 43 | + $query .= " |
|
| 44 | 44 | LIMIT {$offset}, {$limit}"; |
| 45 | - } |
|
| 46 | - |
|
| 47 | - $bindings = [ |
|
| 48 | - 'trusted_commenter' => 1, |
|
| 49 | - 'comment_site' => $site_id, |
|
| 50 | - 'display_post' => 1, |
|
| 51 | - 'active_comment' => 1, |
|
| 52 | - ]; |
|
| 53 | - |
|
| 54 | - return $this |
|
| 55 | - ->connections |
|
| 56 | - ->getRead() |
|
| 57 | - ->fetchAll($query, $bindings); |
|
| 58 | - } |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + $bindings = [ |
|
| 48 | + 'trusted_commenter' => 1, |
|
| 49 | + 'comment_site' => $site_id, |
|
| 50 | + 'display_post' => 1, |
|
| 51 | + 'active_comment' => 1, |
|
| 52 | + ]; |
|
| 53 | + |
|
| 54 | + return $this |
|
| 55 | + ->connections |
|
| 56 | + ->getRead() |
|
| 57 | + ->fetchAll($query, $bindings); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | protected function set_head_data() |
| 22 | 22 | { |
| 23 | - $this->set_head('rss_link', [ |
|
| 24 | - 'title' => 'Jacob Emerick Blog Feed', |
|
| 25 | - 'url' => '/rss.xml' |
|
| 26 | - ]); |
|
| 27 | - $this->set_head('rss_comment_link', [ |
|
| 28 | - 'title' => 'Jacob Emerick Blog Comment Feed', |
|
| 29 | - 'url' => '/rss-comments.xml' |
|
| 30 | - ]); |
|
| 23 | + $this->set_head('rss_link', [ |
|
| 24 | + 'title' => 'Jacob Emerick Blog Feed', |
|
| 25 | + 'url' => '/rss.xml' |
|
| 26 | + ]); |
|
| 27 | + $this->set_head('rss_comment_link', [ |
|
| 28 | + 'title' => 'Jacob Emerick Blog Comment Feed', |
|
| 29 | + 'url' => '/rss-comments.xml' |
|
| 30 | + ]); |
|
| 31 | 31 | |
| 32 | 32 | $this->add_css('normalize'); |
| 33 | 33 | $this->add_css('blog'); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | Loader::load('collector', 'blog/TagCollector'); |
| 93 | 93 | |
| 94 | 94 | $tag_result = TagCollector::getTagsForPost($post->id); |
| 95 | - $tag_array = array(); |
|
| 95 | + $tag_array = array(); |
|
| 96 | 96 | foreach($tag_result as $tag) |
| 97 | 97 | { |
| 98 | 98 | $tag_object = new stdclass(); |
@@ -4,17 +4,17 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | $options = getopt('f:'); |
| 6 | 6 | if (empty($options['f'])) { |
| 7 | - exit('Must pass in a file with the f parameter.'); |
|
| 7 | + exit('Must pass in a file with the f parameter.'); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | use Abraham\TwitterOAuth\TwitterOAuth; |
| 11 | 11 | use Jacobemerick\Web\Domain\Stream\Twitter\MysqlTwitterRepository as TwitterRepository; |
| 12 | 12 | |
| 13 | 13 | $client = new TwitterOAuth( |
| 14 | - $config->twitter->consumer_key, |
|
| 15 | - $config->twitter->consumer_secret, |
|
| 16 | - $config->twitter->access_token, |
|
| 17 | - $config->twitter->access_token_secret |
|
| 14 | + $config->twitter->consumer_key, |
|
| 15 | + $config->twitter->consumer_secret, |
|
| 16 | + $config->twitter->access_token, |
|
| 17 | + $config->twitter->access_token_secret |
|
| 18 | 18 | ); |
| 19 | 19 | $client->setDecodeJsonAsArray(true); |
| 20 | 20 | |
@@ -24,29 +24,29 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $handle = fopen(__DIR__ . '/' . $options['f'], 'r'); |
| 26 | 26 | while ($row = fgets($handle)) { |
| 27 | - array_push($idList, trim($row)); |
|
| 28 | - if (count($idList) == 100) { |
|
| 29 | - $tweetLookup = $client->get('statuses/lookup', [ |
|
| 30 | - 'id' => implode(',', $idList), |
|
| 31 | - 'trim_user' => true, |
|
| 32 | - ]); |
|
| 33 | - |
|
| 34 | - foreach ($tweetLookup as $tweet) { |
|
| 35 | - $uniqueTweetCheck = $twitterRepository->getTwitterByTweetId($tweet['id_str']); |
|
| 36 | - if ($uniqueTweetCheck !== false) { |
|
| 37 | - if ($uniqueTweetCheck['metadata'] != json_encode($tweet)) { |
|
| 38 | - $twitterRepository->updateTweetMetadata($tweet['id_str'], $tweet); |
|
| 39 | - } |
|
| 40 | - continue; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $twitterRepository->insertTweet( |
|
| 44 | - $tweet['id_str'], |
|
| 45 | - (new DateTime($tweet['created_at']))->setTimezone($container['default_timezone']), |
|
| 46 | - $tweet |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - $idList = []; |
|
| 50 | - } |
|
| 27 | + array_push($idList, trim($row)); |
|
| 28 | + if (count($idList) == 100) { |
|
| 29 | + $tweetLookup = $client->get('statuses/lookup', [ |
|
| 30 | + 'id' => implode(',', $idList), |
|
| 31 | + 'trim_user' => true, |
|
| 32 | + ]); |
|
| 33 | + |
|
| 34 | + foreach ($tweetLookup as $tweet) { |
|
| 35 | + $uniqueTweetCheck = $twitterRepository->getTwitterByTweetId($tweet['id_str']); |
|
| 36 | + if ($uniqueTweetCheck !== false) { |
|
| 37 | + if ($uniqueTweetCheck['metadata'] != json_encode($tweet)) { |
|
| 38 | + $twitterRepository->updateTweetMetadata($tweet['id_str'], $tweet); |
|
| 39 | + } |
|
| 40 | + continue; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $twitterRepository->insertTweet( |
|
| 44 | + $tweet['id_str'], |
|
| 45 | + (new DateTime($tweet['created_at']))->setTimezone($container['default_timezone']), |
|
| 46 | + $tweet |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + $idList = []; |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | fclose($handle); |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface ActivityRepositoryInterface |
| 6 | 6 | { |
| 7 | - public function getActivityById($id); |
|
| 8 | - public function getActivities($limit = null, $offset = 0); |
|
| 9 | - public function getActivitiesCount(); |
|
| 10 | - public function getActivitiesByType($type, $limit = null, $offset = 0); |
|
| 11 | - public function getActivitiesByTypeCount($type); |
|
| 7 | + public function getActivityById($id); |
|
| 8 | + public function getActivities($limit = null, $offset = 0); |
|
| 9 | + public function getActivitiesCount(); |
|
| 10 | + public function getActivitiesByType($type, $limit = null, $offset = 0); |
|
| 11 | + public function getActivitiesByTypeCount($type); |
|
| 12 | 12 | } |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function __construct() |
| 12 | 12 | { |
| 13 | - parent::__construct(); |
|
| 13 | + parent::__construct(); |
|
| 14 | 14 | |
| 15 | - global $container; |
|
| 16 | - $this->activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
|
| 15 | + global $container; |
|
| 16 | + $this->activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | protected function set_head_data() |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | |
| 46 | 46 | protected function get_list_results() |
| 47 | 47 | { |
| 48 | - return $this->activityRepository->getActivities(self::$POSTS_PER_PAGE, $this->offset); |
|
| 48 | + return $this->activityRepository->getActivities(self::$POSTS_PER_PAGE, $this->offset); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | protected function get_list_description() |
@@ -56,37 +56,37 @@ discard block |
||
| 56 | 56 | return $domain_container; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function get_recent_activity() |
|
| 60 | - { |
|
| 61 | - global $container; |
|
| 62 | - $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
|
| 63 | - $post_result = $activityRepository->getActivities(5); |
|
| 64 | - |
|
| 65 | - $post_array = array(); |
|
| 66 | - foreach($post_result as $row) { |
|
| 67 | - array_push($post_array, $this->expand_post($row)); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return $post_array; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - protected function expand_post($raw_post, $format = 'short') |
|
| 74 | - { |
|
| 75 | - $post = [ |
|
| 76 | - 'type' => $raw_post['type'], |
|
| 77 | - 'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'], |
|
| 78 | - 'date' => $this->get_parsed_date($raw_post['datetime']), |
|
| 79 | - ]; |
|
| 80 | - |
|
| 81 | - if ($format != 'short') { |
|
| 82 | - $post['url'] = Loader::getRootUrl('lifestream') . "{$raw_post['type']}/{$raw_post['id']}/"; |
|
| 83 | - |
|
| 84 | - $metadata = json_decode($raw_post['metadata'], true); |
|
| 85 | - $post = array_merge($post, $metadata); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return (object) $post; |
|
| 89 | - } |
|
| 59 | + protected function get_recent_activity() |
|
| 60 | + { |
|
| 61 | + global $container; |
|
| 62 | + $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
|
| 63 | + $post_result = $activityRepository->getActivities(5); |
|
| 64 | + |
|
| 65 | + $post_array = array(); |
|
| 66 | + foreach($post_result as $row) { |
|
| 67 | + array_push($post_array, $this->expand_post($row)); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return $post_array; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + protected function expand_post($raw_post, $format = 'short') |
|
| 74 | + { |
|
| 75 | + $post = [ |
|
| 76 | + 'type' => $raw_post['type'], |
|
| 77 | + 'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'], |
|
| 78 | + 'date' => $this->get_parsed_date($raw_post['datetime']), |
|
| 79 | + ]; |
|
| 80 | + |
|
| 81 | + if ($format != 'short') { |
|
| 82 | + $post['url'] = Loader::getRootUrl('lifestream') . "{$raw_post['type']}/{$raw_post['id']}/"; |
|
| 83 | + |
|
| 84 | + $metadata = json_decode($raw_post['metadata'], true); |
|
| 85 | + $post = array_merge($post, $metadata); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return (object) $post; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | public function activate() |
| 92 | 92 | { |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if (URLDecode::getSite() == 'waterfalls') { |
|
| 111 | - Loader::load('view', '/WaterfallFoot'); |
|
| 112 | - } else { |
|
| 113 | - Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
|
| 114 | - } |
|
| 110 | + if (URLDecode::getSite() == 'waterfalls') { |
|
| 111 | + Loader::load('view', '/WaterfallFoot'); |
|
| 112 | + } else { |
|
| 113 | + Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | if($view == '/404' || $view == '/503') |
| 117 | 117 | exit; |
@@ -169,19 +169,19 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | private function load_assets() |
| 171 | 171 | { |
| 172 | - $css_array = array_map(function ($stylesheet) { |
|
| 173 | - $path = "/css/{$stylesheet[0]}.css"; |
|
| 174 | - if ($stylesheet[1] > 1) { |
|
| 175 | - $path .= "?v={$stylesheet[1]}"; |
|
| 176 | - } |
|
| 177 | - return $path; |
|
| 178 | - }, $this->css_array); |
|
| 179 | - $js_array = array_map(function ($script) { |
|
| 180 | - if (substr($script, 0, 4) == 'http') { |
|
| 181 | - return $script; |
|
| 182 | - } |
|
| 183 | - return "/js/{$script}.min.js"; |
|
| 184 | - }, $this->js_array); |
|
| 172 | + $css_array = array_map(function ($stylesheet) { |
|
| 173 | + $path = "/css/{$stylesheet[0]}.css"; |
|
| 174 | + if ($stylesheet[1] > 1) { |
|
| 175 | + $path .= "?v={$stylesheet[1]}"; |
|
| 176 | + } |
|
| 177 | + return $path; |
|
| 178 | + }, $this->css_array); |
|
| 179 | + $js_array = array_map(function ($script) { |
|
| 180 | + if (substr($script, 0, 4) == 'http') { |
|
| 181 | + return $script; |
|
| 182 | + } |
|
| 183 | + return "/js/{$script}.min.js"; |
|
| 184 | + }, $this->js_array); |
|
| 185 | 185 | |
| 186 | 186 | $this->set_head('css_link_array', $css_array); |
| 187 | 187 | $this->set_head('js_link_array', $js_array); |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | case 'distance' : |
| 58 | 58 | return 'Run, Jacob, and Hike'; |
| 59 | 59 | break; |
| 60 | - case 'github' : |
|
| 61 | - return 'Jacob, Code Monkey'; |
|
| 62 | - break; |
|
| 60 | + case 'github' : |
|
| 61 | + return 'Jacob, Code Monkey'; |
|
| 62 | + break; |
|
| 63 | 63 | case 'hulu' : |
| 64 | 64 | return 'Jacob watches Hulu'; |
| 65 | 65 | break; |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | case 'distance' : |
| 86 | 86 | return 'All the cool kids like to be in shape. Jacob goes running and hiking.'; |
| 87 | 87 | break; |
| 88 | - case 'github' : |
|
| 89 | - return 'Since he is trying to be a developer, Jacob codes. Here is some code that he pushed around on the Githubs.'; |
|
| 90 | - break; |
|
| 88 | + case 'github' : |
|
| 89 | + return 'Since he is trying to be a developer, Jacob codes. Here is some code that he pushed around on the Githubs.'; |
|
| 90 | + break; |
|
| 91 | 91 | case 'hulu' : |
| 92 | 92 | return 'Occasionally Jacob chills and watches some Hulu. Well, used to, anyways.'; |
| 93 | 93 | break; |