diff --git a/app/controllers/admins/topic/activity_forums_controller.rb b/app/controllers/admins/topic/activity_forums_controller.rb new file mode 100644 index 000000000..b027dc003 --- /dev/null +++ b/app/controllers/admins/topic/activity_forums_controller.rb @@ -0,0 +1,57 @@ +class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController + before_action :find_activity_forum, only: [:edit, :update, :destroy] + + def index + q = ::Topic::ActivityForum.ransack(title_cont: params[:search]) + activity_forums = q.result(distinct: true) + @activity_forums = paginate(activity_forums) + end + + def new + @activity_forum = ::Topic::ActivityForum.new + end + + def create + @activity_forum = ::Topic::ActivityForum.new(activity_forum_params) + if @activity_forum.save + redirect_to admins_topic_activity_forums_path + flash[:success] = "新增平台动态成功" + else + redirect_to admins_topic_activity_forums_path + flash[:danger] = "新增平台动态失败" + end + end + + def edit + end + + def update + @activity_forum.attributes = activity_forum_params + if @activity_forum.save + redirect_to admins_topic_activity_forums_path + flash[:success] = "更新平台动态成功" + else + redirect_to admins_topic_activity_forums_path + flash[:danger] = "更新平台动态失败" + end + end + + def destroy + if @activity_forum.destroy + redirect_to admins_topic_activity_forums_path + flash[:success] = "删除平台动态成功" + else + redirect_to admins_topic_activity_forums_path + flash[:danger] = "删除平台动态失败" + end + end + + private + def find_activity_forum + @activity_forum = ::Topic::ActivityForum.find_by_id(params[:id]) + end + + def activity_forum_params + params.require(:topic_activity_forum).permit(:title, :uuid, :url, :order_index) + end +end \ No newline at end of file diff --git a/app/controllers/admins/topic/banners_controller.rb b/app/controllers/admins/topic/banners_controller.rb new file mode 100644 index 000000000..359845806 --- /dev/null +++ b/app/controllers/admins/topic/banners_controller.rb @@ -0,0 +1,57 @@ +class Admins::Topic::BannersController < Admins::Topic::BaseController + before_action :find_banner, only: [:edit, :update, :destroy] + + def index + @banners = paginate(::Topic::Banner) + end + + def new + @banner = ::Topic::Banner.new + end + + def create + @banner = ::Topic::Banner.new(banner_params) + if @banner.save + save_image_file(params[:image], @banner) + redirect_to admins_topic_banners_path + flash[:success] = "新增banner成功" + else + redirect_to admins_topic_banners_path + flash[:danger] = "新增banner失败" + end + end + + def edit + end + + def update + @banner.attributes = banner_params + if @banner.save + save_image_file(params[:image], @banner) + redirect_to admins_topic_banners_path + flash[:success] = "更新banner成功" + else + redirect_to admins_topic_banners_path + flash[:danger] = "更新banner失败" + end + end + + def destroy + if @banner.destroy + redirect_to admins_topic_banners_path + flash[:success] = "删除banner成功" + else + redirect_to admins_topic_banners_path + flash[:danger] = "删除banner失败" + end + end + + private + def find_banner + @banner = ::Topic::Banner.find_by_id(params[:id]) + end + + def banner_params + params.require(:topic_banner).permit(:title, :order_index) + end +end \ No newline at end of file diff --git a/app/controllers/admins/topic/base_controller.rb b/app/controllers/admins/topic/base_controller.rb new file mode 100644 index 000000000..1360232c8 --- /dev/null +++ b/app/controllers/admins/topic/base_controller.rb @@ -0,0 +1,11 @@ +class Admins::Topic::BaseController < Admins::BaseController + + protected + def save_image_file(file, topic) + return unless file.present? && file.is_a?(ActionDispatch::Http::UploadedFile) + + file_path = Util::FileManage.source_disk_filename(topic, 'image') + File.delete(file_path) if File.exist?(file_path) # 删除之前的文件 + Util.write_file(file, file_path) + end +end \ No newline at end of file diff --git a/app/controllers/admins/topic/cards_controller.rb b/app/controllers/admins/topic/cards_controller.rb new file mode 100644 index 000000000..732f17e5b --- /dev/null +++ b/app/controllers/admins/topic/cards_controller.rb @@ -0,0 +1,57 @@ +class Admins::Topic::CardsController < Admins::Topic::BaseController + before_action :find_card, only: [:edit, :update, :destroy] + + def index + q = ::Topic::Card.ransack(title_cont: params[:search]) + cards = q.result(distinct: true) + @cards = paginate(cards) + end + + def new + @card = ::Topic::Card.new + end + + def create + @card = ::Topic::Card.new(card_params) + if @card.save + redirect_to admins_topic_cards_path + flash[:success] = "新增合作单位成功" + else + redirect_to admins_topic_cards_path + flash[:danger] = "新增合作单位失败" + end + end + + def edit + end + + def update + @card.attributes = card_params + if @card.save + redirect_to admins_topic_cards_path + flash[:success] = "更新合作单位成功" + else + redirect_to admins_topic_cards_path + flash[:danger] = "更新合作单位失败" + end + end + + def destroy + if @card.destroy + redirect_to admins_topic_cards_path + flash[:success] = "删除合作单位成功" + else + redirect_to admins_topic_cards_path + flash[:danger] = "删除合作单位失败" + end + end + + private + def find_card + @card = ::Topic::Card.find_by_id(params[:id]) + end + + def card_params + params.require(:topic_card).permit(:title, :url, :order_index) + end +end \ No newline at end of file diff --git a/app/controllers/admins/topic/cooperators_controller.rb b/app/controllers/admins/topic/cooperators_controller.rb new file mode 100644 index 000000000..fdd47e712 --- /dev/null +++ b/app/controllers/admins/topic/cooperators_controller.rb @@ -0,0 +1,57 @@ +class Admins::Topic::CooperatorsController < Admins::Topic::BaseController + before_action :find_cooperator, only: [:edit, :update, :destroy] + + def index + @cooperators = kaminari_paginate(::Topic::Cooperator) + end + + def new + @cooperator = ::Topic::Cooperator.new + end + + def create + @cooperator = ::Topic::Cooperator.new(cooperator_params) + if @cooperator.save + save_image_file(params[:image], @cooperator) + redirect_to admins_topic_cooperators_path + flash[:success] = "新增合作单位成功" + else + redirect_to admins_topic_cooperators_path + flash[:danger] = "新增合作单位失败" + end + end + + def edit + end + + def update + @cooperator.attributes = cooperator_params + if @cooperator.save + save_image_file(params[:image], @cooperator) + redirect_to admins_topic_cooperators_path + flash[:success] = "更新合作单位成功" + else + redirect_to admins_topic_cooperators_path + flash[:danger] = "更新合作单位失败" + end + end + + def destroy + if @cooperator.destroy + redirect_to admins_topic_cooperators_path + flash[:success] = "删除合作单位成功" + else + redirect_to admins_topic_cooperators_path + flash[:danger] = "删除合作单位失败" + end + end + + private + def find_cooperator + @cooperator = ::Topic::Cooperator.find_by_id(params[:id]) + end + + def cooperator_params + params.require(:topic_cooperator).permit(:title, :url, :order_index) + end +end \ No newline at end of file diff --git a/app/controllers/admins/topic/excellent_projects_controller.rb b/app/controllers/admins/topic/excellent_projects_controller.rb new file mode 100644 index 000000000..b60dac54c --- /dev/null +++ b/app/controllers/admins/topic/excellent_projects_controller.rb @@ -0,0 +1,57 @@ +class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController + before_action :find_excellent_project, only: [:edit, :update, :destroy] + + def index + q = ::Topic::ExcellentProject.ransack(title_cont: params[:search]) + excellent_projects = q.result(distinct: true) + @excellent_projects = paginate(excellent_projects) + end + + def new + @excellent_project = ::Topic::ExcellentProject.new + end + + def create + @excellent_project = ::Topic::ExcellentProject.new(excellent_project_params) + if @excellent_project.save + redirect_to admins_topic_excellent_projects_path + flash[:success] = "新增优秀仓库成功" + else + redirect_to admins_topic_excellent_projects_path + flash[:danger] = "新增优秀仓库失败" + end + end + + def edit + end + + def update + @excellent_project.attributes = excellent_project_params + if @excellent_project.save + redirect_to admins_topic_excellent_projects_path + flash[:success] = "更新优秀仓库成功" + else + redirect_to admins_topic_excellent_projects_path + flash[:danger] = "更新优秀仓库失败" + end + end + + def destroy + if @excellent_project.destroy + redirect_to admins_topic_excellent_projects_path + flash[:success] = "删除优秀仓库成功" + else + redirect_to admins_topic_excellent_projects_path + flash[:danger] = "删除优秀仓库失败" + end + end + + private + def find_excellent_project + @excellent_project = ::Topic::ExcellentProject.find_by_id(params[:id]) + end + + def excellent_project_params + params.require(:topic_excellent_project).permit(:title, :uuid, :url, :order_index) + end +end \ No newline at end of file diff --git a/app/controllers/admins/topic/experience_forums_controller.rb b/app/controllers/admins/topic/experience_forums_controller.rb new file mode 100644 index 000000000..420670c1b --- /dev/null +++ b/app/controllers/admins/topic/experience_forums_controller.rb @@ -0,0 +1,57 @@ +class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController + before_action :find_experience_forum, only: [:edit, :update, :destroy] + + def index + q = ::Topic::ExperienceForum.ransack(title_cont: params[:search]) + experience_forums = q.result(distinct: true) + @experience_forums = paginate(experience_forums) + end + + def new + @experience_forum = ::Topic::ExperienceForum.new + end + + def create + @experience_forum = ::Topic::ExperienceForum.new(experience_forum_params) + if @experience_forum.save + redirect_to admins_topic_experience_forums_path + flash[:success] = "新增经验分享成功" + else + redirect_to admins_topic_experience_forums_path + flash[:danger] = "新增经验分享失败" + end + end + + def edit + end + + def update + @experience_forum.attributes = experience_forum_params + if @experience_forum.save + redirect_to admins_topic_experience_forums_path + flash[:success] = "更新经验分享成功" + else + redirect_to admins_topic_experience_forums_path + flash[:danger] = "更新经验分享失败" + end + end + + def destroy + if @experience_forum.destroy + redirect_to admins_topic_experience_forums_path + flash[:success] = "删除经验分享成功" + else + redirect_to admins_topic_experience_forums_path + flash[:danger] = "删除经验分享失败" + end + end + + private + def find_experience_forum + @experience_forum = ::Topic::ExperienceForum.find_by_id(params[:id]) + end + + def experience_forum_params + params.require(:topic_experience_forum).permit(:title, :uuid, :url, :order_index) + end +end \ No newline at end of file diff --git a/app/controllers/admins/topic/pinned_forums_controller.rb b/app/controllers/admins/topic/pinned_forums_controller.rb new file mode 100644 index 000000000..ac5bf69a7 --- /dev/null +++ b/app/controllers/admins/topic/pinned_forums_controller.rb @@ -0,0 +1,57 @@ +class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController + before_action :find_pinned_forum, only: [:edit, :update, :destroy] + + def index + q = ::Topic::PinnedForum.ransack(title_cont: params[:search]) + pinned_forums = q.result(distinct: true) + @pinned_forums = paginate(pinned_forums) + end + + def new + @pinned_forum = ::Topic::PinnedForum.new + end + + def create + @pinned_forum = ::Topic::PinnedForum.new(pinned_forum_params) + if @pinned_forum.save + redirect_to admins_topic_pinned_forums_path + flash[:success] = "新增精选文章成功" + else + redirect_to admins_topic_pinned_forums_path + flash[:danger] = "新增精选文章失败" + end + end + + def edit + end + + def update + @pinned_forum.attributes = pinned_forum_params + if @pinned_forum.save + redirect_to admins_topic_pinned_forums_path + flash[:success] = "更新精选文章成功" + else + redirect_to admins_topic_pinned_forums_path + flash[:danger] = "更新精选文章失败" + end + end + + def destroy + if @pinned_forum.destroy + redirect_to admins_topic_pinned_forums_path + flash[:success] = "删除精选文章成功" + else + redirect_to admins_topic_pinned_forums_path + flash[:danger] = "删除精选文章失败" + end + end + + private + def find_pinned_forum + @pinned_forum = ::Topic::PinnedForum.find_by_id(params[:id]) + end + + def pinned_forum_params + params.require(:topic_pinned_forum).permit(:title, :uuid, :url, :order_index) + end +end \ No newline at end of file diff --git a/app/models/topic.rb b/app/models/topic.rb index a859d9029..117912bd0 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -14,4 +14,16 @@ class Topic < ApplicationRecord default_scope { order(order_index: :desc)} + + def image + image_url('image') + end + + private + + def image_url(type) + return nil unless Util::FileManage.exists?(self, type) + Util::FileManage.source_disk_file_url(self, type) + end + end diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index 75abbc124..0b88ddc0b 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -31,7 +31,17 @@
  • <%= sidebar_item(admins_reversed_keywords_path, '系统保留关键词', icon: 'key', controller: 'admins-reversed_keywords') %>
  • <%= sidebar_item(admins_laboratories_path, '云上实验室', icon: 'cloud', controller: 'admins-laboratories') %>
  • - +
  • + <%= sidebar_item_group('#setting-index', '首页配置', icon: 'file') do %> +
  • <%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners') %>
  • +
  • <%= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards') %>
  • +
  • <%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums') %>
  • +
  • <%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects') %>
  • +
  • <%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums') %>
  • +
  • <%= sidebar_item(admins_topic_experience_forums_path, '经验分享管理', icon: 'edit', controller: 'admins-topic-experience_forums') %>
  • +
  • <%= sidebar_item(admins_topic_cooperators_path, '合作伙伴管理', icon: 'user', controller: 'admins-topic-cooperators') %>
  • + <% end %> +
  • <%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %>
  • <%= sidebar_item(edit_admins_about_path, '关于我们', icon: 'smile-o', controller: 'admins-abouts') %>
  • diff --git a/app/views/admins/topic/activity_forums/_form_modal.html.erb b/app/views/admins/topic/activity_forums/_form_modal.html.erb new file mode 100644 index 000000000..3426337d2 --- /dev/null +++ b/app/views/admins/topic/activity_forums/_form_modal.html.erb @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/app/views/admins/topic/activity_forums/_list.html.erb b/app/views/admins/topic/activity_forums/_list.html.erb new file mode 100644 index 000000000..35068eddb --- /dev/null +++ b/app/views/admins/topic/activity_forums/_list.html.erb @@ -0,0 +1,33 @@ + + + + + + + + + + + + + <% if activity_forums.present? %> + <% activity_forums.each_with_index do |activity_forum, index| %> + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题跳转地址帖子ID排序等级操作
    <%= list_index_no((params[:page] || 1).to_i, index) %><%= activity_forum.title %><%= activity_forum.url %><%= activity_forum.uuid %><%= activity_forum.order_index %> + <%= link_to "编辑", edit_admins_topic_activity_forum_path(activity_forum), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_activity_forum_path(activity_forum), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: activity_forums } %> \ No newline at end of file diff --git a/app/views/admins/topic/activity_forums/edit.js.erb b/app/views/admins/topic/activity_forums/edit.js.erb new file mode 100644 index 000000000..b66ecd1c4 --- /dev/null +++ b/app/views/admins/topic/activity_forums/edit.js.erb @@ -0,0 +1,2 @@ +$("#activity-forum-modals").html("<%= j render(partial: 'admins/topic/activity_forums/form_modal', locals: {type: 'update'}) %>") +$(".activity-forum-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/activity_forums/index.html.erb b/app/views/admins/topic/activity_forums/index.html.erb new file mode 100644 index 000000000..a6d673d31 --- /dev/null +++ b/app/views/admins/topic/activity_forums/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('平台动态管理') %> +<% end %> + +
    + <%= form_tag(admins_topic_activity_forums_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_activity_forum_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + <%= render partial: 'admins/topic/activity_forums/list', locals: { activity_forums: @activity_forums } %> +
    +
    +
    diff --git a/app/views/admins/topic/activity_forums/index.js.erb b/app/views/admins/topic/activity_forums/index.js.erb new file mode 100644 index 000000000..3560c21f1 --- /dev/null +++ b/app/views/admins/topic/activity_forums/index.js.erb @@ -0,0 +1 @@ +$('.activity-forum-list-container').html("<%= j( render partial: 'admins/topic/activity_forums/list', locals: { activity_forums: @activity_forums } ) %>"); \ No newline at end of file diff --git a/app/views/admins/topic/activity_forums/new.js.erb b/app/views/admins/topic/activity_forums/new.js.erb new file mode 100644 index 000000000..8e9a33097 --- /dev/null +++ b/app/views/admins/topic/activity_forums/new.js.erb @@ -0,0 +1,2 @@ +$("#activity-forum-modals").html("<%= j render(partial: 'admins/topic/activity_forums/form_modal', locals: {type: 'create'}) %>") +$(".activity-forum-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/banners/_form_modal.html.erb b/app/views/admins/topic/banners/_form_modal.html.erb new file mode 100644 index 000000000..20bca80c6 --- /dev/null +++ b/app/views/admins/topic/banners/_form_modal.html.erb @@ -0,0 +1,45 @@ + \ No newline at end of file diff --git a/app/views/admins/topic/banners/_list.html.erb b/app/views/admins/topic/banners/_list.html.erb new file mode 100644 index 000000000..b3df7cf0b --- /dev/null +++ b/app/views/admins/topic/banners/_list.html.erb @@ -0,0 +1,31 @@ + + + + + + + + + + + + <% if banners.present? %> + <% banners.each_with_index do |banner, index| %> + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题图片排序等级操作
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: banners } %> \ No newline at end of file diff --git a/app/views/admins/topic/banners/edit.js.erb b/app/views/admins/topic/banners/edit.js.erb new file mode 100644 index 000000000..524bb13a7 --- /dev/null +++ b/app/views/admins/topic/banners/edit.js.erb @@ -0,0 +1,18 @@ +$("#banner-modals").html("<%= j render(partial: 'admins/topic/banners/form_modal', locals: {type: 'update'}) %>") +$(".banner-change-modal").modal('show'); + +$('.logo-item-left').on("change", 'input[type="file"]', function () { + var $fileInput = $(this); + var file = this.files[0]; + var imageType = /image.*/; + if (file && file.type.match(imageType)) { + var reader = new FileReader(); + reader.onload = function () { + var $box = $fileInput.parent(); + $box.find('img').attr('src', reader.result).css('display', 'block'); + $box.addClass('has-img'); + }; + reader.readAsDataURL(file); + } else { + } +}); diff --git a/app/views/admins/topic/banners/index.html.erb b/app/views/admins/topic/banners/index.html.erb new file mode 100644 index 000000000..e8ceefa2f --- /dev/null +++ b/app/views/admins/topic/banners/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('卡片管理') %> +<% end %> + +
    + <%= form_tag(admins_topic_banners_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_banner_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + + + diff --git a/app/views/admins/topic/banners/index.js.erb b/app/views/admins/topic/banners/index.js.erb new file mode 100644 index 000000000..0095bd861 --- /dev/null +++ b/app/views/admins/topic/banners/index.js.erb @@ -0,0 +1 @@ +$('.banner-list-container').html("<%= j( render partial: 'admins/topic/banners/list', locals: { banners: @banners } ) %>"); \ No newline at end of file diff --git a/app/views/admins/topic/banners/new.js.erb b/app/views/admins/topic/banners/new.js.erb new file mode 100644 index 000000000..d1450eb7f --- /dev/null +++ b/app/views/admins/topic/banners/new.js.erb @@ -0,0 +1,18 @@ +$("#banner-modals").html("<%= j render(partial: 'admins/topic/banners/form_modal', locals: {type: 'create'}) %>") +$(".banner-change-modal").modal('show'); + +$('.logo-item-left').on("change", 'input[type="file"]', function () { + var $fileInput = $(this); + var file = this.files[0]; + var imageType = /image.*/; + if (file && file.type.match(imageType)) { + var reader = new FileReader(); + reader.onload = function () { + var $box = $fileInput.parent(); + $box.find('img').attr('src', reader.result).css('display', 'block'); + $box.addClass('has-img'); + }; + reader.readAsDataURL(file); + } else { + } +}); diff --git a/app/views/admins/topic/cards/_form_modal.html.erb b/app/views/admins/topic/cards/_form_modal.html.erb new file mode 100644 index 000000000..960b8b503 --- /dev/null +++ b/app/views/admins/topic/cards/_form_modal.html.erb @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/app/views/admins/topic/cards/_list.html.erb b/app/views/admins/topic/cards/_list.html.erb new file mode 100644 index 000000000..71a460199 --- /dev/null +++ b/app/views/admins/topic/cards/_list.html.erb @@ -0,0 +1,31 @@ + + + + + + + + + + + + <% if cards.present? %> + <% cards.each_with_index do |card, index| %> + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题跳转地址排序等级操作
    <%= list_index_no((params[:page] || 1).to_i, index) %><%= card.title %><%= card.url %><%= card.order_index %> + <%= link_to "编辑", edit_admins_topic_card_path(card), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_card_path(card), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: cards } %> \ No newline at end of file diff --git a/app/views/admins/topic/cards/edit.js.erb b/app/views/admins/topic/cards/edit.js.erb new file mode 100644 index 000000000..9d0ed0e74 --- /dev/null +++ b/app/views/admins/topic/cards/edit.js.erb @@ -0,0 +1,2 @@ +$("#card-modals").html("<%= j render(partial: 'admins/topic/cards/form_modal', locals: {type: 'update'}) %>") +$(".card-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/cards/index.html.erb b/app/views/admins/topic/cards/index.html.erb new file mode 100644 index 000000000..6865fa107 --- /dev/null +++ b/app/views/admins/topic/cards/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('卡片管理') %> +<% end %> + +
    + <%= form_tag(admins_topic_cards_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_card_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + <%= render partial: 'admins/topic/cards/list', locals: { cards: @cards } %> +
    +
    +
    diff --git a/app/views/admins/topic/cards/index.js.erb b/app/views/admins/topic/cards/index.js.erb new file mode 100644 index 000000000..1bbcb5487 --- /dev/null +++ b/app/views/admins/topic/cards/index.js.erb @@ -0,0 +1 @@ +$('.card-list-container').html("<%= j( render partial: 'admins/topic/cards/list', locals: { cards: @cards } ) %>"); \ No newline at end of file diff --git a/app/views/admins/topic/cards/new.js.erb b/app/views/admins/topic/cards/new.js.erb new file mode 100644 index 000000000..94b8353b9 --- /dev/null +++ b/app/views/admins/topic/cards/new.js.erb @@ -0,0 +1,2 @@ +$("#card-modals").html("<%= j render(partial: 'admins/topic/cards/form_modal', locals: {type: 'create'}) %>") +$(".card-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/cooperators/_form_modal.html.erb b/app/views/admins/topic/cooperators/_form_modal.html.erb new file mode 100644 index 000000000..8f9085292 --- /dev/null +++ b/app/views/admins/topic/cooperators/_form_modal.html.erb @@ -0,0 +1,51 @@ + \ No newline at end of file diff --git a/app/views/admins/topic/cooperators/_list.html.erb b/app/views/admins/topic/cooperators/_list.html.erb new file mode 100644 index 000000000..18fa64969 --- /dev/null +++ b/app/views/admins/topic/cooperators/_list.html.erb @@ -0,0 +1,33 @@ + + + + + + + + + + + + + <% if cooperators.present? %> + <% cooperators.each_with_index do |cooperator, index| %> + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题跳转地址图片排序等级操作
    <%= list_index_no((params[:page] || 1).to_i, index) %><%= cooperator.title %><%= cooperator.url %><%= cooperator.order_index %> + <%= link_to "编辑", edit_admins_topic_cooperator_path(cooperator), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_cooperator_path(cooperator), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: cooperators } %> \ No newline at end of file diff --git a/app/views/admins/topic/cooperators/edit.js.erb b/app/views/admins/topic/cooperators/edit.js.erb new file mode 100644 index 000000000..ec99bfcef --- /dev/null +++ b/app/views/admins/topic/cooperators/edit.js.erb @@ -0,0 +1,18 @@ +$("#cooperator-modals").html("<%= j render(partial: 'admins/topic/cooperators/form_modal', locals: {type: 'update'}) %>") +$(".cooperator-change-modal").modal('show'); + +$('.logo-item-left').on("change", 'input[type="file"]', function () { + var $fileInput = $(this); + var file = this.files[0]; + var imageType = /image.*/; + if (file && file.type.match(imageType)) { + var reader = new FileReader(); + reader.onload = function () { + var $box = $fileInput.parent(); + $box.find('img').attr('src', reader.result).css('display', 'block'); + $box.addClass('has-img'); + }; + reader.readAsDataURL(file); + } else { + } +}); diff --git a/app/views/admins/topic/cooperators/index.html.erb b/app/views/admins/topic/cooperators/index.html.erb new file mode 100644 index 000000000..e18bc397f --- /dev/null +++ b/app/views/admins/topic/cooperators/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('卡片管理') %> +<% end %> + +
    + <%= form_tag(admins_topic_cooperators_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_cooperator_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + <%= render partial: 'admins/topic/cooperators/list', locals: { cooperators: @cooperators } %> +
    +
    +
    diff --git a/app/views/admins/topic/cooperators/index.js.erb b/app/views/admins/topic/cooperators/index.js.erb new file mode 100644 index 000000000..e3bbc044b --- /dev/null +++ b/app/views/admins/topic/cooperators/index.js.erb @@ -0,0 +1 @@ +$('.cooperator-list-container').html("<%= j( render partial: 'admins/topic/cooperators/list', locals: { cooperators: @cooperators } ) %>"); \ No newline at end of file diff --git a/app/views/admins/topic/cooperators/new.js.erb b/app/views/admins/topic/cooperators/new.js.erb new file mode 100644 index 000000000..d986f4e7d --- /dev/null +++ b/app/views/admins/topic/cooperators/new.js.erb @@ -0,0 +1,18 @@ +$("#cooperator-modals").html("<%= j render(partial: 'admins/topic/cooperators/form_modal', locals: {type: 'create'}) %>") +$(".cooperator-change-modal").modal('show'); + +$('.logo-item-left').on("change", 'input[type="file"]', function () { + var $fileInput = $(this); + var file = this.files[0]; + var imageType = /image.*/; + if (file && file.type.match(imageType)) { + var reader = new FileReader(); + reader.onload = function () { + var $box = $fileInput.parent(); + $box.find('img').attr('src', reader.result).css('display', 'block'); + $box.addClass('has-img'); + }; + reader.readAsDataURL(file); + } else { + } +}); diff --git a/app/views/admins/topic/excellent_projects/_form_modal.html.erb b/app/views/admins/topic/excellent_projects/_form_modal.html.erb new file mode 100644 index 000000000..4e48063b8 --- /dev/null +++ b/app/views/admins/topic/excellent_projects/_form_modal.html.erb @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/app/views/admins/topic/excellent_projects/_list.html.erb b/app/views/admins/topic/excellent_projects/_list.html.erb new file mode 100644 index 000000000..7642037db --- /dev/null +++ b/app/views/admins/topic/excellent_projects/_list.html.erb @@ -0,0 +1,33 @@ + + + + + + + + + + + + + <% if excellent_projects.present? %> + <% excellent_projects.each_with_index do |excellent_project, index| %> + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题跳转地址项目ID排序等级操作
    <%= list_index_no((params[:page] || 1).to_i, index) %><%= excellent_project.title %><%= excellent_project.url %><%= excellent_project.uuid %><%= excellent_project.order_index %> + <%= link_to "编辑", edit_admins_topic_excellent_project_path(excellent_project), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_excellent_project_path(excellent_project), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: excellent_projects } %> \ No newline at end of file diff --git a/app/views/admins/topic/excellent_projects/edit.js.erb b/app/views/admins/topic/excellent_projects/edit.js.erb new file mode 100644 index 000000000..d47b1a92a --- /dev/null +++ b/app/views/admins/topic/excellent_projects/edit.js.erb @@ -0,0 +1,2 @@ +$("#excellent-project-modals").html("<%= j render(partial: 'admins/topic/excellent_projects/form_modal', locals: {type: 'update'}) %>") +$(".excellent-project-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/excellent_projects/index.html.erb b/app/views/admins/topic/excellent_projects/index.html.erb new file mode 100644 index 000000000..1b529344b --- /dev/null +++ b/app/views/admins/topic/excellent_projects/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('优秀仓库管理') %> +<% end %> + +
    + <%= form_tag(admins_topic_excellent_projects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_excellent_project_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + <%= render partial: 'admins/topic/excellent_projects/list', locals: { excellent_projects: @excellent_projects } %> +
    +
    +
    diff --git a/app/views/admins/topic/excellent_projects/index.js.erb b/app/views/admins/topic/excellent_projects/index.js.erb new file mode 100644 index 000000000..969abd1e0 --- /dev/null +++ b/app/views/admins/topic/excellent_projects/index.js.erb @@ -0,0 +1 @@ +$('.excellent-project-list-container').html("<%= j( render partial: 'admins/topic/excellent_projects/list', locals: { excellent_projects: @excellent_projects } ) %>"); \ No newline at end of file diff --git a/app/views/admins/topic/excellent_projects/new.js.erb b/app/views/admins/topic/excellent_projects/new.js.erb new file mode 100644 index 000000000..1b7e13095 --- /dev/null +++ b/app/views/admins/topic/excellent_projects/new.js.erb @@ -0,0 +1,2 @@ +$("#excellent-project-modals").html("<%= j render(partial: 'admins/topic/excellent_projects/form_modal', locals: {type: 'create'}) %>") +$(".excellent-project-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/experience_forums/_form_modal.html.erb b/app/views/admins/topic/experience_forums/_form_modal.html.erb new file mode 100644 index 000000000..971b8ca51 --- /dev/null +++ b/app/views/admins/topic/experience_forums/_form_modal.html.erb @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/app/views/admins/topic/experience_forums/_list.html.erb b/app/views/admins/topic/experience_forums/_list.html.erb new file mode 100644 index 000000000..b6f5e91fc --- /dev/null +++ b/app/views/admins/topic/experience_forums/_list.html.erb @@ -0,0 +1,33 @@ + + + + + + + + + + + + + <% if experience_forums.present? %> + <% experience_forums.each_with_index do |experience_forum, index| %> + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题跳转地址帖子ID排序等级操作
    <%= list_index_no((params[:page] || 1).to_i, index) %><%= experience_forum.title %><%= experience_forum.url %><%= experience_forum.uuid %><%= experience_forum.order_index %> + <%= link_to "编辑", edit_admins_topic_experience_forum_path(experience_forum), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_experience_forum_path(experience_forum), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: experience_forums } %> \ No newline at end of file diff --git a/app/views/admins/topic/experience_forums/edit.js.erb b/app/views/admins/topic/experience_forums/edit.js.erb new file mode 100644 index 000000000..5684a1b1f --- /dev/null +++ b/app/views/admins/topic/experience_forums/edit.js.erb @@ -0,0 +1,2 @@ +$("#experience-forum-modals").html("<%= j render(partial: 'admins/topic/experience_forums/form_modal', locals: {type: 'update'}) %>") +$(".experience-forum-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/experience_forums/index.html.erb b/app/views/admins/topic/experience_forums/index.html.erb new file mode 100644 index 000000000..e66738762 --- /dev/null +++ b/app/views/admins/topic/experience_forums/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('经验分享管理') %> +<% end %> + +
    + <%= form_tag(admins_topic_experience_forums_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_experience_forum_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + <%= render partial: 'admins/topic/experience_forums/list', locals: { experience_forums: @experience_forums } %> +
    +
    +
    diff --git a/app/views/admins/topic/experience_forums/index.js.erb b/app/views/admins/topic/experience_forums/index.js.erb new file mode 100644 index 000000000..9653cd9a8 --- /dev/null +++ b/app/views/admins/topic/experience_forums/index.js.erb @@ -0,0 +1 @@ +$('.experience-forum-list-container').html("<%= j( render partial: 'admins/topic/experience_forums/list', locals: { experience_forums: @experience_forums } ) %>"); \ No newline at end of file diff --git a/app/views/admins/topic/experience_forums/new.js.erb b/app/views/admins/topic/experience_forums/new.js.erb new file mode 100644 index 000000000..5020e9ed1 --- /dev/null +++ b/app/views/admins/topic/experience_forums/new.js.erb @@ -0,0 +1,2 @@ +$("#experience-forum-modals").html("<%= j render(partial: 'admins/topic/experience_forums/form_modal', locals: {type: 'create'}) %>") +$(".experience-forum-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/pinned_forums/_form_modal.html.erb b/app/views/admins/topic/pinned_forums/_form_modal.html.erb new file mode 100644 index 000000000..45c6eb8ec --- /dev/null +++ b/app/views/admins/topic/pinned_forums/_form_modal.html.erb @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/app/views/admins/topic/pinned_forums/_list.html.erb b/app/views/admins/topic/pinned_forums/_list.html.erb new file mode 100644 index 000000000..9169b6a20 --- /dev/null +++ b/app/views/admins/topic/pinned_forums/_list.html.erb @@ -0,0 +1,33 @@ + + + + + + + + + + + + + <% if pinned_forums.present? %> + <% pinned_forums.each_with_index do |pinned_forum, index| %> + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号标题跳转地址帖子ID排序等级操作
    <%= list_index_no((params[:page] || 1).to_i, index) %><%= pinned_forum.title %><%= pinned_forum.url %><%= pinned_forum.uuid %><%= pinned_forum.order_index %> + <%= link_to "编辑", edit_admins_topic_pinned_forum_path(pinned_forum), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_pinned_forum_path(pinned_forum), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %> +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: pinned_forums } %> \ No newline at end of file diff --git a/app/views/admins/topic/pinned_forums/edit.js.erb b/app/views/admins/topic/pinned_forums/edit.js.erb new file mode 100644 index 000000000..77875c679 --- /dev/null +++ b/app/views/admins/topic/pinned_forums/edit.js.erb @@ -0,0 +1,2 @@ +$("#pinned-forum-modals").html("<%= j render(partial: 'admins/topic/pinned_forums/form_modal', locals: {type: 'update'}) %>") +$(".pinned-forum-change-modal").modal('show'); \ No newline at end of file diff --git a/app/views/admins/topic/pinned_forums/index.html.erb b/app/views/admins/topic/pinned_forums/index.html.erb new file mode 100644 index 000000000..d6cf788b6 --- /dev/null +++ b/app/views/admins/topic/pinned_forums/index.html.erb @@ -0,0 +1,18 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('精选文章管理') %> +<% end %> + +
    + <%= form_tag(admins_topic_pinned_forums_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_pinned_forum_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
    + +
    + <%= render partial: 'admins/topic/pinned_forums/list', locals: { pinned_forums: @pinned_forums } %> +
    +
    +
    diff --git a/app/views/admins/topic/pinned_forums/index.js.erb b/app/views/admins/topic/pinned_forums/index.js.erb new file mode 100644 index 000000000..78d1a240a --- /dev/null +++ b/app/views/admins/topic/pinned_forums/index.js.erb @@ -0,0 +1 @@ +$('.pinned-forum-list-container').html("<%= j( render partial: 'admins/topic/pinned_forums/list', locals: { pinned_forums: @pinned_forums } ) %>"); \ No newline at end of file diff --git a/app/views/admins/topic/pinned_forums/new.js.erb b/app/views/admins/topic/pinned_forums/new.js.erb new file mode 100644 index 000000000..1069707c0 --- /dev/null +++ b/app/views/admins/topic/pinned_forums/new.js.erb @@ -0,0 +1,2 @@ +$("#pinned-forum-modals").html("<%= j render(partial: 'admins/topic/pinned_forums/form_modal', locals: {type: 'create'}) %>") +$(".pinned-forum-change-modal").modal('show'); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 8ea18375e..146cb4913 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -677,6 +677,16 @@ Rails.application.routes.draw do namespace :admins do mount Sidekiq::Web => '/sidekiq' get '/', to: 'dashboards#index' + namespace :topic do + resources :activity_forums + resources :banners + resources :cards + resources :cooperators + resources :excellent_projects + resources :experience_forums + resources :pinned_forums + end + resources :project_statistics, only: [:index] do collection do get :visits_static diff --git a/db/migrate/20211102065736_create_topics.rb b/db/migrate/20211102065736_create_topics.rb index 57f21a0ac..f94ecacd1 100644 --- a/db/migrate/20211102065736_create_topics.rb +++ b/db/migrate/20211102065736_create_topics.rb @@ -4,7 +4,6 @@ class CreateTopics < ActiveRecord::Migration[5.2] t.string :type t.string :title t.integer :uuid - t.string :image_url t.string :url t.integer :order_index end