Real data profile
Seto Elkahfi committed
Jun 17, 2026 at 07:49 UTC
b6f4d7c16ee44986f90587cfdf6ca6dc786fb3b6
3 files changed
+97
-8
app/controllers/users_controller.rb
+41
-8
index d741928..d24e0f8 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,6 +1,10 @@
class UsersController < ApplicationController
before_action :require_sign_in!, only: [ :settings, :update_settings ]
+ # Username whose profile shows the curated showcase feed instead of a
+ # real activity feed.
+ DEMO_FEED_USERNAME = "sigit"
+
def show
@profile_user = User.find_by!(username: params[:username])
@repositories = if signed_in? && current_user == @profile_user
@@ -9,14 +13,19 @@ class UsersController < ApplicationController
@profile_user.repositories.where(is_private: false).order(updated_at: :desc)
end
- feed_repo = @repositories.find { |r| r.name == "sigit" } || @repositories.first
- if feed_repo&.initialized?
- @feed_repo = feed_repo
- @feed_commits = GitRepositoryService.commits(
- feed_repo.disk_path,
- feed_repo.default_branch,
- limit: 3
- )
+ if @profile_user.username == DEMO_FEED_USERNAME
+ # Curated showcase feed for the demo profile.
+ feed_repo = @repositories.find { |r| r.name == "sigit" } || @repositories.first
+ if feed_repo&.initialized?
+ @feed_repo = feed_repo
+ @feed_commits = GitRepositoryService.commits(
+ feed_repo.disk_path,
+ feed_repo.default_branch,
+ limit: 3
+ )
+ end
+ else
+ @activity_items = build_activity_feed(@repositories)
end
rescue ActiveRecord::RecordNotFound
render file: Rails.public_path.join("404.html"), status: :not_found, layout: false
@@ -40,4 +49,28 @@ class UsersController < ApplicationController
def user_settings_params
params.require(:user).permit(:display_name, :avatar_url)
end
+
+ # Real activity feed for a profile, newest first: repository creations and
+ # recent pushes (latest commits per repo) merged and sorted by time.
+ def build_activity_feed(repositories, limit: 10)
+ items = []
+
+ repositories.each do |repo|
+ items << { kind: :created_repo, at: repo.created_at, repo: repo }
+
+ next unless repo.initialized?
+
+ commits = GitRepositoryService.commits(repo.disk_path, repo.default_branch, limit: 3)
+ next if commits.blank?
+
+ items << {
+ kind: :pushed,
+ at: commits.first[:authored_date] || repo.updated_at,
+ repo: repo,
+ commits: commits
+ }
+ end
+
+ items.sort_by { |item| item[:at] || Time.at(0) }.reverse.first(limit)
+ end
end
app/views/users/_activity_item.html.erb
+43
new file mode 100644
index 0000000..5b5861f
--- /dev/null
+++ b/app/views/users/_activity_item.html.erb
@@ -0,0 +1,43 @@
+<%# Renders one real activity-feed entry. Locals: item, profile_user %>
+<li class="mb-8 ml-6">
+ <% case item[:kind] %>
+ <% when :pushed %>
+ <span class="absolute -left-3 flex h-6 w-6 items-center justify-center rounded-full border border-surface-500 bg-surface-700">
+ <svg class="w-3.5 h-3.5 text-brand-500" viewBox="0 0 16 16" fill="currentColor">
+ <path d="M1.643 3.143 .427 1.927A.25.25 0 0 0 0 2.104V5.75c0 .138.112.25.25.25h3.646a.25.25 0 0 0 .177-.427L2.715 4.215a6.5 6.5 0 1 1-1.18 4.458.75.75 0 1 0-1.493.154 8.001 8.001 0 1 0 1.6-5.684ZM7.75 4a.75.75 0 0 1 .75.75v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5A.75.75 0 0 1 7.75 4Z"/>
+ </svg>
+ </span>
+ <div class="card px-4 py-3">
+ <p class="text-xs text-gray-500 mb-2"><%= time_ago_in_words(item[:at]) %> ago</p>
+ <p class="text-sm mb-3">
+ <span class="text-gray-400">Pushed </span>
+ <span class="font-semibold text-gray-200"><%= pluralize(item[:commits].size, "commit") %></span>
+ <span class="text-gray-400"> to </span>
+ <%= link_to "@#{profile_user.username}/#{item[:repo].name}", repository_path(profile_user.username, item[:repo].name), class: "text-brand-500 hover:underline font-medium" %>
+ <span class="text-gray-400"> on </span>
+ <code class="bg-surface-600 px-1.5 py-0.5 rounded text-xs text-gray-200"><%= item[:repo].default_branch || "main" %></code>
+ </p>
+ <ul class="space-y-1.5 border-t border-surface-600 pt-3">
+ <% item[:commits].each do |commit| %>
+ <li class="flex items-start gap-2 text-xs text-gray-400">
+ <%= link_to commit[:short_sha], repository_commit_path(profile_user.username, item[:repo].name, commit[:sha]), class: "text-brand-400 shrink-0 font-mono hover:underline" %>
+ <span><%= commit[:subject] %></span>
+ </li>
+ <% end %>
+ </ul>
+ </div>
+ <% when :created_repo %>
+ <span class="absolute -left-3 flex h-6 w-6 items-center justify-center rounded-full border border-surface-500 bg-surface-700">
+ <svg class="w-3.5 h-3.5 text-gray-400" viewBox="0 0 16 16" fill="currentColor">
+ <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"/>
+ </svg>
+ </span>
+ <div class="card px-4 py-3">
+ <p class="text-xs text-gray-500 mb-2"><%= time_ago_in_words(item[:at]) %> ago</p>
+ <p class="text-sm">
+ <span class="text-gray-400">Created repository </span>
+ <%= link_to "@#{profile_user.username}/#{item[:repo].name}", repository_path(profile_user.username, item[:repo].name), class: "text-brand-500 hover:underline font-medium" %>
+ </p>
+ </div>
+ <% end %>
+</li>
app/views/users/show.html.erb
+13
index fe183d7..986f3d4 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -128,6 +128,10 @@
<%# ── Feed panel ── %>
<div data-tabs-target="panel" data-tabs-key="feed">
+ <% if @profile_user.username == "sigit" %>
+ <%# Curated showcase feed for the demo profile. Every other profile
+ renders a real activity feed (@activity_items) built from its
+ repositories and commits. %>
<ol class="relative border-l border-surface-600 ml-3 space-y-0">
<%# Item: push commits %>
@@ -232,6 +236,15 @@
</li>
</ol>
+ <% elsif @activity_items.present? %>
+ <ol class="relative border-l border-surface-600 ml-3 space-y-0">
+ <%= render partial: "users/activity_item", collection: @activity_items, as: :item, locals: { profile_user: @profile_user } %>
+ </ol>
+ <% else %>
+ <div class="card px-4 py-8 text-center text-sm text-gray-500">
+ No activity yet.
+ </div>
+ <% end %>
</div>
<%# ── Repositories panel ── %>