Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 361c4f871e
Fetching contributors…

Cannot retrieve contributors at this time

113 lines (93 sloc) 2.73 kb
require 'haml'
require 'sass'
require 'sinatra/base'
require "sinatra/reloader"
require 'json'
path = File.expand_path "../", __FILE__
APP_PATH = path
class Makevoid < Sinatra::Base
require "#{APP_PATH}/config/env"
configure :development do
# register Sinatra::Reloader
# also_reload ["controllers/*.rb", "models/*.rb", "public/projects/*.haml"]
set :public_folder, "public"
set :static, true
end
set :logging, true
set :haml, { :format => :html5 }
# require 'rack-flash'
enable :sessions
# use Rack::Flash
require 'sinatra/content_for'
helpers Sinatra::ContentFor
set :method_override, true
def not_found(object=nil)
halt 404, "404 - Page Not Found"
end
helpers do
def js_void
"javascript:void(0)"
end
end
def order_datas(datas, page)
values = datas.map{ |d| d[:template] }
idx = values.index(page)
not_found unless idx
# datas.sort{ |a, b| (datas.index(a) > idx) ? -1 : 1 }
data = datas[idx]
datas.delete_at idx
# datas.unshift data
datas.insert 2, data
datas
end
#MKVD_FORMAT = "svg"
MKVD_FORMAT = "png"
def get_datas(page=nil)
datas = [
{ name: "Accademia Cappiello", template: "cappiello" },
{ name: "RiotVan", template: "riotvan" },
{ name: "makevoid", template: "makevoid" },
{ name: "Elisabetta Porcinai", template: "eli" },
{ name: "Pietro Porcinai", template: "pp" },
#{ name: "my open source projects on github", template: "github_projects" },
{ name: "jScrape", template: "jscrape" },
{ name: "Thorrents", template: "thorrents" },
{ name: "MangaPad", template: "mangapad" },
{ name: "SkiCams", template: "skicams" },
#{ name: "StyleQuiz", template: "stylequiz" },
]
datas.each do |data|
frmt = data[:template] == "makevoid" ? MKVD_FORMAT : "png"
data[:image] = "/imgs/projects/#{data[:template]}.#{frmt}"
end
datas = order_datas(datas, page) if page
@gallery_datas = datas
@gallery_json = datas.to_json
end
get "/" do
get_datas
@entry = @gallery_datas[2]
haml :index
end
get "/updates" do
redirect "http://updates.makevoid.com"
end
get "/blog" do
redirect "http://updates.makevoid.com/blog"
end
get "/login" do
redirect "http://updates.makevoid.com/login"
end
get "/posts/*" do |splat|
splat = splat.gsub(/ /, '+')
redirect "http://updates.makevoid.com/posts/#{splat}"
end
get '/css/main.css' do
sass :main
end
get "/*" do |page|
get_datas(page)
@entry = @gallery_datas.find{ |e| e[:template] == page }
haml :index
end
end
Jump to Line
Something went wrong with that request. Please try again.