Created
April 13, 2009 17:06
-
-
Save cypher/94545 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'sinatra' | |
get "/" do | |
dir = "./public/files/" | |
@links = Dir[dir+"*"].map { |file| | |
file_link(file) | |
}.join | |
erb :index | |
end | |
helpers do | |
def file_link(file) | |
filename = File.basename(file) | |
"<li><a href='#{file[9..-1]}' target='_self'>#{filename}</a></li>" | |
end | |
end | |
use_in_file_templates! | |
__END__ | |
@@ index | |
<html> | |
<head> | |
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/> | |
<style type="text/css" media="screen">@import "/stylesheets/iui.css";</style> | |
<script type="application/x-javascript" src="/javascripts/iui.js"></script> | |
</head> | |
<body> | |
<div class="toolbar"> | |
<h1 id="pageTitle"></h1> | |
</div> | |
<ul id="home" title="Your files, sir." selected="true"> | |
<%= @links %> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment