Completed
Push — master ( 3087cf...881d4b )
by Jacob
05:28
created
script/cron/generate-rss-feeds.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  * @return boolean
22 22
  */
23 23
 $buildFeed = function (Feed $feed, $folder, $name = 'rss') {
24
-    $tempFeed = __DIR__ . "/../../public/{$folder}/{$name}-new.xml";
25
-    $finalFeed = __DIR__ . "/../../public/{$folder}/{$name}.xml";
24
+	$tempFeed = __DIR__ . "/../../public/{$folder}/{$name}-new.xml";
25
+	$finalFeed = __DIR__ . "/../../public/{$folder}/{$name}.xml";
26 26
 
27
-    $feedHandle = fopen($tempFeed, 'w');
28
-    fwrite($feedHandle, $feed->render());
29
-    fclose($feedHandle);
27
+	$feedHandle = fopen($tempFeed, 'w');
28
+	fwrite($feedHandle, $feed->render());
29
+	fclose($feedHandle);
30 30
 
31
-    rename($tempFeed, $finalFeed);
31
+	rename($tempFeed, $finalFeed);
32 32
 };
33 33
 
34 34
 
@@ -47,56 +47,56 @@  discard block
 block discarded – undo
47 47
 $activeBlogPosts = $blogPostRepository->getActivePosts();
48 48
 
49 49
 foreach ($activeBlogPosts as $blogPost) {
50
-    $blogPostItem = new Item();
51
-
52
-    $blogPostItem->title($blogPost['title']);
53
-
54
-    $url = "http://blog.jacobemerick.com/{$blogPost['category']}/{$blogPost['path']}/";
55
-    $blogPostItem->url($url);
56
-    $blogPostItem->guid($url, true);
57
-
58
-    $description = $blogPost['body'];
59
-    $description = strip_tags($description);
60
-    $description = strtok($description, "\n");
61
-    if (strlen($description) > 250) {
62
-        $description = wordwrap($description, 250);
63
-        $description = strtok($description, "\n");
64
-        if (substr($description, -1) != '.') {
65
-            $description .= '…';
66
-        }
67
-    }
68
-    $description = html_entity_decode($description);
69
-    $blogPostItem->description($description);
70
-
71
-    $categoryUrl = "http://blog.jacobemerick.com/{$blogPost['category']}/";
72
-    $blogPostItem->category($blogPost['category'], $categoryUrl);
73
-
74
-    $pubDate = new DateTime($blogPost['date']);
75
-    $blogPostItem->pubDate($pubDate->getTimestamp());
76
-
77
-    $firstPhoto = Content::instance('FetchFirstPhoto', $blogPost['body'])->activate(true, 'large');
78
-    if (!empty($firstPhoto)) {
79
-        $firstPhotoPieces = sscanf($firstPhoto, '<img src="%s" height="%d" width="%d" alt="%s" />');
80
-        $firstPhotoPath = current($firstPhotoPieces);
81
-        $firstPhotoPath = trim($firstPhotoPath, '"');
82
-
83
-        $firstPhotoInternalPath = __DIR__ . '/../../public' . $firstPhotoPath;
84
-
85
-        $firstPhotoSize = filesize($firstPhotoInternalPath);
86
-
87
-        /**
88
-         * ugh, remote host does not have pecl fileinfo
89
-         *
90
-         * $fInfo = new finfo(FILEINFO_MIME_TYPE);
91
-         * $firstPhotoType = $fInfo->file($firstPhotoInternalPath);
92
-         * unset($fInfo);
93
-         **/
94
-        $firstPhotoType = 'image/jpeg';
95
-
96
-        $blogPostItem->enclosure("http://blog.jacobemerick.com{$firstPhotoPath}", $firstPhotoSize, $firstPhotoType);
97
-    }
98
-
99
-    $blogPostItem->appendTo($blogPostChannel);
50
+	$blogPostItem = new Item();
51
+
52
+	$blogPostItem->title($blogPost['title']);
53
+
54
+	$url = "http://blog.jacobemerick.com/{$blogPost['category']}/{$blogPost['path']}/";
55
+	$blogPostItem->url($url);
56
+	$blogPostItem->guid($url, true);
57
+
58
+	$description = $blogPost['body'];
59
+	$description = strip_tags($description);
60
+	$description = strtok($description, "\n");
61
+	if (strlen($description) > 250) {
62
+		$description = wordwrap($description, 250);
63
+		$description = strtok($description, "\n");
64
+		if (substr($description, -1) != '.') {
65
+			$description .= '&hellip;';
66
+		}
67
+	}
68
+	$description = html_entity_decode($description);
69
+	$blogPostItem->description($description);
70
+
71
+	$categoryUrl = "http://blog.jacobemerick.com/{$blogPost['category']}/";
72
+	$blogPostItem->category($blogPost['category'], $categoryUrl);
73
+
74
+	$pubDate = new DateTime($blogPost['date']);
75
+	$blogPostItem->pubDate($pubDate->getTimestamp());
76
+
77
+	$firstPhoto = Content::instance('FetchFirstPhoto', $blogPost['body'])->activate(true, 'large');
78
+	if (!empty($firstPhoto)) {
79
+		$firstPhotoPieces = sscanf($firstPhoto, '<img src="%s" height="%d" width="%d" alt="%s" />');
80
+		$firstPhotoPath = current($firstPhotoPieces);
81
+		$firstPhotoPath = trim($firstPhotoPath, '"');
82
+
83
+		$firstPhotoInternalPath = __DIR__ . '/../../public' . $firstPhotoPath;
84
+
85
+		$firstPhotoSize = filesize($firstPhotoInternalPath);
86
+
87
+		/**
88
+		 * ugh, remote host does not have pecl fileinfo
89
+		 *
90
+		 * $fInfo = new finfo(FILEINFO_MIME_TYPE);
91
+		 * $firstPhotoType = $fInfo->file($firstPhotoInternalPath);
92
+		 * unset($fInfo);
93
+		 **/
94
+		$firstPhotoType = 'image/jpeg';
95
+
96
+		$blogPostItem->enclosure("http://blog.jacobemerick.com{$firstPhotoPath}", $firstPhotoSize, $firstPhotoType);
97
+	}
98
+
99
+	$blogPostItem->appendTo($blogPostChannel);
100 100
 }
