Mephisto Google Sitemaps Plugin
August 16th, 2007
Since I recently restructured my site I wanted to make changes quickly visible to Google. Sitemaps can help with this. I searched for Mephisto plugin. Found Sitemap Generator by Joseph Moore and Auto Generated Sitemaps by Greg Benedict.
Both were great but required manually editing Rails routes. They also did not use Mephistos plugin facilities which enable configuring through admin interface.
Based from two previous examples Mephisto Sitemap was born. Installing is as simple as:
script/plugin install
http://svn.appelsiini.net/svn/rails/plugins/mephisto_sitemap/
Restart you WEBrick or mongrel and youre set to go. Routes are automatically added to poing to your <mephisto_root>/sitemap.xml.
Now sit back and wait for you increased Google fame!
Changing Hostname of Mephisto Blog
July 5th, 2007
Recently I was developing a new website under Mephisto and multisite config. I developed site under temporary hostname. Below are the steps needed to change hostname of running Mephisto instance.
Lets assume old host of the site was dev.example.com. New host will be www.example.com.
In table sites update column host to have value example.com. Also update Apache config to understand the new hostname. Now Mephisto is ready to answer in new hostname.
Articles containing images or other assets still have old hostname in their url. They can be easily changed with MySQL’s REPLACE command. Four columns have to be updated in contents table:
UPDATE contents
SET body =
REPLACE(body, 'dev.example.com','www.example.com');
UPDATE contents
SET body_html =
REPLACE(body_html, 'dev.example.com'','www.example.com');
UPDATE contents
SET excerpt_html =
REPLACE(excerpt_html, 'dev.example.com'','www.example.com');
UPDATE contents
SET excerpt =
REPLACE(excerpt, 'dev.example.com'','www.example.com');
Last thing to change is the name of asset directory under mephisto folder.
>cd /www/mephisto/public/assets
>mv dev.example.com www.example.com
Thats it. Fire up you browser. Clear caches from Mephisto admin and check everything is ok.
UPDATE: There still seems to be problem with new assets being uploaded to wrong folder. Temporary fix for this is to make a symlink:
>cd /www/mephisto/public/assets
>ln -s www.example.com example.com
I’m sure there is a better way.
Mephisto Multiple Site Config
June 8th, 2007
Configuring Mephisto to support multiple sites can be confusing. Michael Slater wrote an excellent article describing how to setup multiple sites.
I had some problems with provided mod_rewrite rules. Some of requests never used Mephisto cache. Instead they were always redirected to Mongrel. With mod_rewrite logging turned on and Mephisto production log I was able to tweak it to work on my system running Apache2 and Mongrel.
My working config can be seen below. It is almost identical to Michaels. Main difference is to use RewriteRule (.∗) _ instead of _RewriteRule ^/(.∗)$ and REQUEST_URI instead of REQUEST_FILENAME in several places.
Options -MultiViews
RewriteEngine On
# asset redirection
RewriteCond %{REQUEST_URI} ^/assets/.*$
RewriteCond %{DOCUMENT_ROOT}/assets/%{HTTP_HOST}/$1 -f
RewriteRule ^assets/(.*)$ /assets/%{HTTP_HOST}/$1 [QSA,L]
# index redirection
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/index.html -f
RewriteRule (.*) /cache/%{HTTP_HOST}/index.html [QSA,L]
# content redirection
RewriteCond %{REQUEST_URI} ^/[^.]+$
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI}.html -f
RewriteRule (.*) /cache/%{HTTP_HOST}%{REQUEST_URI}.html [QSA,L]
# everything else
RewriteCond %{REQUEST_URI} ^/.+$
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}%{REQUEST_URI} -f
RewriteRule ^(.*)$ /cache/%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
# everything not found goes to Mongrel
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://127.0.0.1:3001%{REQUEST_URI} [L,P,QSA]
You can also download rules from svn.
ThickBox Macro For Mephisto - jQuery and Rails
March 26th, 2007
Some people consider it to be heretic to use jQuery with Ruby on Rails. Since I am big fan of jQuery I decided to do it anyway.
With filtered_column_thickbox_macro you can display single or multiple images with Lightbox effect. Macro uses Cody Linley’s ThickBox plugin. Code is based on Based on Christian Lim’s Lightbox Image Gallery Filter.
Installation
Install by issuing command (in one line):
script/plugin install
http://svn.appelsiini.net/svn/rails/plugins/filtered_column_thickbox_macro/
Script will copy needed Javascript, CSS and image files into your public folder. It does not overwrite any existing files. So if you rely in specific version of jQuery library it will be safe.