@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | * @return boolean |
| 20 | 20 | */ |
| 21 | 21 | $buildFeed = function (Feed $feed, $folder) { |
| 22 | - $tempFeed = __DIR__ . "/../../public/{$folder}/rss-new.xml"; |
|
| 23 | - $finalFeed = __DIR__ . "/../../public/{$folder}/rss.xml"; |
|
| 22 | + $tempFeed = __DIR__ . "/../../public/{$folder}/rss-new.xml"; |
|
| 23 | + $finalFeed = __DIR__ . "/../../public/{$folder}/rss.xml"; |
|
| 24 | 24 | |
| 25 | - $feedHandle = fopen($tempFeed, 'w'); |
|
| 26 | - fwrite($feedHandle, $feed->render()); |
|
| 27 | - fclose($feedHandle); |
|
| 25 | + $feedHandle = fopen($tempFeed, 'w'); |
|
| 26 | + fwrite($feedHandle, $feed->render()); |
|
| 27 | + fclose($feedHandle); |
|
| 28 | 28 | |
| 29 | - rename($tempFeed, $finalFeed); |
|
| 29 | + rename($tempFeed, $finalFeed); |
|
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | |
@@ -45,26 +45,26 @@ discard block |
||
| 45 | 45 | $activeBlogPosts = $blogPostRepository->getActivePosts(); |
| 46 | 46 | |
| 47 | 47 | foreach ($activeBlogPosts as $blogPost) { |
| 48 | - $blogPostItem = new Item(); |
|
| 48 | + $blogPostItem = new Item(); |
|
| 49 | 49 | |
| 50 | - $blogPostItem->title($blogPost['title']); |
|
| 50 | + $blogPostItem->title($blogPost['title']); |
|
| 51 | 51 | |
| 52 | - $url = "http://blog.jacobemerick.com/{$blogPost['category']}/{$blogPost['path']}/"; |
|
| 53 | - $blogPostItem->url($url); |
|
| 54 | - $blogPostItem->guid($url, true); |
|
| 52 | + $url = "http://blog.jacobemerick.com/{$blogPost['category']}/{$blogPost['path']}/"; |
|
| 53 | + $blogPostItem->url($url); |
|
| 54 | + $blogPostItem->guid($url, true); |
|
| 55 | 55 | |
| 56 | - $description = $blogPost['body']; |
|
| 57 | - $description = Content::instance('FixPhoto', $description)->activate(true); // todo kill this with fire |
|
| 58 | - $description = htmlentities($description); |
|
| 59 | - $blogPostItem->description($description); |
|
| 56 | + $description = $blogPost['body']; |
|
| 57 | + $description = Content::instance('FixPhoto', $description)->activate(true); // todo kill this with fire |
|
| 58 | + $description = htmlentities($description); |
|
| 59 | + $blogPostItem->description($description); |
|
| 60 | 60 | |
| 61 | - $categoryUrl = "http://blog.jacobemerick.com/{$blogPost['category']}/"; |
|
| 62 | - $blogPostItem->category($blogPost['category'], $categoryUrl); |
|
| 61 | + $categoryUrl = "http://blog.jacobemerick.com/{$blogPost['category']}/"; |
|
| 62 | + $blogPostItem->category($blogPost['category'], $categoryUrl); |
|
| 63 | 63 | |
| 64 | - $pubDate = new DateTime($blogPost['date']); |
|
| 65 | - $blogPostItem->pubDate($pubDate->getTimestamp()); |
|
| 64 | + $pubDate = new DateTime($blogPost['date']); |
|
| 65 | + $blogPostItem->pubDate($pubDate->getTimestamp()); |
|
| 66 | 66 | |
| 67 | - $blogPostItem->appendTo($blogPostChannel); |
|
| 67 | + $blogPostItem->appendTo($blogPostChannel); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $buildFeed($blogPostFeed, 'blog'); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * @param string $folder |
| 19 | 19 | * @return boolean |
| 20 | 20 | */ |
| 21 | -$buildFeed = function (Feed $feed, $folder) { |
|
| 21 | +$buildFeed = function(Feed $feed, $folder) { |
|
| 22 | 22 | $tempFeed = __DIR__ . "/../../public/{$folder}/rss-new.xml"; |
| 23 | 23 | $finalFeed = __DIR__ . "/../../public/{$folder}/rss.xml"; |
| 24 | 24 | |
@@ -17,26 +17,26 @@ discard block |
||
| 17 | 17 | * @return boolean |
| 18 | 18 | */ |
| 19 | 19 | $buildSitemap = function (array $entries, $domain, $folder) { |
| 20 | - $urlSet = new Urlset(); |
|
| 21 | - foreach ($entries as $path => $entry) { |
|
| 22 | - $url = new Url("{$domain}{$path}"); // todo better detection of domain by env |
|
| 23 | - $url->setLastMod($entry['lastmod']); // todo check if exists |
|
| 24 | - $url->setChangeFreq($entry['changefreq']); // todo check if exists |
|
| 25 | - $url->setPriority($entry['priority']); // todo check if exists |
|
| 26 | - $urlSet->addUrl($url); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - $output = new Output(); |
|
| 30 | - $output->setIndentString(' '); // change indentation from 4 to 2 spaces |
|
| 31 | - |
|
| 32 | - $tempSitemap = __DIR__ . "/../../public/{$folder}/sitemap-new.xml"; |
|
| 33 | - $finalSitemap = __DIR__ . "/../../public/{$folder}/sitemap.xml"; |
|
| 34 | - |
|
| 35 | - $sitemapHandle = fopen($tempSitemap, 'w'); |
|
| 36 | - fwrite($sitemapHandle, $output->getOutput($urlSet)); |
|
| 37 | - fclose($sitemapHandle); |
|
| 38 | - |
|
| 39 | - rename($tempSitemap, $finalSitemap); |
|
| 20 | + $urlSet = new Urlset(); |
|
| 21 | + foreach ($entries as $path => $entry) { |
|
| 22 | + $url = new Url("{$domain}{$path}"); // todo better detection of domain by env |
|
| 23 | + $url->setLastMod($entry['lastmod']); // todo check if exists |
|
| 24 | + $url->setChangeFreq($entry['changefreq']); // todo check if exists |
|
| 25 | + $url->setPriority($entry['priority']); // todo check if exists |
|
| 26 | + $urlSet->addUrl($url); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + $output = new Output(); |
|
| 30 | + $output->setIndentString(' '); // change indentation from 4 to 2 spaces |
|
| 31 | + |
|
| 32 | + $tempSitemap = __DIR__ . "/../../public/{$folder}/sitemap-new.xml"; |
|
| 33 | + $finalSitemap = __DIR__ . "/../../public/{$folder}/sitemap.xml"; |
|
| 34 | + |
|
| 35 | + $sitemapHandle = fopen($tempSitemap, 'w'); |
|
| 36 | + fwrite($sitemapHandle, $output->getOutput($urlSet)); |
|
| 37 | + fclose($sitemapHandle); |
|
| 38 | + |
|
| 39 | + rename($tempSitemap, $finalSitemap); |
|
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | 42 | |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | * blog.jacobemerick.com |
| 45 | 45 | *********************************************/ |
| 46 | 46 | $reduceToMostRecentBlogPost = function ($recentPost, $post) { |
| 47 | - if (is_null($recentPost)) { |
|
| 48 | - return $post; |
|
| 49 | - } |
|
| 50 | - $postDate = new DateTime($post['date']); |
|
| 51 | - $recentPostDate = new DateTime($recentPost['date']); |
|
| 52 | - return ($postDate > $recentPostDate) ? $post: $recentPost; |
|
| 47 | + if (is_null($recentPost)) { |
|
| 48 | + return $post; |
|
| 49 | + } |
|
| 50 | + $postDate = new DateTime($post['date']); |
|
| 51 | + $recentPostDate = new DateTime($recentPost['date']); |
|
| 52 | + return ($postDate > $recentPostDate) ? $post: $recentPost; |
|
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | 55 | $blogPostsPerPage = 10; |
@@ -60,106 +60,106 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // todo these post-level dates should be accurate to H:i:s |
| 62 | 62 | $entryArray = [ |
| 63 | - '/' => [ |
|
| 64 | - 'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'), |
|
| 65 | - 'changefreq' => 'daily', |
|
| 66 | - 'priority' => .9, |
|
| 67 | - ] |
|
| 63 | + '/' => [ |
|
| 64 | + 'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'), |
|
| 65 | + 'changefreq' => 'daily', |
|
| 66 | + 'priority' => .9, |
|
| 67 | + ] |
|
| 68 | 68 | ]; |
| 69 | 69 | for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($activeBlogPosts); $i++) { |
| 70 | - $entryKey = "/{$i}/"; |
|
| 71 | - $entryArray += [ |
|
| 72 | - $entryKey => [ |
|
| 73 | - 'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'), |
|
| 74 | - 'changefreq' => 'daily', |
|
| 75 | - 'priority' => .1, |
|
| 76 | - ] |
|
| 77 | - ]; |
|
| 70 | + $entryKey = "/{$i}/"; |
|
| 71 | + $entryArray += [ |
|
| 72 | + $entryKey => [ |
|
| 73 | + 'lastmod' => (new DateTime($mostRecentBlogPost['date']))->format('Y-m-d'), |
|
| 74 | + 'changefreq' => 'daily', |
|
| 75 | + 'priority' => .1, |
|
| 76 | + ] |
|
| 77 | + ]; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $blogCategoryArray = [ |
| 81 | - 'hiking', |
|
| 82 | - 'personal', |
|
| 83 | - 'web-development', |
|
| 81 | + 'hiking', |
|
| 82 | + 'personal', |
|
| 83 | + 'web-development', |
|
| 84 | 84 | ]; |
| 85 | 85 | |
| 86 | 86 | foreach ($blogCategoryArray as $blogCategory) { |
| 87 | - $blogCategoryPosts = array_filter($activeBlogPosts, function ($post) use ($blogCategory) { |
|
| 88 | - return $post['category'] == $blogCategory; |
|
| 89 | - }); |
|
| 90 | - $mostRecentBlogCategoryPost = array_reduce($blogCategoryPosts, $reduceToMostRecentBlogPost); |
|
| 91 | - |
|
| 92 | - $entryKey = "/{$blogCategory}/"; |
|
| 93 | - $entryArray += [ |
|
| 94 | - $entryKey => [ |
|
| 95 | - 'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'), |
|
| 96 | - 'changefreq' => 'daily', |
|
| 97 | - 'priority' => .3, |
|
| 98 | - ] |
|
| 99 | - ]; |
|
| 100 | - |
|
| 101 | - for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogCategoryPosts); $i++) { |
|
| 102 | - $entryKey = "/{$blogCategory}/{$i}/"; |
|
| 103 | - $entryArray += [ |
|
| 104 | - $entryKey => [ |
|
| 105 | - 'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'), |
|
| 106 | - 'changefreq' => 'daily', |
|
| 107 | - 'priority' => .1, |
|
| 108 | - ] |
|
| 109 | - ]; |
|
| 110 | - } |
|
| 87 | + $blogCategoryPosts = array_filter($activeBlogPosts, function ($post) use ($blogCategory) { |
|
| 88 | + return $post['category'] == $blogCategory; |
|
| 89 | + }); |
|
| 90 | + $mostRecentBlogCategoryPost = array_reduce($blogCategoryPosts, $reduceToMostRecentBlogPost); |
|
| 91 | + |
|
| 92 | + $entryKey = "/{$blogCategory}/"; |
|
| 93 | + $entryArray += [ |
|
| 94 | + $entryKey => [ |
|
| 95 | + 'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'), |
|
| 96 | + 'changefreq' => 'daily', |
|
| 97 | + 'priority' => .3, |
|
| 98 | + ] |
|
| 99 | + ]; |
|
| 100 | + |
|
| 101 | + for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogCategoryPosts); $i++) { |
|
| 102 | + $entryKey = "/{$blogCategory}/{$i}/"; |
|
| 103 | + $entryArray += [ |
|
| 104 | + $entryKey => [ |
|
| 105 | + 'lastmod' => (new DateTime($mostRecentBlogCategoryPost['date']))->format('Y-m-d'), |
|
| 106 | + 'changefreq' => 'daily', |
|
| 107 | + 'priority' => .1, |
|
| 108 | + ] |
|
| 109 | + ]; |
|
| 110 | + } |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $blogTagRepository = new BlogTagRepository($container['db_connection_locator']); |
| 114 | 114 | $blogTags = $blogTagRepository->getAllTags(); |
| 115 | 115 | foreach ($blogTags as $blogTag) { |
| 116 | - $blogPostsWithTag = $blogPostRepository->getActivePostsByTag($blogTag['id']); |
|
| 117 | - if (count($blogPostsWithTag) < 1) { |
|
| 118 | - continue; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $mostRecentBlogTagPost = array_reduce($blogPostsWithTag, $reduceToMostRecentBlogPost); |
|
| 122 | - |
|
| 123 | - $entryKey = "/tag/{$blogTag['tag']}/"; |
|
| 124 | - $entryArray += [ |
|
| 125 | - $entryKey => [ |
|
| 126 | - 'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'), |
|
| 127 | - 'changefreq' => 'daily', |
|
| 128 | - 'priority' => .1, |
|
| 129 | - ] |
|
| 130 | - ]; |
|
| 131 | - |
|
| 132 | - for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogPostsWithTag); $i++) { |
|
| 133 | - $blogTagPath = str_replace(' ', '-', $blogTag['tag']); |
|
| 134 | - $entryKey = "/tag/{$blogTagPath}/{$i}/"; |
|
| 135 | - $entryArray += [ |
|
| 136 | - $entryKey => [ |
|
| 137 | - 'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'), |
|
| 138 | - 'changefreq' => 'daily', |
|
| 139 | - 'priority' => .1, |
|
| 140 | - ] |
|
| 141 | - ]; |
|
| 142 | - } |
|
| 116 | + $blogPostsWithTag = $blogPostRepository->getActivePostsByTag($blogTag['id']); |
|
| 117 | + if (count($blogPostsWithTag) < 1) { |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $mostRecentBlogTagPost = array_reduce($blogPostsWithTag, $reduceToMostRecentBlogPost); |
|
| 122 | + |
|
| 123 | + $entryKey = "/tag/{$blogTag['tag']}/"; |
|
| 124 | + $entryArray += [ |
|
| 125 | + $entryKey => [ |
|
| 126 | + 'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'), |
|
| 127 | + 'changefreq' => 'daily', |
|
| 128 | + 'priority' => .1, |
|
| 129 | + ] |
|
| 130 | + ]; |
|
| 131 | + |
|
| 132 | + for ($i = 2; (($i - 1) * $blogPostsPerPage) < count($blogPostsWithTag); $i++) { |
|
| 133 | + $blogTagPath = str_replace(' ', '-', $blogTag['tag']); |
|
| 134 | + $entryKey = "/tag/{$blogTagPath}/{$i}/"; |
|
| 135 | + $entryArray += [ |
|
| 136 | + $entryKey => [ |
|
| 137 | + 'lastmod' => (new DateTime($mostRecentBlogTagPost['date']))->format('Y-m-d'), |
|
| 138 | + 'changefreq' => 'daily', |
|
| 139 | + 'priority' => .1, |
|
| 140 | + ] |
|
| 141 | + ]; |
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $reversedBlogPosts = array_reverse($activeBlogPosts); |
| 146 | 146 | foreach ($reversedBlogPosts as $blogPost) { |
| 147 | - $entryKey = "/{$blogPost['category']}/{$blogPost['path']}/"; |
|
| 148 | - $entryArray += [ |
|
| 149 | - $entryKey => [ |
|
| 150 | - 'lastmod' => (new DateTime($blogPost['date']))->format('Y-m-d'), // todo this should be based on comment |
|
| 151 | - 'changefreq' => 'weekly', |
|
| 152 | - 'priority' => .8, |
|
| 153 | - ], |
|
| 154 | - ]; |
|
| 147 | + $entryKey = "/{$blogPost['category']}/{$blogPost['path']}/"; |
|
| 148 | + $entryArray += [ |
|
| 149 | + $entryKey => [ |
|
| 150 | + 'lastmod' => (new DateTime($blogPost['date']))->format('Y-m-d'), // todo this should be based on comment |
|
| 151 | + 'changefreq' => 'weekly', |
|
| 152 | + 'priority' => .8, |
|
| 153 | + ], |
|
| 154 | + ]; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $entryArray += [ |
| 158 | - '/about/' => [ |
|
| 159 | - 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 160 | - 'changefreq' => 'monthly', |
|
| 161 | - 'priority' => .2, |
|
| 162 | - ] |
|
| 158 | + '/about/' => [ |
|
| 159 | + 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 160 | + 'changefreq' => 'monthly', |
|
| 161 | + 'priority' => .2, |
|
| 162 | + ] |
|
| 163 | 163 | ]; |
| 164 | 164 | |
| 165 | 165 | $buildSitemap($entryArray, 'http://blog.jacobemerick.com', 'blog'); |
@@ -169,26 +169,26 @@ discard block |
||
| 169 | 169 | * site.jacobemerick.com |
| 170 | 170 | *********************************************/ |
| 171 | 171 | $entryArray = [ |
| 172 | - '/' => [ |
|
| 173 | - 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 174 | - 'changefreq' => 'weekly', |
|
| 175 | - 'priority' => 1, |
|
| 176 | - ], |
|
| 177 | - '/terms/' => [ |
|
| 178 | - 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 179 | - 'changefreq' => 'weekly', |
|
| 180 | - 'priority' => .3, |
|
| 181 | - ], |
|
| 182 | - '/change-log/' => [ |
|
| 183 | - 'lastmod' => (new DateTime('now'))->format('Y-m-d'), // todo lookup based on changelog |
|
| 184 | - 'changefreq' => 'daily', |
|
| 185 | - 'priority' => .1, |
|
| 186 | - ], |
|
| 187 | - '/contact/' => [ |
|
| 188 | - 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 189 | - 'changefreq' => 'weekly', |
|
| 190 | - 'priority' => .6, |
|
| 191 | - ], |
|
| 172 | + '/' => [ |
|
| 173 | + 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 174 | + 'changefreq' => 'weekly', |
|
| 175 | + 'priority' => 1, |
|
| 176 | + ], |
|
| 177 | + '/terms/' => [ |
|
| 178 | + 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 179 | + 'changefreq' => 'weekly', |
|
| 180 | + 'priority' => .3, |
|
| 181 | + ], |
|
| 182 | + '/change-log/' => [ |
|
| 183 | + 'lastmod' => (new DateTime('now'))->format('Y-m-d'), // todo lookup based on changelog |
|
| 184 | + 'changefreq' => 'daily', |
|
| 185 | + 'priority' => .1, |
|
| 186 | + ], |
|
| 187 | + '/contact/' => [ |
|
| 188 | + 'lastmod' => (new DateTime('December 20, 2015'))->format('Y-m-d'), |
|
| 189 | + 'changefreq' => 'weekly', |
|
| 190 | + 'priority' => .6, |
|
| 191 | + ], |
|
| 192 | 192 | ]; |
| 193 | 193 | |
| 194 | 194 | $buildSitemap($entryArray, 'http://site.jacobemerick.com', 'site'); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @param string $domain |
| 17 | 17 | * @return boolean |
| 18 | 18 | */ |
| 19 | -$buildSitemap = function (array $entries, $domain, $folder) { |
|
| 19 | +$buildSitemap = function(array $entries, $domain, $folder) { |
|
| 20 | 20 | $urlSet = new Urlset(); |
| 21 | 21 | foreach ($entries as $path => $entry) { |
| 22 | 22 | $url = new Url("{$domain}{$path}"); // todo better detection of domain by env |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | /********************************************* |
| 44 | 44 | * blog.jacobemerick.com |
| 45 | 45 | *********************************************/ |
| 46 | -$reduceToMostRecentBlogPost = function ($recentPost, $post) { |
|
| 46 | +$reduceToMostRecentBlogPost = function($recentPost, $post) { |
|
| 47 | 47 | if (is_null($recentPost)) { |
| 48 | 48 | return $post; |
| 49 | 49 | } |
| 50 | 50 | $postDate = new DateTime($post['date']); |
| 51 | 51 | $recentPostDate = new DateTime($recentPost['date']); |
| 52 | - return ($postDate > $recentPostDate) ? $post: $recentPost; |
|
| 52 | + return ($postDate > $recentPostDate) ? $post : $recentPost; |
|
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | 55 | $blogPostsPerPage = 10; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ]; |
| 85 | 85 | |
| 86 | 86 | foreach ($blogCategoryArray as $blogCategory) { |
| 87 | - $blogCategoryPosts = array_filter($activeBlogPosts, function ($post) use ($blogCategory) { |
|
| 87 | + $blogCategoryPosts = array_filter($activeBlogPosts, function($post) use ($blogCategory) { |
|
| 88 | 88 | return $post['category'] == $blogCategory; |
| 89 | 89 | }); |
| 90 | 90 | $mostRecentBlogCategoryPost = array_reduce($blogCategoryPosts, $reduceToMostRecentBlogPost); |