Created
November 8, 2011 02:04
-
-
Save xaviervia/1346804 to your computer and use it in GitHub Desktop.
"Explorer"...
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
!!! 5 | |
%html | |
%body | |
- @files.each do |file| | |
%article | |
%h1 | |
%a(href="/#{file.identifier}")= file.title | |
- begin | |
%blockquote= file.description | |
- rescue | |
%blockquote No se pudo cargar por error en el encoding |
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
require "maruku" | |
class DCResource | |
attr_accessor :identifier, :title, :description | |
def initialize path | |
if File.exist? path | |
@identifier = path.force_encoding("UTF-8") | |
@title = path.force_encoding("UTF-8") | |
@description = File.read( path ).lines.to_a[0..4].join("\n").force_encoding("UTF-8") | |
end | |
end | |
def self.descartados | |
[/\./, /\.\./, /\.ini$/, /\.haml$/] | |
end | |
end | |
get "/" do | |
@files = [] | |
Dir.new(Dir.pwd).each do |file| | |
encaja_en_descartado = false | |
DCResource.descartados.each do |descartado| | |
if file.match descartado | |
encaja_descartado = true | |
break | |
end | |
end | |
unless encaja_en_descartado | |
@files << DCResource.new( file ) | |
end | |
end | |
try_haml :files | |
end | |
get %r{^/(.+).md$} do |element| | |
if File.exist? "#{element}.md" | |
Maruku.new(File.read("#{element}.md")).to_html | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment