diff --git a/controllers/colab_integration_plugin_controller.rb b/controllers/colab_integration_plugin_controller.rb new file mode 100644 index 0000000..21b29fc --- /dev/null +++ b/controllers/colab_integration_plugin_controller.rb @@ -0,0 +1,12 @@ +class ColabIntegrationPluginController < ApplicationController + def index + { + "total" => environment.profiles.count, + "profiles" => [ + environment.profiles.each do |profile| + profile.attr_to_json + end + ] + }.to_json + end +end \ No newline at end of file diff --git a/lib/colab_integration_plugin.rb b/lib/colab_integration_plugin.rb new file mode 100644 index 0000000..d89834f --- /dev/null +++ b/lib/colab_integration_plugin.rb @@ -0,0 +1,10 @@ +class ColabIntegrationPlugin < Noosfero::Plugin + + def self.plugin_name + "Colab Integration Plugin" + end + + def self.plugin_description + _("A plugin that offers noosfero's data for Colab Integration.") + end +end diff --git a/lib/ext/profile.rb b/lib/ext/profile.rb new file mode 100644 index 0000000..aa66a26 --- /dev/null +++ b/lib/ext/profile.rb @@ -0,0 +1,20 @@ +require_dependency 'profile' + +class Profile + def attr_to_json + { + "type" => "#{self.type}", + "data" => { + "id" => "#{self.id}", + "identifier" => "#{self.identifier}", + "name" => "#{self.name}", + "description" => "#{self.description}" + }, + # "articles" => [ + # self.articles.each do |article| + # { article.attr_to_json } + # end + # ] + }.to_json + end +end -- libgit2 0.21.2