change title's editor to ckeditor.
This commit is contained in:
parent
12ece8e7e9
commit
dfbc9aa879
|
@ -1,5 +1,5 @@
|
|||
class WebResourcesController < ApplicationController
|
||||
|
||||
require 'nokogiri'
|
||||
def index
|
||||
links = WebLink.where(:title.ne => "").can_display.filter_by_categories
|
||||
web_link = links.collect do |link|
|
||||
|
@ -14,9 +14,14 @@ class WebResourcesController < ApplicationController
|
|||
elsif link.link_open == "local"
|
||||
target = "_self"
|
||||
end
|
||||
|
||||
doc = Nokogiri::HTML(link.title.to_s)
|
||||
text = doc.css("body")[0].text rescue ""
|
||||
if text.blank? && doc.css("img").count != 0
|
||||
text = doc.css("img").map{|img| img.attr("alt") rescue ""}.select{|t| t.present?}.first
|
||||
end
|
||||
{
|
||||
"title" => link.title,
|
||||
"title_text" => text,
|
||||
"context" => link.context,
|
||||
"statuses" => statuses,
|
||||
"category" => link.category.title,
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
<label class="control-label muted"><%= t(:title) %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@link.title_translations[locale] rescue nil) %>
|
||||
<%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t(:title), value: (@link.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<div class="widget-link widget1">
|
||||
<h3 class="widget-title">
|
||||
<span>{{widget-title}}</span>
|
||||
</h3>
|
||||
<ul class="list-unstyled" data-level="0" data-list="web_link">
|
||||
<li class="widget-content">
|
||||
<a class="widget-content-title" href="{{link_to_show}}" target="_blank" title="{{title_text}}">{{title}}</a>
|
||||
<span data-list="statuses" data-level="1">
|
||||
<span class="label status {{status-class}}">{{status}}</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"frontend": [
|
||||
{
|
||||
"filename" : "web_res_index1",
|
||||
"name" : {
|
||||
"zh_tw" : "1. 列表 ( 模組標題, 連結, 連結說明 )",
|
||||
"en" : "1. List (widget-title, link, link description)"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
},
|
||||
{
|
||||
"filename" : "web_res_index2",
|
||||
"name" : {
|
||||
"zh_tw" : "2. 三欄式列表 ( 模組標題, 連結, 連結說明 )",
|
||||
"en" : "2. 3 column List (widget-title, link, link description)"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
}
|
||||
],
|
||||
"widgets" : [
|
||||
{
|
||||
"filename" : "web_res_widget1",
|
||||
"name" : {
|
||||
"zh_tw" : "1. 列表 ( 模組標題, 連結 )",
|
||||
"en" : "1. List (widget-title, link)"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
|
@ -0,0 +1,17 @@
|
|||
<div class="index-link index1">
|
||||
<h1 class="index-title">
|
||||
<span>{{page-title}}</span>
|
||||
</h1>
|
||||
<ul class="list-unstyled" data-list="web_link" data-level="0">
|
||||
<li class="index-content">
|
||||
<h4>
|
||||
<a class="index-content-title" href="{{link_to_show}}" target="_blank" title="{{title_text}}">{{title}}</a>
|
||||
<span data-list="statuses" data-level="1">
|
||||
<span class="label status {{status-class}}">{{status}}</span>
|
||||
</span>
|
||||
</h4>
|
||||
<small class="index-context">{{context}}</small>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{pagination_goes_here}}
|
|
@ -0,0 +1,17 @@
|
|||
<div class="index-link index2">
|
||||
<h1 class="index-title">
|
||||
<span>{{page-title}}</span>
|
||||
</h1>
|
||||
<ul class="list-unstyled" data-list="web_link" data-level="0">
|
||||
<li class="index-content col-md-4 col-sm-4">
|
||||
<h4>
|
||||
<a class="index-content-title" href="{{link_to_show}}" target="_blank" title="{{title_text}}">{{title}}</a>
|
||||
<span data-list="statuses" data-level="1">
|
||||
<span class="label status {{status-class}}">{{status}}</span>
|
||||
</span>
|
||||
</h4>
|
||||
<small class="index-context">{{context}}</small>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{pagination_goes_here}}
|
|
@ -2,7 +2,22 @@ $:.push File.expand_path("../lib", __FILE__)
|
|||
|
||||
# Maintain your gem's version:
|
||||
require "web_resource/version"
|
||||
|
||||
app_path = File.expand_path(__dir__)
|
||||
template_path = ENV['PWD'] + '/app/templates'
|
||||
all_template = Dir.glob(template_path+'/*/')
|
||||
puts 'copying module'
|
||||
all_template.each do |folder|
|
||||
if !folder.include?('mobile')
|
||||
if folder.split('/')[-1] != 'mobile' && Dir.exist?("#{folder}/modules/")
|
||||
begin
|
||||
system ('cp -r '+ app_path + '/modules/. ' + folder+'/modules/.')
|
||||
puts "Updating websource to #{folder}"
|
||||
rescue
|
||||
puts "error updating websource in #{folder}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "web_resource"
|
||||
|
|
Loading…
Reference in New Issue