Browse Source

Adding Gemfile, commit recent changes (great chances to be broken!)

Tone 10 years ago
parent
commit
6e767ab471

+ 11 - 0
Gemfile

@@ -0,0 +1,11 @@
+# A sample Gemfile
+source "https://rubygems.org"
+
+gem 'sinatra'
+gem 'sinatra-contrib'
+gem 'sinatra-xsendfile'
+gem 'thin'
+gem 'nokogiri'
+gem 'haml'
+gem 'rest-client'
+gem 'sys-filesystem'

+ 56 - 0
Gemfile.lock

@@ -0,0 +1,56 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    backports (3.6.4)
+    daemons (1.1.9)
+    eventmachine (1.0.3)
+    ffi (1.9.8)
+    haml (4.0.6)
+      tilt
+    mime-types (2.3)
+    mini_portile (0.6.2)
+    multi_json (1.11.0)
+    netrc (0.7.9)
+    nokogiri (1.6.6.2)
+      mini_portile (~> 0.6.0)
+    rack (1.6.1)
+    rack-protection (1.5.3)
+      rack
+    rack-test (0.6.3)
+      rack (>= 1.0)
+    rest-client (1.7.2)
+      mime-types (>= 1.16, < 3.0)
+      netrc (~> 0.7)
+    sinatra (1.4.6)
+      rack (~> 1.4)
+      rack-protection (~> 1.4)
+      tilt (>= 1.3, < 3)
+    sinatra-contrib (1.4.2)
+      backports (>= 2.0)
+      multi_json
+      rack-protection
+      rack-test
+      sinatra (~> 1.4.0)
+      tilt (~> 1.3)
+    sinatra-xsendfile (0.4.2)
+      sinatra (>= 0.9.1)
+    sys-filesystem (1.1.4)
+      ffi
+    thin (1.6.2)
+      daemons (>= 1.0.9)
+      eventmachine (>= 1.0.0)
+      rack (>= 1.0.0)
+    tilt (1.4.1)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  haml
+  nokogiri
+  rest-client
+  sinatra
+  sinatra-contrib
+  sinatra-xsendfile
+  sys-filesystem
+  thin

+ 5 - 0
config.ru

@@ -1,3 +1,8 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.require
+
 require "./lib/rSeed"
 
 app = RSeed::Server.new do

+ 1 - 0
lib/rSeed.rb

@@ -11,6 +11,7 @@ require "fileutils"
 require "net/http"
 require "sinatra"
 require "sinatra/xsendfile"
+require "sinatra/reloader" if development?
 require "xmlrpc/client"
 require "sys/filesystem"
 require "yaml"

+ 3 - 1
lib/rSeed/rtorrent.rb

@@ -4,7 +4,8 @@ module RSeed
   class Rtorrent
 
     def initialize(host, path, port)
-      @client = XMLRPC::Client.new(host, path, port)
+      @client = XMLRPC::Client.new(host, path, port, nil, nil, nil, nil, true, nil)
+      @client.instance_variable_get(:@http).instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE)
       puts "#{host}, #{path}, #{port}"
     end
 
@@ -18,6 +19,7 @@ module RSeed
       end
       columns = ["name", "completed_bytes", "size_bytes", "ratio", "up", "down", "hash"]
       formated_response = response.map { |row| Hash[*columns.zip(row).flatten] }
+      formated_response.sort_by! { |hsh| hsh["name"] } 
       return formated_response
     end
 

+ 1 - 1
lib/rSeed/server.rb

@@ -111,7 +111,7 @@ module RSeed
     get %r{/d/([a-zA-Z0-9]+)} do |hash|
       if publicLink(hash)
         haml :download, :locals => { 
-          :torrentFileTree => @utils.renderTree(@utils.treePath(@rtorrent.getTorrentPath(hash))),
+          :torrentFileTree => @utils.renderTree(@utils.treePath(@rtorrent.getTorrentPath(hash)), hash),
           :tname => @rtorrent.getName(hash),
           :thash => hash
         }  

+ 4 - 4
lib/rSeed/utils.rb

@@ -7,7 +7,7 @@ module RSeed
     def treePath path
       tree = {}
       if File.directory? path
-        Dir.foreach(path) do |file|
+        Dir.entries(path).sort!.each do |file|
           if file != "." and file != ".."
             if File.directory?(File.join(path, file))
               tree[file] = treePath(File.join(path, file))
@@ -22,14 +22,14 @@ module RSeed
       tree
     end
 
-    def renderTree tree
+    def renderTree tree, hash
       s = "<ul>"
       tree.each do |node|
         if node == :file or node[1] == :file
-          s += "<li>#{node[0]}</li>"
+          s += "<li><a href='/d/#{hash}/#{node[0]}'>#{node[0]}</a></li>"
         else
           s += "<li>#{node[0]}/"
-          s += renderTree(node[1])
+          s += renderTree(node[1], hash)
           s += "</li>"
         end
       end

+ 30 - 0
public/css/folding.css

@@ -0,0 +1,30 @@
+.folding ul {
+    list-style: none;
+    margin: 0;
+    padding: 0;
+}
+
+.folding li {
+    background-image: url('/img/page.png');
+    background-position: 0 5px;
+    background-repeat: no-repeat;
+    padding-left: 20px;
+}
+
+.folding li.folder {
+    background-image: url('/img/folder-closed.png');
+}
+
+.folding li.folder-open {
+    background-image: url('/img/folder-open.png');
+}
+
+.folding a {
+    color: #000000;
+    cursor: pointer;
+    text-decoration: none;
+}
+
+.folding a:hover {
+    text-decoration: underline;
+}

BIN
public/img/folder-closed.png


BIN
public/img/folder-open.png


BIN
public/img/page.png


+ 3 - 1
public/js/custom.js

@@ -61,7 +61,9 @@ $(document).ready(function() {
   refreshUpDownTotal();
   diskInfo();
 
+  
 });
+   
 
 function refreshUpDownTotal() {
   $.getJSON( "api/get_updown_total", function( data ) {
@@ -126,7 +128,7 @@ var box = document.getElementById('dropbox')
   
 var dropbox = new Dropbox(box, '/add/file')
 // Optional settings and callbacks
-dropbox.max_size = 2 // MB
+dropbox.max_size = 4 // MB
 dropbox.max_concurrent = 1 // Do not upload more than two files at a time
 dropbox.mime_types = /(torrent)/i // Only allow pngs, jpgs, and gifs
 dropbox.success = function(file, response) {

+ 27 - 0
public/js/folding.js

@@ -0,0 +1,27 @@
+$(function() {
+    // Find list items representing folders and
+    // style them accordingly.  Also, turn them
+    // into links that can expand/collapse the
+    // tree leaf.
+    $('li > ul').each(function(i) {
+        // Find this list's parent list item.
+        var parent_li = $(this).parent('li');
+
+        // Style the list item as folder.
+        parent_li.addClass('folder');
+
+        // Temporarily remove the list from the
+        // parent list item, wrap the remaining
+        // text in an anchor, then reattach it.
+        var sub_ul = $(this).remove();
+        parent_li.wrapInner('<a/>').find('a').click(function() {
+            // Make the anchor toggle the leaf display.
+            sub_ul.toggle();
+            parent_li.toggleClass('folder-open', 'folder')
+        });
+        parent_li.append(sub_ul);
+    });
+
+    // Hide all lists except the outermost.
+    $('ul ul').hide();
+});

+ 2 - 1
views/download.haml

@@ -12,7 +12,7 @@
               %span Menu
     %section.main-section{style: "margin-top : 50px;"}
       .row
-        .large-12.columns
+        .large-12.columns.folding
           %h3{data: {torrent_id: thash}} #{tname}
           #{torrentFileTree}
     %a.exit-off-canvas
@@ -20,5 +20,6 @@
 %script{:src => '/js/vendor/jquery.js'}
 %script{:src => '/js/foundation.min.js'}
 %script{:src => '/js/notify-combined.min.js'}
+%script{:src => '/js/folding.js'}
 %script
   $(document).foundation();

+ 1 - 0
views/layout.haml

@@ -7,6 +7,7 @@
     %link{:rel => :stylesheet, :href => "/css/alertify.core.css", :type => "text/css"}
     %link{:rel => :stylesheet, :href => "/css/alertify.foundation.css", :type => "text/css"}
     %link{:rel => :stylesheet, :href => "/css/dropbox.css", :type => "text/css"}
+    %link{:rel => :stylesheet, :href => "/css/folding.css", :type => "text/css"}
     %script{:type => 'text/javascript', :src => '/js/modernizr.js'}
     %body
       %section{:role => 'main'}