diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb
index 7433967..eefdc1b 100644
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -335,6 +335,12 @@ class CmsController < MyProfileController
end
end
+ def search
+ query = params[:q]
+ results = query.blank? ? [] : profile.articles.published.find_by_contents(query)
+ render :text => results.map { |item| { 'title' => item.title, 'url' => url_for(item.url), :icon => icon_for_article(item), :content_type => item.mime_type }}.to_json, :content_type => 'application/json'
+ end
+
protected
def record_coming
diff --git a/app/views/cms/_textile_media.rhtml b/app/views/cms/_textile_media.rhtml
new file mode 100644
index 0000000..1bab4b6
--- /dev/null
+++ b/app/views/cms/_textile_media.rhtml
@@ -0,0 +1,55 @@
+
+
+
diff --git a/app/views/cms/edit.rhtml b/app/views/cms/edit.rhtml
index 1d2f977..e5a7806 100644
--- a/app/views/cms/edit.rhtml
+++ b/app/views/cms/edit.rhtml
@@ -52,5 +52,8 @@
<% if environment.enabled?('media_panel') && [TinyMceArticle, Event, EnterpriseHomepage].any?{|klass| @article.kind_of?(klass)} %>
<%= render :partial => 'media_listing' %>
<% end %>
+<% if @article.is_a?(TextileArticle) %>
+ <%= render :partial => 'textile_media' %>
+<% end %>
diff --git a/public/javascripts/article.js b/public/javascripts/article.js
index ff3639c..7eb600b 100644
--- a/public/javascripts/article.js
+++ b/public/javascripts/article.js
@@ -1,4 +1,4 @@
-(function($) {
+jQuery(function($) {
$(".lead-button").live('click', function(){
article_id = this.getAttribute("article_id");
$(this).toggleClass('icon-add').toggleClass('icon-remove');
@@ -10,4 +10,42 @@
$('#article-body-field').slideToggle();
return false;
})
-})(jQuery)
+
+ $("#textile-quickref-show").click(function(){
+ $('#textile-quickref-hide').show();
+ $(this).hide();
+ $('#textile-quickref').slideToggle();
+ return false;
+ })
+ $("#textile-quickref-hide").click(function(){
+ $('#textile-quickref-show').show();
+ $(this).hide();
+ $('#textile-quickref').slideToggle();
+ return false;
+ })
+ function insert_items(items, selector) {
+ var html_for_items = '';
+ $.each(items, function(i, item) {
+ if (item.content_type && item.content_type.match(/^image/)) {
+ html_for_items += '
' + item.title + '';
+ } else {
+ html_for_items += '' + item.title + '';
+ }
+ });
+ $(selector).html(html_for_items);
+ }
+ $('#media-search-button').click(function() {
+ var query = '*' + $('#media-search-query').val() + '*';
+ var $button = $(this);
+ $button.toggleClass('icon-loading');
+ $.get($(this).parent().attr('action'), { 'q': query }, function(data) {
+ $button.toggleClass('icon-loading');
+ insert_items(data, '#media-search-results ul');
+ if (data.length && data.length > 0) {
+ $('#media-search-results').slideDown();
+ }
+ });
+ return false;
+ });
+
+});
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 47c3ac0..3330a86 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -3369,6 +3369,52 @@ div.with_media_panel .formfield input {
width: 100%;
}
+/* Textile sidebar */
+
+.textile-editor-sidebar {
+ position: absolute;
+ width: 380px;
+ right: 20px;
+ top: 70px;
+}
+
+.textile-editor-sidebar-box {
+ background: #eeeeec;
+ border: 1px solid #d3d7cf;
+ padding: 10px 10px 0px 10px;
+ margin-bottom: 10px;
+}
+.textile-editor-sidebar-box p {
+ margin-top: 0px;
+}
+.textile-editor-sidebar code,
+.textile-editor-sidebar pre {
+ border: 1px solid #d3d7cf;
+ color: black;
+ padding: 2px;
+}
+.textile-editor-sidebar .icon-loading {
+ background-image: url(../images/loading-small.gif);
+}
+.textile-editor-sidebar #media-search-results ul {
+ padding: 0px;
+ list-style: none;
+}
+.textile-editor-sidebar #media-search-results li {
+ background-repeat: no-repeat;
+ background-position: 0px 0px;
+ padding-left: 20px;
+ padding-top: 2px;
+ padding-bottom: 2px;
+ border: none;
+ margin-bottom: 2px;
+}
+.textile-editor-sidebar #media-search-results li:hover {
+ background-color: transparent;
+ border: none;
+}
+
+
/* ==> public/stylesheets/controller_contact.css <== */
/*** SELECT CITY ***/
diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb
index 850bf8b..e5ede13 100644
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -1618,4 +1618,17 @@ class CmsControllerTest < Test::Unit::TestCase
end
end
+ should 'search for content for inclusion in articles' do
+ file = UploadedFile.create!(:profile => @profile, :uploaded_data => fixture_file_upload('files/test.txt', 'text/plain'))
+ get :search, :profile => @profile.identifier, :q => 'test.txt'
+ assert_match /test.txt/, @response.body
+ assert_equal 'application/json', @response.content_type
+
+ data = eval(@response.body.gsub('":', '"=>'))
+ assert_equal 'test.txt', data.first['title']
+ assert_match /\/testinguser\/test.txt$/, data.first['url']
+ assert_match /text/, data.first['icon']
+ assert_match /text/, data.first['content_type']
+ end
+
end
--
libgit2 0.21.2