mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-20 11:45:57 +08:00
add: home index api
This commit is contained in:
3
app/views/topics/_activity_forum.json.jbuilder
Normal file
3
app/views/topics/_activity_forum.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
json.(activity_forum, :id, :title, :url)
|
||||
json.visits 0
|
||||
json.created_time format_time(Time.now)
|
||||
1
app/views/topics/_banner.json.jbuilder
Normal file
1
app/views/topics/_banner.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.(banner, :id, :title, :image)
|
||||
1
app/views/topics/_card.json.jbuilder
Normal file
1
app/views/topics/_card.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.(card, :id, :title, :url)
|
||||
1
app/views/topics/_cooperator.json.jbuilder
Normal file
1
app/views/topics/_cooperator.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.(cooperator, :id, :title, :image, :url)
|
||||
3
app/views/topics/_excellent_project.json.jbuilder
Normal file
3
app/views/topics/_excellent_project.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
json.(excellent_project, :id, :title, :url)
|
||||
project_common = $redis_cache.hgetall("v2-project-common:#{excellent_project&.uuid}")
|
||||
json.visits (project_common['visits'] || 0).to_i
|
||||
3
app/views/topics/_experience_forum.json.jbuilder
Normal file
3
app/views/topics/_experience_forum.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
json.(experience_forum, :id, :title, :url)
|
||||
json.visits 0
|
||||
json.created_time format_time(Time.now)
|
||||
3
app/views/topics/_pinned_forum.json.jbuilder
Normal file
3
app/views/topics/_pinned_forum.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
json.(pinned_forum, :id, :title, :url)
|
||||
json.visits 0
|
||||
json.created_time format_time(Time.now)
|
||||
24
app/views/topics/index.json.jbuilder
Normal file
24
app/views/topics/index.json.jbuilder
Normal file
@@ -0,0 +1,24 @@
|
||||
json.partial! "commons/success"
|
||||
json.total_count @topics.total_count
|
||||
json.topics do
|
||||
json.array! @topics.each do |topic|
|
||||
case topic.type
|
||||
when "Topic::ActivityForum"
|
||||
json.partial! "activity_forum", locals: {activity_forum: topic}
|
||||
when "Topic::Banner"
|
||||
json.partial! "banner", locals: {banner: topic}
|
||||
when "Topic::Card"
|
||||
json.partial! "card", locals: {card: topic}
|
||||
when "Topic::Cooperator"
|
||||
json.partial! "cooperator", locals: {cooperator: topic}
|
||||
when "Topic::ExcellentProject"
|
||||
json.partial! "excellent_project", locals: {excellent_project: topic}
|
||||
when "Topic::ExperienceForum"
|
||||
json.partial! "experience_forum", locals: {experience_forum: topic}
|
||||
when "Topic::PinnedForum"
|
||||
json.partial! "pinned_forum", locals: {pinned_forum: topic}
|
||||
else
|
||||
json.nil!
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user