add: home index api

This commit is contained in:
2021-11-03 10:19:01 +08:00
parent 35f04afe91
commit 18bbbce7b3
19 changed files with 70 additions and 55 deletions

View File

@@ -0,0 +1,3 @@
json.(activity_forum, :id, :title, :url)
json.visits 0
json.created_time format_time(Time.now)

View File

@@ -0,0 +1 @@
json.(banner, :id, :title, :image)

View File

@@ -0,0 +1 @@
json.(card, :id, :title, :url)

View File

@@ -0,0 +1 @@
json.(cooperator, :id, :title, :image, :url)

View 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

View File

@@ -0,0 +1,3 @@
json.(experience_forum, :id, :title, :url)
json.visits 0
json.created_time format_time(Time.now)

View File

@@ -0,0 +1,3 @@
json.(pinned_forum, :id, :title, :url)
json.visits 0
json.created_time format_time(Time.now)

View 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