bulb 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/README.md +21 -2
- data/app/controllers/bulb/blob_controller.rb +3 -1
- data/app/controllers/bulb/tree_controller.rb +3 -1
- data/app/helpers/bulb/application_helper.rb +27 -0
- data/app/models/bulb/group.rb +2 -0
- data/app/models/bulb/repository.rb +9 -4
- data/app/validators/bulb/unexisting_validator.rb +9 -0
- data/app/views/bulb/blob/show.html.erb +16 -3
- data/app/views/bulb/tree/show.html.erb +2 -0
- data/db/migrate/20220116171708_add_unique_index_on_slugs.rb +6 -0
- data/lib/bulb/engine.rb +2 -0
- data/lib/bulb/version.rb +1 -1
- data/lib/bulb.rb +1 -0
- metadata +4 -3
- data/app/mailers/bulb/application_mailer.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d8fbeacdbc0bd0d8bdb90769e4bb4e25e3a9327847f5b690605a72ad7c29d29
|
4
|
+
data.tar.gz: 5f3cc7e8cd6778b4afbee05e73de2371929b3fac18b82263c10e643927d36124
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9c474bbb7aabc5cf420731d94ce969ac2327f3b3e6bf37f9b8a3ac1edd1214747d34aaba27319a8460c1dc8cf1b0fac46eac1446955e838ec52ef43e6771b42
|
7
|
+
data.tar.gz: d1e1ccedb16cfbbe54ae1ef1253feba5d77d9fef8c1bb2bcd36b191915e6c419d6f543890a3a515c864483f7fffbea9177e5c8232d999e347eff48a24d87217c
|
data/README.md
CHANGED
@@ -24,8 +24,15 @@ $ bundle
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
Once installed, you
|
28
|
-
|
27
|
+
Once installed, you need to generate the needed migrations to
|
28
|
+
create the tables and migrate your database:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ rake bulb:install:migrations
|
32
|
+
$ rake db:migrate
|
33
|
+
```
|
34
|
+
|
35
|
+
Then, you can mount the engine to whichever path you like:
|
29
36
|
|
30
37
|
```ruby
|
31
38
|
mount Bulb::Engine => "/git"
|
@@ -34,6 +41,18 @@ mount Bulb::Engine => "/git"
|
|
34
41
|
Then your repositories will be available through `/git/:group-slug/:slug`
|
35
42
|
like `/git/sites/personal`.
|
36
43
|
|
44
|
+
To configure where your repositories are stored and who own them, you can
|
45
|
+
open your `config/application.rb` or any environment-specific file and add
|
46
|
+
the following:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
config.bulb.repositories_path = '/srv/git/'
|
50
|
+
config.bulb.repositories_owner = 'git'
|
51
|
+
```
|
52
|
+
|
53
|
+
Where `git` is a Unix user on your system that must be the owner of the
|
54
|
+
repository folders.
|
55
|
+
|
37
56
|
## License
|
38
57
|
|
39
58
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -5,8 +5,10 @@ module Bulb
|
|
5
5
|
|
6
6
|
def show
|
7
7
|
@git_repository = @repository.git_repository
|
8
|
-
|
9
8
|
@blob_hash = @git_repository.head.target.tree.path(params[:path])
|
9
|
+
|
10
|
+
redirect_to repository_tree_path if @blob_hash[:type] == :tree
|
11
|
+
|
10
12
|
@blob = @git_repository.lookup(@blob_hash[:oid])
|
11
13
|
end
|
12
14
|
end
|
@@ -5,8 +5,10 @@ module Bulb
|
|
5
5
|
|
6
6
|
def show
|
7
7
|
@git_repository = @repository.git_repository
|
8
|
-
|
9
8
|
tree_hash = @git_repository.head.target.tree.path(params[:path])
|
9
|
+
|
10
|
+
redirect_to repository_blob_path if tree_hash[:type] == :blob
|
11
|
+
|
10
12
|
@tree = @git_repository.lookup(tree_hash[:oid])
|
11
13
|
end
|
12
14
|
end
|
@@ -9,5 +9,32 @@ module Bulb
|
|
9
9
|
root = root ? (root + "/") : ""
|
10
10
|
bulb.repository_blob_path(reference: 'master', path: root + name)
|
11
11
|
end
|
12
|
+
|
13
|
+
def breadcrumb
|
14
|
+
parts = params[:path].split("/")
|
15
|
+
last = parts.pop
|
16
|
+
|
17
|
+
reference = params[:reference]
|
18
|
+
group_slug = params[:group_slug]
|
19
|
+
slug = params[:slug]
|
20
|
+
|
21
|
+
elements = []
|
22
|
+
|
23
|
+
elements << content_tag(:li) do
|
24
|
+
link_to @repository.slug, bulb.repository_path(group_slug, slug)
|
25
|
+
end
|
26
|
+
|
27
|
+
parts.each_with_index do |part, index|
|
28
|
+
path = parts[0..index].join("/")
|
29
|
+
|
30
|
+
elements << content_tag(:li) do
|
31
|
+
link_to part, bulb.repository_tree_path(reference: reference, path: path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
elements << content_tag(:li, last)
|
36
|
+
|
37
|
+
content_tag(:ul, elements.join.html_safe, class: 'breadcrumb')
|
38
|
+
end
|
12
39
|
end
|
13
40
|
end
|
data/app/models/bulb/group.rb
CHANGED
@@ -6,6 +6,9 @@ module Bulb
|
|
6
6
|
|
7
7
|
before_create :create_git_repository
|
8
8
|
|
9
|
+
validates_uniqueness_of :slug, scope: :bulb_group_id
|
10
|
+
validates :fs_repository_path, 'bulb/unexisting': true, on: :create
|
11
|
+
|
9
12
|
def git_repository
|
10
13
|
@git_repository ||= Rugged::Repository.new(fs_repository_path)
|
11
14
|
end
|
@@ -14,17 +17,19 @@ module Bulb
|
|
14
17
|
def create_git_repository
|
15
18
|
full_path = fs_repository_path
|
16
19
|
|
17
|
-
raise RuntimeError.new if File.exist?(full_path)
|
18
|
-
|
19
20
|
FileUtils.mkdir_p(full_path)
|
20
21
|
Rugged::Repository.init_at(full_path, :bare)
|
22
|
+
|
23
|
+
if (owner = Bulb.repositories_owner).present?
|
24
|
+
FileUtils.chown_R(owner, owner, full_path)
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def fs_repository_path
|
24
29
|
if group.nil?
|
25
|
-
File.join(Bulb.repositories_path, slug)
|
30
|
+
File.join(Bulb.repositories_path, "#{slug}.git")
|
26
31
|
else
|
27
|
-
File.join(Bulb.repositories_path, group.slug, slug)
|
32
|
+
File.join(Bulb.repositories_path, group.slug, "#{slug}.git")
|
28
33
|
end
|
29
34
|
end
|
30
35
|
end
|
@@ -1,3 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
<%= breadcrumb %>
|
2
|
+
|
3
|
+
<% unless @blob.binary? %>
|
4
|
+
<div class="blob highlight">
|
5
|
+
<%= raw highlight_blob @blob_hash[:name], @blob.content.force_encoding(Encoding::UTF_8) %>
|
6
|
+
</div>
|
7
|
+
<% else %>
|
8
|
+
<div class="blob">
|
9
|
+
<% match = @blob_hash[:name].match(/\.(jpg|jpeg|png|gif)$/) %>
|
10
|
+
<% if match %>
|
11
|
+
<img src="data:image/<%= match[1] %>;base64,<%= Base64.strict_encode64(@blob.content) %>">
|
12
|
+
<% else %>
|
13
|
+
Nothing to display.
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
data/lib/bulb/engine.rb
CHANGED
data/lib/bulb/version.rb
CHANGED
data/lib/bulb.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Dupret
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,10 +86,10 @@ files:
|
|
86
86
|
- app/helpers/bulb/application_helper.rb
|
87
87
|
- app/helpers/bulb/text_helper.rb
|
88
88
|
- app/jobs/bulb/application_job.rb
|
89
|
-
- app/mailers/bulb/application_mailer.rb
|
90
89
|
- app/models/bulb/application_record.rb
|
91
90
|
- app/models/bulb/group.rb
|
92
91
|
- app/models/bulb/repository.rb
|
92
|
+
- app/validators/bulb/unexisting_validator.rb
|
93
93
|
- app/views/bulb/blob/show.html.erb
|
94
94
|
- app/views/bulb/repositories/show.html.erb
|
95
95
|
- app/views/bulb/tree/_blob.html.erb
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- config/routes.rb
|
100
100
|
- db/migrate/20210809182658_create_bulb_groups.rb
|
101
101
|
- db/migrate/20210809182912_create_bulb_repositories.rb
|
102
|
+
- db/migrate/20220116171708_add_unique_index_on_slugs.rb
|
102
103
|
- lib/bulb.rb
|
103
104
|
- lib/bulb/engine.rb
|
104
105
|
- lib/bulb/version.rb
|