Created
May 15, 2011 03:11
-
-
Save sleepingkingstudios/972856 to your computer and use it in GitHub Desktop.
ArticlesController (original implementation)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes | |
match 'articles/*path' => "articles#static" | |
match '*path' => "articles#static" | |
# app/controllers/ArticlesController | |
class ArticlesController < ApplicationController | |
# GET /articles/:path | |
def static | |
@prefix = Dir.getwd + "/app/views/articles/" | |
@path = params[:path] | |
@render_me = nil | |
logger.debug "Received path variable \"" + @path + "\"" | |
logger.debug "Current path = " + @prefix | |
unless @path.nil? | |
# check if path to directory | |
if @render_me == nil | |
logger.debug "Checking for directory..." | |
if File.exists?(@prefix + @path + "/index.html.haml") | |
logger.debug "Found directory at #{@prefix + @path}/" | |
@render_me = @prefix + @path + "/index.html.haml" | |
else | |
logger.debug "Did not find directory at #{@prefix + @path}/" | |
end # if | |
end # if | |
# check if path to file | |
if @render_me == nil | |
logger.debug "Checking for file..." | |
if @render_me == nil && File.exists?(@prefix + @path + ".html.haml") | |
logger.debug "Found file at #{@prefix + @path}.html.haml" | |
@render_me = @prefix + @path + ".html.haml" | |
else | |
logger.debug "Did not find file at #{@prefix + @path}.html.haml" | |
end # if | |
end # if | |
end # unless | |
if @render_me.nil? | |
redirect_to(articles_url) | |
else | |
render @render_me | |
end # if-else | |
end # method static | |
# GET /articles | |
def index | |
end # method index | |
end # class ArticlesController |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment