daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest May 16th, 2018 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # first, run 'ls -R > filemap.txt', then run this script on that file.
  2.  
  3. # css div classes:
  4. #  folder
  5. #  title
  6. #  file
  7.  
  8. require 'pp'
  9.  
  10. doc =  <<EOF
  11. <html>
  12. <head>
  13.   <style type='text/css'>
  14.     <!--
  15.     .folder {
  16.       background-color: #99CCCC;
  17.       border: 1px solid #333333;
  18.       display: block;
  19.       margin-top: 3px;
  20.       margin-right: 3px;
  21.       margin-left: 6px;
  22.       margin-bottom: 6px;
  23.      }
  24.     .title {
  25.       background-color: #D5EAEA;
  26.       width: 99%;
  27.       padding-left: 1%;
  28.       border-bottom-width: 1px;
  29.       border-bottom-style: dotted;
  30.       border-bottom-color: #333333;
  31.      }
  32.     .file {
  33.       padding-right: 12px;
  34.       padding-left: 12px;
  35.     } //-->
  36.   </style>
  37. </head>
  38. <body>
  39.  
  40.  
  41. EOF
  42.  
  43.  
  44. example = <<EOF
  45. Migratus
  46. filemap.txt
  47. images
  48. index.html
  49. index.php
  50. linkcheck
  51. modules
  52. phpMyAdmin
  53. sandbox
  54. site_administration.rb
  55. sitemap
  56.  
  57. ./Migratus:
  58. Migratus 2.zip
  59. Rakefile
  60. app
  61. backup-sunday
  62. config
  63. db
  64. doc
  65. lib
  66. log
  67. migratus.rb
  68. public
  69. script
  70. test
  71. tmp
  72. vendor
  73.  
  74. ./Migratus/app:
  75. controllers
  76. helpers
  77. models
  78. views
  79.  
  80. ./Migratus/app/controllers:
  81. application.rb
  82. projects_controller.rb
  83. tasks_controller.rb
  84.  
  85. ./Migratus/app/helpers:
  86. application_helper.rb
  87. application_helper.rb.bak
  88. projects_helper.rb
  89.  
  90. ./Migratus/app/models:
  91. project.rb
  92. task.rb
  93.  
  94. ./Migratus/app/views:
  95. layouts
  96. projects
  97. tasks
  98.  
  99. ./Migratus/app/views/layouts:
  100. application.html.erb
  101.  
  102. ./Migratus/app/views/projects:
  103. edit.html.erb
  104. index.html.erb
  105. new.html.erb
  106. show.html.erb
  107.  
  108. ./Migratus/app/views/tasks:
  109. edit.html.erb
  110. index.html.erb
  111. new.html.erb
  112. show.html.erb
  113.  
  114. ./Migratus/backup-sunday:
  115. Migratus.tmproj
  116.  
  117. ./Migratus/config:
  118. boot.rb
  119. database.yml
  120. environment.rb
  121. environments
  122. initializers
  123. routes.rb
  124.  
  125. ./Migratus/config/environments:
  126. development.rb
  127. production.rb
  128. test.rb
  129.  
  130. ./Migratus/config/initializers:
  131. inflections.rb
  132. mime_types.rb
  133.  
  134. ./Migratus/db:
  135. development.sqlite3
  136. migrate
  137. schema.rb
  138.  
  139. ./Migratus/db/migrate:
  140. 001_create_tasks.rb
  141. 002_fix_tasks.rb
  142. 003_add_finished.rb
  143. 004_add_finished_to_tasks.rb
  144. 005_create_projects.rb
  145. 006_create_table_projects_tasks.rb
  146.  
  147. ./Migratus/doc:
  148. README_FOR_APP
  149.  
  150. ./Migratus/lib:
  151. tasks
  152.  
  153. ./Migratus/lib/tasks:
  154. file_map.rake
  155. migratus.rake
  156. probe.rake
  157.  
  158. ./Migratus/log:
  159. development.log
  160. mongrel.log
  161. production.log
  162. server.log
  163. test.log
  164.  
  165. ./Migratus/public:
  166. 404.html
  167. 422.html
  168. 500.html
  169. dispatch.cgi
  170. dispatch.fcgi
  171. dispatch.rb
  172. favicon.ico
  173. images
  174. javascripts
  175. stylesheets
  176.  
  177. ./Migratus/public/images:
  178. bar_yellow.gif
  179. dot_pattern.png
  180. rails.png
  181.  
  182. ./Migratus/public/javascripts:
  183. application.js
  184. controls.js
  185. dragdrop.js
  186. effects.js
  187. prototype.js
  188.  
  189. ./Migratus/public/stylesheets:
  190. main.css
  191. scaffold.css
  192.  
  193. ./Migratus/script:
  194. about
  195. console
  196. destroy
  197. generate
  198. performance
  199. plugin
  200. process
  201. runner
  202. server
  203.  
  204. ./Migratus/script/performance:
  205. benchmarker
  206. profiler
  207. request
  208.  
  209. ./Migratus/script/process:
  210. inspector
  211. reaper
  212. spawner
  213.  
  214. ./Migratus/test:
  215. fixtures
  216. functional
  217. unit
  218.  
  219. ./Migratus/test/fixtures:
  220. projects.yml
  221.  
  222. ./Migratus/test/functional:
  223. projects_controller_test.rb
  224.  
  225. ./Migratus/test/unit:
  226. project_test.rb
  227.  
  228. ./Migratus/tmp:
  229. cache
  230. pids
  231. sessions
  232. sockets
  233.  
  234. ./Migratus/tmp/cache:
  235.  
  236. ./Migratus/tmp/pids:
  237.  
  238. ./Migratus/tmp/sessions:
  239.  
  240. ./Migratus/tmp/sockets:
  241.  
  242. ./Migratus/vendor:
  243. plugins
  244.  
  245. ./Migratus/vendor/plugins:
  246.  
  247. ./images:
  248. apache_pb.gif
  249. gradient.jpg
  250. macosxlogo.png
  251. web_share.gif
  252.  
  253. EOF
  254.  
  255. def transform_nested data
  256.  
  257.   result = {:name => "root", :elements => []}
  258.  
  259.   data.each do |item|
  260.  
  261.     index = result
  262.  
  263.     item.each do |sub|
  264.       sub.gsub! /:$/, ''
  265.       new_index = index[:elements].find {|e| e[:name] == sub}
  266.  
  267.       unless new_index
  268.         new_index = {:name => sub, :elements => []}
  269.         index[:elements] << new_index
  270.       end
  271.  
  272.       index = new_index
  273.  
  274.     end
  275.  
  276.   end
  277.  
  278.   result
  279.  
  280. end
  281.  
  282.  
  283.  
  284. data = Array.new
  285.  
  286. final_document = File.open('/Users/John/Sites/newmap.html', 'w') do |f|
  287.   f << doc
  288.   f << "Version 25: <br />"
  289.   f << "<div class='folder'>\n\t"
  290.  
  291.  
  292.   # File.open('/Users/John/Sites/filemap.txt').each do |x|
  293.  
  294.   example.each do |x|
  295.    
  296.    
  297.     if x =~ /.*:$/
  298.       x.gsub!('.', '')
  299.       data << x.chomp!.split('/')
  300.     end
  301.    
  302.     @map = transform_nested(data)
  303.  
  304.    
  305.     case x
  306.     when /.*:$/ # trailing ':'
  307.       f << "\n<div class='folder'><div class='title'>\n\t"
  308.       f << x
  309.       f << "\n\t</div>"
  310.     when /^\n/ # leading '\n'
  311.       f << "</div>"
  312.     else
  313.       f << "\n<span class='file'>\n\t"
  314.       f << x
  315.       f << "\n\t</span>"
  316.     end
  317.   end
  318.  
  319.   @map.each do |k, v|
  320.     f << "#{k} is: #{v}<br />"
  321.   end
  322.  
  323.   f << "</div>"
  324.   f << "\n</body></html>"
  325.  
  326.  
  327. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top