main
erb 77 lines 4.53 KB
Raw
1 <% content_for :title, "Repositories" %>
2 <% content_for :description, "Explore public Git repositories hosted on siGit." %>
3
4 <div class="max-w-6xl mx-auto px-4 sm:px-6 py-8">
5
6 <div class="flex items-end justify-between gap-4 mb-6 flex-wrap">
7 <div>
8 <h1 class="text-2xl font-semibold text-gray-100 flex items-center gap-2">
9 <svg class="w-6 h-6 text-brand-500" viewBox="0 0 16 16" fill="currentColor">
10 <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8Z"/>
11 </svg>
12 Repositories
13 <span class="badge-gray text-sm align-middle"><%= number_with_delimiter(@repositories.size) %></span>
14 </h1>
15 <p class="text-sm text-gray-400 mt-1">Source code hosted on siGit — browse, clone, and build on it.</p>
16 </div>
17 <% if signed_in? %>
18 <%= link_to new_repository_path, class: "btn-primary text-xs py-2 px-4" do %>
19 <svg class="w-3.5 h-3.5" viewBox="0 0 16 16" fill="currentColor"><path d="M7.75 2a.75.75 0 0 1 .75.75V7h4.25a.75.75 0 0 1 0 1.5H8.5v4.25a.75.75 0 0 1-1.5 0V8.5H2.75a.75.75 0 0 1 0-1.5H7V2.75A.75.75 0 0 1 7.75 2Z"/></svg>
20 New repository
21 <% end %>
22 <% end %>
23 </div>
24
25 <div class="flex items-center gap-3 mb-4">
26 <%= form_with url: repos_path, method: :get, class: "flex-1" do %>
27 <%= hidden_field_tag :sort, @sort %>
28 <div class="relative">
29 <svg class="w-4 h-4 text-gray-500 absolute left-3 top-1/2 -translate-y-1/2" viewBox="0 0 16 16" fill="currentColor"><path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-1.06 1.06ZM11.5 7a4.5 4.5 0 1 0-9 0 4.5 4.5 0 0 0 9 0Z"/></svg>
30 <%= text_field_tag :q, @query, placeholder: "Search repositories…",
31 class: "form-input pl-9", autocomplete: "off" %>
32 </div>
33 <% end %>
34 <%= form_with url: repos_path, method: :get, class: "shrink-0" do %>
35 <% if @query.present? %><%= hidden_field_tag :q, @query %><% end %>
36 <%= select_tag :sort,
37 options_for_select([["Recently updated", "recent"], ["Most stars", "stars"], ["Name", "name"]], @sort),
38 class: "form-input py-2 pr-8 text-sm", onchange: "this.form.submit()" %>
39 <% end %>
40 </div>
41
42 <% if @repositories.any? %>
43 <div class="card divide-y divide-surface-600">
44 <% @repositories.each do |repo| %>
45 <%= link_to repository_path(repo.user.username, repo.name),
46 class: "block px-4 py-3 hover:bg-surface-600 transition-colors" do %>
47 <div class="flex items-center justify-between gap-3">
48 <div class="min-w-0">
49 <div class="flex items-center gap-2">
50 <svg class="w-4 h-4 text-gray-500 shrink-0" viewBox="0 0 16 16" fill="currentColor">
51 <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8Z"/>
52 </svg>
53 <span class="font-medium text-gray-100 truncate"><%= repo.full_name %></span>
54 <% if repo.is_private %><span class="badge-gray">Private</span><% end %>
55 </div>
56 <% if repo.description.present? %>
57 <p class="text-xs text-gray-400 mt-1 truncate max-w-xl"><%= repo.description %></p>
58 <% end %>
59 <p class="text-xs text-gray-500 mt-1">Updated <%= time_ago_in_words(repo.updated_at) %> ago</p>
60 </div>
61 <div class="flex items-center gap-1 text-xs text-gray-500 shrink-0" title="Stars">
62 <svg class="w-3.5 h-3.5" viewBox="0 0 16 16" fill="currentColor"><path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"/></svg>
63 <%= number_with_delimiter(repo.stars_count) %>
64 </div>
65 </div>
66 <% end %>
67 <% end %>
68 </div>
69 <% else %>
70 <div class="card px-6 py-16 text-center">
71 <p class="text-sm text-gray-400 mb-1">No repositories found.</p>
72 <% if signed_in? %>
73 <p class="text-xs text-gray-500"><%= link_to "Create one", new_repository_path, class: "text-brand-500 hover:underline" %> to get started.</p>
74 <% end %>
75 </div>
76 <% end %>
77 </div>