Skip to content
This repository has been archived by the owner on Apr 6, 2018. It is now read-only.

Commit

Permalink
Moved tag pages to /tags and /year/month/tag
Browse files Browse the repository at this point in the history
  • Loading branch information
nickwynja committed Dec 1, 2012
1 parent ff21317 commit b06e768
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
20 changes: 10 additions & 10 deletions engine/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ private static function _update($restart_if_resequenced = true)
{
if (! file_exists(self::$dest_path)) mkdir_as_parent_owner(self::$dest_path, 0755, true);
if (! file_exists(self::$dest_path . '/.htaccess')) copy(dirname(__FILE__) . '/default.htaccess', self::$dest_path . '/.htaccess');

if (! file_exists(self::$dest_path . '/tag')) mkdir_as_parent_owner(self::$dest_path . '/tag', 0755, true);
if (! file_exists(self::$source_path . '/drafts/_publish-now')) mkdir_as_parent_owner(self::$source_path . '/drafts/_publish-now', 0755, true);
if (! file_exists(self::$source_path . '/drafts/_previews')) mkdir_as_parent_owner(self::$source_path . '/drafts/_previews', 0755, true);
if (! file_exists(self::$source_path . '/pages')) mkdir_as_parent_owner(self::$source_path . '/pages', 0755, true);
Expand Down Expand Up @@ -503,7 +503,7 @@ private static function _update($restart_if_resequenced = true)
$post->write_permalink_page();

self::set_has_posts_for_month($post->year, $post->month);
foreach ($post->tags as $tag) self::set_has_posts_for_month($post->year, $post->month, 'tagged-' . $tag);
foreach ($post->tags as $tag) self::set_has_posts_for_month($post->year, $post->month, $tag);
if ($post->type) self::set_has_posts_for_month($post->year, $post->month, 'type-' . $post->type);

} else {
Expand Down Expand Up @@ -602,7 +602,7 @@ private static function _update($restart_if_resequenced = true)
self::$changes_were_written = true;

$seq_count = Post::write_index_sequence(
self::$dest_path . "/tagged-$tag",
self::$dest_path . "/tag/$tag",
Post::$blog_title,
'tag',
Post::from_files(self::most_recent_post_filenames(0, $tag, self::$archive_tag_filter)),
Expand All @@ -612,38 +612,38 @@ private static function _update($restart_if_resequenced = true)
);

Post::write_index(
self::$dest_path . "/tagged-$tag.html",
self::$dest_path . "/tag/$tag.html",
Post::$blog_title,
'tag',
Post::from_files(self::most_recent_post_filenames(self::$frontpage_post_limit, $tag, self::$archive_tag_filter)),
self::$tag_page_template,
self::archive_array('tagged-' . $tag),
self::archive_array($tag),
$seq_count
);

Post::write_index(
self::$dest_path . "/tagged-$tag.xml",
self::$dest_path . "/tag/$tag.xml",
Post::$blog_title,
'tag',
Post::from_files(self::most_recent_post_filenames(self::$rss_post_limit, $tag, self::$archive_tag_filter)),
self::$rss_template,
self::archive_array('tagged-' . $tag)
self::archive_array($tag)
);

$months_with_posts = self::months_with_posts('tagged-' . $tag);
$months_with_posts = self::months_with_posts($tag);
foreach (self::$index_months_to_be_updated as $ym => $x) {
list($year, $month) = explode('-', $ym);
if (! isset($months_with_posts[$year]) || ! isset($months_with_posts[$year][intval($month)])) continue;
error_log("Updating month index: $ym for tag: $tag");
$posts = Post::from_files(self::post_filenames_in_year_month($year, $month, $tag, self::$archive_type_filter));
$ts = mktime(0, 0, 0, $month, 15, $year);
Post::write_index(
self::$dest_path . "/$year/$month/tagged-$tag.html",
self::$dest_path . "/$year/$month/$tag.html",
date('F Y', $ts),
'tag',
$posts,
self::$tag_page_template,
self::archive_array('tagged-' . $tag)
self::archive_array($tag)
);
}
}
Expand Down
13 changes: 7 additions & 6 deletions engine/default.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ Options -MultiViews
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript text/xml text/rss text/rss+xml

RewriteEngine On

RewriteRule ^rss$ rss.xml [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule ^([^\.]*)$ - [T=text/html]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [QSA,L]

ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

RewriteRule ^(.*)$ $1.html [QSA,L]

0 comments on commit b06e768

Please sign in to comment.