lib/pow-index.rb in pow-index-0.0.4 vs lib/pow-index.rb in pow-index-0.0.5
- old
+ new
@@ -7,11 +7,11 @@
POW_PATH = "#{ENV['HOME']}/.pow"
enable :inline_templates
get '/' do
- @pows = Dir[POW_PATH + "/*"].map { |link| File.basename(link) }
+ @pows = (Dir[POW_PATH + "/*"] - [ "#{ENV['HOME']}/.pow/#{request.host.gsub(/.dev$/, '')}" ]).map { |link| File.basename(link) }
haml :index
end
get '/cleanup' do
require 'fileutils'
@@ -19,42 +19,48 @@
@pows = Dir[POW_PATH + "/*"].map { |link| File.basename(link) }
haml :linktable
end
get '/linktable' do
- @pows = Dir[POW_PATH + "/*"].map { |link| File.basename(link) }
+ @pows = (Dir[POW_PATH + "/*"] - [ "#{ENV['HOME']}/.pow/#{request.host.gsub(/.dev$/, '')}" ]).map { |link| File.basename(link) }
haml :linktable
end
-
- get '/assets/:filename' do
- File.readlines("#{File.dirname(__FILE__)}/../assets/#{params[:filename]}")
- end
-
end
end
__END__
@@ index
%html
%head
%title pow index
- %link{:rel => 'stylesheet', :href => '/assets/bootstrap-1.2.0.min.css'}
- %script{:type => 'text/javascript', :src => 'assets/jquery.min.js'}
+ %link{:rel => 'stylesheet', :href => 'bootstrap.min.css'}
+ %link{:rel => 'stylesheet', :href => 'bootstrap-responsive.min.css'}
+ %script{:type => 'text/javascript', :src => 'jquery.min.js'}
+ %script{:type => 'text/javascript', :src => 'bootstrap-modal.js'}
= haml :js
- %body
+ %body{:style => 'padding-top:40px'}
+ .navbar.navbar-fixed-top
+ .navbar-inner
+ .container
+ .brand pow index
+ .nav.pull-right
+ %a.btn{:'data-toggle' => "modal", :href => '#toggle'}
+ %i.icon-refresh
.container
- %h1 pow index
- %table.zebra-striped#linktable
- .row
- %button.btn.small#toggle{:onClick => 'toggle()'} Cleanup
- .alert-message.block-message.warning#confirm{'style' => 'display: none'}
- %button.btn.small{:onClick => 'cleanup()'} Cleanup
- %button.btn.small{:onClick => 'toggle()'} Cancel
- %p= "Pushing 'Cleanup' removes invalid symbolic link in ~/.pow"
+ %table.table.table-striped#linktable
+ .modal.hide#toggle
+ .modal-header
+ %h3 Cleanup
+ .modal-body
+ %p= "Remove invalid symbolic links in ~/.pow"
+ .modal-footer
+ %a.btn.btn-primary{:onClick => 'cleanup()'} OK
+ %a.btn{:'data-dismiss' => 'modal'} cancel
+
@@ linktable
%tbody
- @pows.each do |pow|
%tr
%td
@@ -64,26 +70,17 @@
@@ js
:javascript
function loadtable(){
$('#linktable').load('/linktable')
}
- function toggle(){
- $.each(['toggle', 'confirm'], function() {
- if(document.getElementById(this).style.display == 'none'){
- document.getElementById(this).style.display = 'block';
- }else{
- document.getElementById(this).style.display = 'none';
- }
- })
- }
function cleanup() {
$.ajax({
type: "GET",
url: "/cleanup",
dataType: "html",
success: function(){
loadtable();
- toggle();
+ $('#toggle').modal('hide')
}
})
}
$(function(){ loadtable(); })