101 101
 
102 102
 $buildFeed($blogPostFeed, 'blog');
@@ -114,33 +114,33 @@  discard block
 block discarded – undo
114 114
 $activeBlogComments = $commentRepository->getActiveCommentsBySite('blog');
115 115
 
116 116
 foreach ($activeBlogComments as $blogComment) {
117
-    $blogCommentItem = new Item();
118
-
119
-    $blogCommentItem->title("Comment on '{$blogComment['title']}' from {$blogComment['name']}");
120
-
121
-    $url = "http://blog.jacobemerick.com/{$blogComment['category']}/{$blogComment['path']}/";
122
-    $url .= "#comment-{$blogComment['id']}";
123
-    $blogCommentItem->url($url);
124
-    $blogCommentItem->guid($url, true);
125
-
126
-    $description = $blogComment['body'];
127
-    $description = strip_tags($description);
128
-    $description = strtok($description, "\n");
129
-    if (strlen($description) > 250) {
130
-        $description = wordwrap($description, 250);
131
-        $description = strtok($description, "\n");
132
-        if (substr($description, -1) != '.') {
133
-            $description .= '&hellip;';
134
-        }
135
-    }
136
-    $description = html_entity_decode($description);
137
-    $description = trim($description);
138
-    $blogCommentItem->description($description);
139
-
140
-    $pubDate = new DateTime($blogComment['date']);
141
-    $blogCommentItem->pubDate($pubDate->getTimestamp());
142
-
143
-    $blogCommentItem->appendTo($blogCommentChannel);
117
+	$blogCommentItem = new Item();
118
+
119
+	$blogCommentItem->title("Comment on '{$blogComment['title']}' from {$blogComment['name']}");
120
+
121
+	$url = "http://blog.jacobemerick.com/{$blogComment['category']}/{$blogComment['path']}/";
122
+	$url .= "#comment-{$blogComment['id']}";
123
+	$blogCommentItem->url($url);
124
+	$blogCommentItem->guid($url, true);
125
+
126
+	$description = $blogComment['body'];
127
+	$description = strip_tags($description);
128
+	$description = strtok($description, "\n");
129
+	if (strlen($description) > 250) {
130
+		$description = wordwrap($description, 250);
131
+		$description = strtok($description, "\n");
132
+		if (substr($description, -1) != '.') {
133
+			$description .= '&hellip;';
134
+		}
135
+	}
136
+	$description = html_entity_decode($description);
137
+	$description = trim($description);
138
+	$blogCommentItem->description($description);
139
+
140
+	$pubDate = new DateTime($blogComment['date']);
141
+	$blogCommentItem->pubDate($pubDate->getTimestamp());
142
+
143
+	$blogCommentItem->appendTo($blogCommentChannel);
144 144
 }
145 145
 
146 146
 $buildFeed($blogCommentFeed, 'blog', 'rss-comments');
Please login to merge, or discard this patch.