garaj 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +0 -1
- data/garaj.gemspec +1 -0
- data/lib/garaj/project.rb +4 -13
- data/lib/garaj/version.rb +1 -1
- data/lib/garaj/web/public/css/styles.css +15 -6
- data/lib/garaj/web/public/css/syntax.css +61 -0
- data/lib/garaj/web/views/dir.erb +4 -4
- data/lib/garaj/web/views/file.erb +2 -1
- data/lib/garaj/web/views/layout.erb +3 -1
- data/lib/garaj/web.rb +25 -4
- metadata +19 -2
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/garaj.gemspec
CHANGED
data/lib/garaj/project.rb
CHANGED
@@ -20,15 +20,6 @@ module Garaj
|
|
20
20
|
"#{@root_path}/#{relative_path.chomp('/')}"
|
21
21
|
end
|
22
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
23
|
# Checks if the given file is ignored
|
33
24
|
def not_ignored?(entry)
|
34
25
|
true unless IGNORED_ENTRIES.include?(entry)
|
@@ -53,8 +44,8 @@ module Garaj
|
|
53
44
|
def files_at(relative_path)
|
54
45
|
files = []
|
55
46
|
Dir.foreach(full_path_to(relative_path)) do |entry|
|
56
|
-
if !
|
57
|
-
files <<
|
47
|
+
if !path_is_dir?("#{relative_path)}/#{entry}") and not_ignored?(entry)
|
48
|
+
files << entry
|
58
49
|
end
|
59
50
|
end
|
60
51
|
files
|
@@ -64,8 +55,8 @@ module Garaj
|
|
64
55
|
def dirs_at(relative_path)
|
65
56
|
dirs = []
|
66
57
|
Dir.foreach(full_path_to(relative_path)) do |entry|
|
67
|
-
if
|
68
|
-
dirs <<
|
58
|
+
if path_is_dir?("#{relative_path)}/#{entry}") and not_ignored?(entry)
|
59
|
+
dirs << entry
|
69
60
|
end
|
70
61
|
end
|
71
62
|
dirs
|
data/lib/garaj/version.rb
CHANGED
@@ -3,7 +3,7 @@ html {
|
|
3
3
|
font-size: 14px;
|
4
4
|
}
|
5
5
|
|
6
|
-
p, ul, pre {
|
6
|
+
p, ul, pre, table, tbody, tr, td {
|
7
7
|
margin: 0;
|
8
8
|
padding: 0;
|
9
9
|
}
|
@@ -70,12 +70,21 @@ a {
|
|
70
70
|
color: #555;
|
71
71
|
}
|
72
72
|
|
73
|
-
.
|
74
|
-
|
75
|
-
|
73
|
+
.highlighttable {
|
74
|
+
font-size: 13px;
|
75
|
+
border-spacing: 0;
|
76
|
+
}
|
77
|
+
|
78
|
+
.code {
|
79
|
+
padding: 8px;
|
76
80
|
background-color: #fff;
|
77
|
-
|
78
|
-
|
81
|
+
width: 100%;
|
82
|
+
}
|
83
|
+
|
84
|
+
.linenodiv {
|
85
|
+
padding: 10px 6px;
|
86
|
+
color: #AAA;
|
87
|
+
border-right: 1px solid #bbb;
|
79
88
|
}
|
80
89
|
|
81
90
|
/** Footer**/
|
@@ -0,0 +1,61 @@
|
|
1
|
+
.hll { background-color: #ffffcc }
|
2
|
+
.c { color: #999988; font-style: italic } /* Comment */
|
3
|
+
.err { color: #a61717; background-color: #e3d2d2 } /* Error */
|
4
|
+
.k { color: #000000; font-weight: bold } /* Keyword */
|
5
|
+
.o { color: #000000; font-weight: bold } /* Operator */
|
6
|
+
.cm { color: #999988; font-style: italic } /* Comment.Multiline */
|
7
|
+
.cp { color: #999999; font-weight: bold; font-style: italic } /* Comment.Preproc */
|
8
|
+
.c1 { color: #999988; font-style: italic } /* Comment.Single */
|
9
|
+
.cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
|
10
|
+
.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
|
11
|
+
.ge { color: #000000; font-style: italic } /* Generic.Emph */
|
12
|
+
.gr { color: #aa0000 } /* Generic.Error */
|
13
|
+
.gh { color: #999999 } /* Generic.Heading */
|
14
|
+
.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
|
15
|
+
.go { color: #888888 } /* Generic.Output */
|
16
|
+
.gp { color: #555555 } /* Generic.Prompt */
|
17
|
+
.gs { font-weight: bold } /* Generic.Strong */
|
18
|
+
.gu { color: #aaaaaa } /* Generic.Subheading */
|
19
|
+
.gt { color: #aa0000 } /* Generic.Traceback */
|
20
|
+
.kc { color: #000000; font-weight: bold } /* Keyword.Constant */
|
21
|
+
.kd { color: #000000; font-weight: bold } /* Keyword.Declaration */
|
22
|
+
.kn { color: #000000; font-weight: bold } /* Keyword.Namespace */
|
23
|
+
.kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */
|
24
|
+
.kr { color: #000000; font-weight: bold } /* Keyword.Reserved */
|
25
|
+
.kt { color: #445588; font-weight: bold } /* Keyword.Type */
|
26
|
+
.m { color: #009999 } /* Literal.Number */
|
27
|
+
.s { color: #d01040 } /* Literal.String */
|
28
|
+
.na { color: #008080 } /* Name.Attribute */
|
29
|
+
.nb { color: #0086B3 } /* Name.Builtin */
|
30
|
+
.nc { color: #445588; font-weight: bold } /* Name.Class */
|
31
|
+
.no { color: #008080 } /* Name.Constant */
|
32
|
+
.nd { color: #3c5d5d; font-weight: bold } /* Name.Decorator */
|
33
|
+
.ni { color: #800080 } /* Name.Entity */
|
34
|
+
.ne { color: #990000; font-weight: bold } /* Name.Exception */
|
35
|
+
.nf { color: #990000; font-weight: bold } /* Name.Function */
|
36
|
+
.nl { color: #990000; font-weight: bold } /* Name.Label */
|
37
|
+
.nn { color: #555555 } /* Name.Namespace */
|
38
|
+
.nt { color: #000080 } /* Name.Tag */
|
39
|
+
.nv { color: #008080 } /* Name.Variable */
|
40
|
+
.ow { color: #000000; font-weight: bold } /* Operator.Word */
|
41
|
+
.w { color: #bbbbbb } /* Text.Whitespace */
|
42
|
+
.mf { color: #009999 } /* Literal.Number.Float */
|
43
|
+
.mh { color: #009999 } /* Literal.Number.Hex */
|
44
|
+
.mi { color: #009999 } /* Literal.Number.Integer */
|
45
|
+
.mo { color: #009999 } /* Literal.Number.Oct */
|
46
|
+
.sb { color: #d01040 } /* Literal.String.Backtick */
|
47
|
+
.sc { color: #d01040 } /* Literal.String.Char */
|
48
|
+
.sd { color: #d01040 } /* Literal.String.Doc */
|
49
|
+
.s2 { color: #d01040 } /* Literal.String.Double */
|
50
|
+
.se { color: #d01040 } /* Literal.String.Escape */
|
51
|
+
.sh { color: #d01040 } /* Literal.String.Heredoc */
|
52
|
+
.si { color: #d01040 } /* Literal.String.Interpol */
|
53
|
+
.sx { color: #d01040 } /* Literal.String.Other */
|
54
|
+
.sr { color: #009926 } /* Literal.String.Regex */
|
55
|
+
.s1 { color: #d01040 } /* Literal.String.Single */
|
56
|
+
.ss { color: #990073 } /* Literal.String.Symbol */
|
57
|
+
.bp { color: #999999 } /* Name.Builtin.Pseudo */
|
58
|
+
.vc { color: #008080 } /* Name.Variable.Class */
|
59
|
+
.vg { color: #008080 } /* Name.Variable.Global */
|
60
|
+
.vi { color: #008080 } /* Name.Variable.Instance */
|
61
|
+
.il { color: #009999 } /* Literal.Number.Integer.Long */
|
data/lib/garaj/web/views/dir.erb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
<% if @dirs.empty? and @files.empty? %>
|
4
4
|
<li class="path">This folder is empty</li>
|
5
5
|
<% else %>
|
6
|
-
<% @dirs.each do |
|
7
|
-
<li class="path dir-path"><a href="<%=
|
6
|
+
<% @dirs.each do |entry| %>
|
7
|
+
<li class="path dir-path"><a href="<%= url_for(entry, @current_path) %>"><%= entry %>/</a></li>
|
8
8
|
<% end %>
|
9
|
-
<% @files.each do |
|
10
|
-
<li class="path file-path"><a href="<%=
|
9
|
+
<% @files.each do |entry| %>
|
10
|
+
<li class="path file-path"><a href="<%= url_for(entry, @current_path) %>"><%= entry %></a></li>
|
11
11
|
<% end %>
|
12
12
|
<% end %>
|
13
13
|
</ul>
|
@@ -2,7 +2,9 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
|
-
<link href="/css/styles.css" media="screen" rel="stylesheet" type="text/css">
|
5
|
+
<link href="/css/styles.css" media="screen" rel="stylesheet" type="text/css">
|
6
|
+
<link href="/css/syntax.css" media="screen" rel="stylesheet" type="text/css">
|
7
|
+
<title><%= @project_name %> - garaj</title>
|
6
8
|
</head>
|
7
9
|
|
8
10
|
<body>
|
data/lib/garaj/web.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
+
require 'pygments'
|
2
3
|
|
3
4
|
module Garaj
|
4
5
|
class Web < Sinatra::Base
|
5
6
|
|
6
|
-
attr_accessor :project
|
7
|
-
|
8
7
|
configure do
|
9
8
|
set :port, '9988'
|
10
9
|
set :logging, false
|
@@ -13,15 +12,37 @@ module Garaj
|
|
13
12
|
set :views, File.expand_path('../web/views', __FILE__)
|
14
13
|
end
|
15
14
|
|
15
|
+
helpers do
|
16
|
+
# Returns the url for the given relative path
|
17
|
+
def url_for(entry, relative_path)
|
18
|
+
if !relative_path.empty?
|
19
|
+
"/#{relative_path}/#{entry}"
|
20
|
+
else
|
21
|
+
"/#{entry}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def syntax_highlight(file_content, file_name)
|
26
|
+
options = { :encoding => 'utf-8', :linenos => 'True' }
|
27
|
+
lexer = file_name.split('.').last
|
28
|
+
|
29
|
+
begin
|
30
|
+
::Pygments.highlight(file_content, :lexer => lexer.downcase, :options => options)
|
31
|
+
rescue
|
32
|
+
::Pygments.highlight(file_content, :options => options)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
16
37
|
def self.start(project_root)
|
17
38
|
set :project, Garaj::Project.new(project_root)
|
18
39
|
run!
|
19
40
|
end
|
20
|
-
|
41
|
+
|
21
42
|
get '/*?' do |relative_path|
|
22
43
|
@project_name = settings.project.name
|
23
44
|
@current_path = relative_path
|
24
|
-
|
45
|
+
|
25
46
|
if settings.project.path_is_dir?(relative_path)
|
26
47
|
@dirs = settings.project.dirs_at(relative_path)
|
27
48
|
@files = settings.project.files_at(relative_path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garaj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: pygments.rb
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0.3'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.3'
|
30
46
|
description: Browse through your project's source code
|
31
47
|
email:
|
32
48
|
- fisyonet@gmail.com
|
@@ -48,6 +64,7 @@ files:
|
|
48
64
|
- lib/garaj/version.rb
|
49
65
|
- lib/garaj/web.rb
|
50
66
|
- lib/garaj/web/public/css/styles.css
|
67
|
+
- lib/garaj/web/public/css/syntax.css
|
51
68
|
- lib/garaj/web/views/dir.erb
|
52
69
|
- lib/garaj/web/views/file.erb
|
53
70
|
- lib/garaj/web/views/layout.erb
|