garaj 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## head
2
+
3
+ ## v0.0.1
4
+
5
+ Initial public release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in garaj.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Oguz Bilgic
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ Garaj
2
+ =====
3
+
4
+ a tiny web app which lets you browse your project`s source code
5
+ locally using a web browser.
6
+
7
+ ![garaj-v0.0.1](http://i.imgur.com/6gVvQ.png)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ group :development
14
+ gem 'garaj'
15
+ end
16
+
17
+ Or install to your system:
18
+
19
+ $ gem install garaj
20
+
21
+ ## Usage
22
+
23
+ Go to your project's folder and start garaj:
24
+
25
+ $ cd my-awesome-app/
26
+ $ garaj
27
+
28
+ Visit your garaj using a web browser at:
29
+
30
+ http://127.0.0.1:9988
31
+
32
+ ## Roadmap
33
+
34
+ * Syntax highlighting
35
+ * File, page icons
36
+ * Readme.md support
37
+ * Markdown support
38
+ * Support non-text file types
39
+ * Running as deamon (garaj -d)
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/garaj ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'garaj'
4
+
5
+ Garaj::Web.start(ENV['PWD'])
data/garaj.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'garaj/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "garaj"
8
+ gem.version = Garaj::VERSION
9
+ gem.authors = ["Oguz Bilgic"]
10
+ gem.email = ["fisyonet@gmail.com"]
11
+ gem.description = %q{Browse through your project's source code}
12
+ gem.summary = %q{Garaj is a tiny web app which lets you to browse your project`s source code locally using a web browser.}
13
+ gem.homepage = "https://github.com/oguzbilgic/garaj"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency('sinatra', '~> 1.3')
21
+ end
data/lib/garaj.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "garaj/version"
2
+ require "garaj/project"
3
+ require "garaj/web"
4
+
5
+ module Garaj
6
+
7
+ end
@@ -0,0 +1,74 @@
1
+ module Garaj
2
+ class Project
3
+
4
+ IGNORED_ENTRIES = %w{. .. .DS_Store .git}
5
+
6
+ attr_accessor :root_path
7
+
8
+ # Initializes a new Garaj::Project object
9
+ def initialize(root_path)
10
+ @root_path = root_path.chomp('/')
11
+ end
12
+
13
+ # Returns name of the project
14
+ def name
15
+ @root_path.split('/').last
16
+ end
17
+
18
+ # Returns full path of the given relative path
19
+ def full_path_to(relative_path)
20
+ "#{@root_path}/#{relative_path.chomp('/')}"
21
+ end
22
+
23
+ # Returns the url for the given relative path
24
+ def url_for(entry, relative_path)
25
+ if !relative_path.empty?
26
+ "/#{relative_path}/#{entry}"
27
+ else
28
+ "/#{entry}"
29
+ end
30
+ end
31
+
32
+ # Checks if the given file is ignored
33
+ def not_ignored?(entry)
34
+ true unless IGNORED_ENTRIES.include?(entry)
35
+ end
36
+
37
+ # Checks if the given path is a directory
38
+ def path_is_dir?(relative_path)
39
+ true if File.directory?(full_path_to(relative_path))
40
+ end
41
+
42
+ # Returns the name of the file
43
+ def file_name_at(relative_path)
44
+ relative_path.split('/').last
45
+ end
46
+
47
+ # Returns the contents of the file at the given path
48
+ def file_content_at(relative_path)
49
+ File.read(full_path_to(relative_path))
50
+ end
51
+
52
+ # Returns a list of the files at the given path
53
+ def files_at(relative_path)
54
+ files = []
55
+ Dir.foreach(full_path_to(relative_path)) do |entry|
56
+ if !File.directory?("#{full_path_to(relative_path)}/#{entry}") and not_ignored?(entry)
57
+ files << {:url => url_for(entry, relative_path), :name => entry}
58
+ end
59
+ end
60
+ files
61
+ end
62
+
63
+ # Returns a list of the dirs at the given path
64
+ def dirs_at(relative_path)
65
+ dirs = []
66
+ Dir.foreach(full_path_to(relative_path)) do |entry|
67
+ if File.directory?("#{full_path_to(relative_path)}/#{entry}") and not_ignored?(entry)
68
+ dirs << {:url => url_for(entry, relative_path), :name => entry}
69
+ end
70
+ end
71
+ dirs
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module Garaj
2
+ VERSION = "0.0.1"
3
+ end
data/lib/garaj/web.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'sinatra/base'
2
+
3
+ module Garaj
4
+ class Web < Sinatra::Base
5
+
6
+ attr_accessor :project
7
+
8
+ configure do
9
+ set :port, '9988'
10
+ set :logging, false
11
+ set :dump_errors, false
12
+ set :public_folder, File.expand_path('../web/public', __FILE__)
13
+ set :views, File.expand_path('../web/views', __FILE__)
14
+ end
15
+
16
+ def self.start(project_root)
17
+ set :project, Garaj::Project.new(project_root)
18
+ run!
19
+ end
20
+
21
+ get '/*?' do |relative_path|
22
+ @project_name = settings.project.name
23
+ @current_path = relative_path
24
+
25
+ if settings.project.path_is_dir?(relative_path)
26
+ @dirs = settings.project.dirs_at(relative_path)
27
+ @files = settings.project.files_at(relative_path)
28
+ erb :dir
29
+ else
30
+ @file_name = settings.project.file_name_at(relative_path)
31
+ @file_content = settings.project.file_content_at(relative_path)
32
+ erb :file
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,87 @@
1
+ html {
2
+ font-family: helvetica;
3
+ font-size: 14px;
4
+ }
5
+
6
+ p, ul, pre {
7
+ margin: 0;
8
+ padding: 0;
9
+ }
10
+
11
+ a {
12
+ color: #4183C4;
13
+ }
14
+
15
+ /** Layout **/
16
+
17
+ .container {
18
+ width: 760px;
19
+ margin: auto;
20
+ }
21
+
22
+ .box {
23
+ padding: 4px;
24
+ background-color: #eee;
25
+ border-radius: 3px;
26
+ margin-bottom: 10px;
27
+ }
28
+
29
+ /** Breadcrumb **/
30
+
31
+ .breadcrumb{
32
+ padding: 12px;
33
+ font-size: 18px;
34
+ }
35
+
36
+ /** Dir **/
37
+
38
+ .paths {
39
+ border: 1px solid #bbb;
40
+ }
41
+
42
+ .path {
43
+ display: block;
44
+ background-color: #f8f8f8;
45
+ padding: 8px 0 8px 12px;
46
+ border-bottom: 1px solid #ddd;
47
+ }
48
+
49
+ .dir-path {
50
+ font-weight: bold;
51
+ }
52
+
53
+ .path a {
54
+ text-decoration: none;
55
+ }
56
+
57
+ /** File **/
58
+
59
+ .file{
60
+ background-color: #f8f8f8;
61
+ border: 1px solid #bbb;
62
+ }
63
+
64
+ .file-name {
65
+ padding: 14px 12px 12px 15px;
66
+ display: block;
67
+ border-bottom: 1px solid #bbb;
68
+ font-weight: bold;
69
+ font-size: 16px;
70
+ color: #555;
71
+ }
72
+
73
+ .file-content {
74
+ padding: 12px;
75
+ display: block;
76
+ background-color: #fff;
77
+ overflow: auto;
78
+ overflow-y: hidden;
79
+ }
80
+
81
+ /** Footer**/
82
+
83
+ .footer {
84
+ font-size: 12px;
85
+ color: #aaa;
86
+ text-align: center;
87
+ }
@@ -0,0 +1,14 @@
1
+ <div class="box">
2
+ <ul class="paths">
3
+ <% if @dirs.empty? and @files.empty? %>
4
+ <li class="path">This folder is empty</li>
5
+ <% else %>
6
+ <% @dirs.each do |path| %>
7
+ <li class="path dir-path"><a href="<%= path[:url] %>"><%= path[:name] %>/</a></li>
8
+ <% end %>
9
+ <% @files.each do |path| %>
10
+ <li class="path file-path"><a href="<%= path[:url] %>"><%= path[:name] %></a></li>
11
+ <% end %>
12
+ <% end %>
13
+ </ul>
14
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="box">
2
+ <div class="file">
3
+ <span class="file-name"><%= @file_name %></span>
4
+ <pre class="file-content"><%= @file_content %></pre>
5
+ </div>
6
+ </div>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link href="/css/styles.css" media="screen" rel="stylesheet" type="text/css"> <title><%= @project_name %> - garaj</title>
6
+ </head>
7
+
8
+ <body>
9
+ <div class="container">
10
+ <p class="breadcrumb"><a href="/"><%= @project_name %></a> / <%= @current_path.gsub('/', ' / ') %></p>
11
+ <%= yield %>
12
+ <p class="footer">garaj v<%= Garaj::VERSION %></p>
13
+ </div>
14
+ </body>
15
+ </html>
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: garaj
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Oguz Bilgic
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ description: Browse through your project's source code
31
+ email:
32
+ - fisyonet@gmail.com
33
+ executables:
34
+ - garaj
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - CHANGELOG.md
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - bin/garaj
45
+ - garaj.gemspec
46
+ - lib/garaj.rb
47
+ - lib/garaj/project.rb
48
+ - lib/garaj/version.rb
49
+ - lib/garaj/web.rb
50
+ - lib/garaj/web/public/css/styles.css
51
+ - lib/garaj/web/views/dir.erb
52
+ - lib/garaj/web/views/file.erb
53
+ - lib/garaj/web/views/layout.erb
54
+ homepage: https://github.com/oguzbilgic/garaj
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.24
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Garaj is a tiny web app which lets you to browse your project`s source code
78
+ locally using a web browser.
79
+ test_files: []