diff --git a/lib/tasks/main_data.rake b/lib/tasks/main_data.rake index 936195b..793ec38 100644 --- a/lib/tasks/main_data.rake +++ b/lib/tasks/main_data.rake @@ -4,145 +4,15 @@ namespace :main_data do desc "Create the main community and its contents" task :populate => :environment do - Rake::Task["main_data:community"].invoke Rake::Task["templates:create:all"].invoke + Rake::Task["software:create_licenses"].invoke + Rake::Task["software:create_categories"].invoke + Rake::Task["software:create_sample_softwares"].invoke end desc "Create the main community and its contents" task :all => :environment do - Rake::Task["main_data:destroy"].invoke Rake::Task["templates:destroy"].invoke - Rake::Task["software:create_categories"].invoke Rake::Task["main_data:populate"].invoke end - - desc "Create the main community" - task :community => :environment do - Environment.all.each do |env| - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") - identifier = "spb" - community = Community.create!(:name => "SPB", :identifier => identifier) - community.layout_template = "leftbar" - - box1 = community.boxes.where(:position => 1).first - box2 = community.boxes.where(:position => 2).first - box3 = community.boxes.where(:position => 3).first - - box1.blocks.destroy_all - box2.blocks.destroy_all - box3.blocks.destroy_all - - community.save! - puts "SPB succesfully created!" - - main_block = MainBlock.new - main_block.position = 1 - main_block.save! - box1.blocks << main_block - box1.save! - puts "MainBlock successfully added to SPB!" - - generate_fixed_blocks(community) - - generate_article(community, Blog, {name: "Notícias", slug: "noticias", published: true, accept_comments: true, notify_comments: true, license_id: 1, body: "", accept_comments: false, posts_per_page: 5}, true) - generate_article(community, TinyMceArticle, {name: "Sobre o Portal", slug: "sobre-o-portal", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) - generate_article(community, TinyMceArticle, {name: "Publique seu software", slug: "publique-seu-software", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) - generate_article(community, TinyMceArticle, {name: "Inicie um projeto", slug: "inicie-um-projeto", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) - generate_article(community, TinyMceArticle, {name: "Entenda o que é", slug: "entenda-o-que-e", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) - generate_article(community, TinyMceArticle, {name: "Ajuda", slug: "ajuda", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) - generate_article(community, TinyMceArticle, {name: "Contato", slug: "contato", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) - end - end - end - - desc "Create the home page blocks" - task :home => :environment do - Environment.all.each do |env| - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") - identifier = "spb" - - box2 = env.boxes.where(:position => 2).first - box2.blocks.destroy_all - - generate_fixed_blocks(env) - end - end - end - - desc "Destroy all main content created by this namespace" - task :destroy => :environment do - Environment.all.each do |env| - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") - Community["spb"].destroy unless Community["spb"].nil? - puts "Main Community destoyed with success!" - end - end - end - - private - - def generate_article(software, klass, params, home_page = false) - article = klass.new(params) - article.body = params[:body] - - software.articles << article - if home_page - software.home_page = article - end - - software.save! - - puts "#{params[:name]} #{klass} successfully created!" - end - - def generate_fixed_blocks(profile) - identifier = "spb" - - box2 = profile.boxes.where(:position => 2).first - - first_link_list_block = LinkListBlock.new - first_link_list_block.position = 3 - first_link_list_block.display = "always" - first_link_list_block.title = "Portal do SPB" - first_link_list_block.fixed = true - first_link_list_block.save! - - first_link_list_block.links << {:icon => "no-icon", :name => "Sobre o Portal", :address => "/#{identifier}/sobre-o-portal", :target => "_self"} - first_link_list_block.links << {:icon => "no-icon", :name => "Notícias", :address => "/#{identifier}/noticias", :target => "_self"} - first_link_list_block.save! - box2.blocks << first_link_list_block - box2.save! - puts "First LinkListBlock successfully added to software!" - - second_link_list_block = LinkListBlock.new - second_link_list_block.position = 2 - second_link_list_block.display = "always" - second_link_list_block.title = "Software Público" - second_link_list_block.fixed = true - second_link_list_block.save! - - second_link_list_block.links << {:icon => "no-icon", :name => "Entenda o que é", :address => "/#{identifier}/entenda-o-que-e", :target => "_self"} - second_link_list_block.links << {:icon => "no-icon", :name => "Inicie um projeto", :address => "/#{identifier}/inicie-um-projeto", :target => "_self"} - second_link_list_block.links << {:icon => "no-icon", :name => "Publique seu software", :address => "/#{identifier}/publique-seu-software", :target => "_self"} - second_link_list_block.save! - box2.blocks << second_link_list_block - box2.save! - puts "Second LinkListBlock successfully added to software!" - - third_link_list_block = LinkListBlock.new - third_link_list_block.position = 1 - third_link_list_block.display = "always" - third_link_list_block.title = "" - third_link_list_block.fixed = true - third_link_list_block.save! - - third_link_list_block.links << {:icon => "no-icon", :name => "Catálogo de Software Público", :address => "/search/software_infos", :target => "_self"} - third_link_list_block.links << {:icon => "no-icon", :name => "Comunidades", :address => "/search/communities", :target => "_self"} - third_link_list_block.links << {:icon => "no-icon", :name => "Ajuda", :address => "/#{identifier}/ajuda", :target => "_self"} - - third_link_list_block.save! - box2.blocks << third_link_list_block - box2.save! - puts "Third LinkListBlock successfully added to software!" - end end diff --git a/lib/tasks/templates.rake b/lib/tasks/templates.rake index 3d90c1e..46ad264 100644 --- a/lib/tasks/templates.rake +++ b/lib/tasks/templates.rake @@ -6,10 +6,7 @@ namespace :templates do desc "Create new templates of software, intitution, person and community" task :all => :environment do - Rake::Task["templates:create:institution"].invoke Rake::Task["templates:create:software"].invoke - Rake::Task["templates:create:people"].invoke - Rake::Task["templates:create:community"].invoke end desc "Create new templates of software" @@ -24,350 +21,22 @@ namespace :templates do software.layout_template = "default" software.is_template = true - - box1 = software.boxes.where(:position => 1).first - box1.blocks.destroy_all - software.save! - - #This box is going to be used for fixed blocks - box2 = software.boxes.where(:position => 2).first - box2.blocks.destroy_all software.save! - box3 = software.boxes.where(:position => 3).first - box3.blocks.destroy_all - software.save! - puts "Software successfully created!" - - categories_block = CategoriesAndTagsBlock.new - categories_block.position = 4 - categories_block.display = "home_page_only" - categories_block.save! - box1.blocks << categories_block - box1.save! - puts "CategoriesAndTagsBlock successfully added to software!" - - main_block = MainBlock.new - main_block.position = 3 - main_block.save! - box1.blocks << main_block - box1.save! - - download_block = DownloadBlock.new - download_block.position = 2 - download_info = Hash.new - download_info[:name] = "Versão X.Y" - download_info[:link] = "#" - download_info[:software_description] = "(Windows X, Ubuntu Y, Debian Z)" - download_info[:version_news] = "#" - download_block.downloads << download_info - download_block.display = "home_page_only" - download_block.save! - box1.blocks << download_block - box1.save! - puts "DownloadBlock successfully added to software!" - - software_information_block = SoftwareInformationBlock.new - software_information_block.position = 1 - software_information_block.display = "home_page_only" - software_information_block.save! - box1.blocks << software_information_block - box1.save! - puts "SoftwareInformation successfully added to software!" - - puts "Software Main Box successfully created!" - - - members_block = MembersBlock.new - members_block.position = 6 - members_block.display = "except_home_page" - members_block.name = "" - members_block.address = "" - members_block.visible_role = "" - members_block.limit = 6 - members_block.prioritize_profiles_with_image = true - members_block.show_join_leave_button = false - members_block.title = "Equipe" - - members_block.save! - box3.blocks << members_block - box3.save! - - another_link_list_block = LinkListBlock.new - another_link_list_block.position = 5 - another_link_list_block.display = "always" - another_link_list_block.title = "Participe" - links = [{:icon => "", :name => "Lista de E-mails", :address => "http://beta.softwarepublico.gov.br/archives/thread/", :target => "_self"}, {:icon => "no-icon", :name => "Comunidade", :address => "/profile/{profile}", :target => "_self"}, {:icon => "", :name => "Blog", :address => "/{profile}/blog", :target => "_self"}, {:icon => "", :name => "Convide Amigos", :address => "/profile/{profile}/invite/friends", :target => "_self"}] - - another_link_list_block.save! - box3.blocks << another_link_list_block - another_link_list_block.update_attributes(:links => links) - box3.save! - puts "LinkListBlock successfully added to software!" - - - repository_block = RepositoryBlock.new - repository_block.position = 4 - repository_block.display = "always" - repository_block.title = "" - - repository_block.save! - box3.blocks << repository_block - box3.save! - puts "RepositoryBlock successfully added to software!" - - link_list_block = LinkListBlock.new - link_list_block.position = 3 - link_list_block.display = "always" - link_list_block.title = "Ajuda" - - link_list_block.save! - link_list_block.links << {:icon => "no-icon", :name => "Download de Versões", :address => "/{profile}/versoes", :target => "_self"} - link_list_block.links << {:icon => "", :name => "Pergutas Frequentes", :address => "/{profile}/perguntas-frequentes", :target => "_self"} - link_list_block.links << {:icon => "no-icon", :name => "README", :address => "/{profile}/versoes-estaveis", :target => "_self"} - link_list_block.links << {:icon => "", :name => "Como Instalar", :address => "/{profile}/tutorial-de-instalacao", :target => "_self"} - link_list_block.links << {:icon => "", :name => "Manuais", :address => "/{profile}/manuais-de-usuario", :target => "_self"} - link_list_block.save! - box3.blocks << link_list_block - box3.save! - puts "LinkListBlock successfully added to software!" - - profile_image_block = ProfileImageBlock.new - profile_image_block.position = 2 - profile_image_block.display = "except_home_page" - profile_image_block.show_name = false - profile_image_block.save! - - box3.blocks << profile_image_block - box3.save! - puts "ProfileImageBlock successfully added to software!" - - statistics_block = StatisticsBlock.new - statistics_block.position = 1 - statistics_block.display = "home_page_only" - statistics_block.save! - box3.blocks << statistics_block - box3.save! - puts "StatisticsBlock successfully added to software!" - puts "MembersBlock successfully added to software!" - puts "Software Box 3 successfully created!" - - generate_article(software, TinyMceArticle, {name: "Perguntas Frequentes", slug: "perguntas-frequentes", published: true, accept_comments: true, notify_comments: true, license_id: 1, body: "
\r\n
\r\n
Texto introdutório à página de instalação. Caso tenha-se uma documento específico que possa ser redundante com esta página, remova está página e mantenha apenas o documento. Neste caso, referencie-o adequadamente na página principal do seu software.
\r\nTexto identificando as dependências e requisitos necessários para a realização da instalação do Software.
\r\nPara demonstrar comandos através de terminais utilize a seguinte formatação:
\r\n\r\n \r\n | \r\n
Crie quantos tópicos forem necessários para melhor explicar a instalação
\r\nExplique todas as configurações necessários para configurar adequadamente outros serviços complementares e do próprio Software.
\r\nExplique os passos para testar se a instalação foi realizada com sucesso.
", license_id: 1}) - - generate_article(software, TinyMceArticle, {name: "Versões", body: "Texto com detalhamento das mudanças que cada versão do software introduziu. Sugere-se que os arquivos aqui linkados sejam colocados dentro da pasta Versões Estáveis.
\r\nDownload da nova versão X.Y.C
\r\nLançada nova versão X.Y.B
\r\nDownload da nova versão X.Y.A
\r\nTexto com explicação detalhada sobre o Software.
\r\nLorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.
\r\nDonec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.
\r\nMorbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.
\r\nPraesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsa
\r\nTexto curto informativo sobre os requisitos mínimos do software.
\r\nDonec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis. Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequa.
\r\nMaiores informações podem ser encontradas na página de instalação.
\r\nTexto informativo sobre as novidades da última versão estável do software. Listar aqui as principais funcionalidades em linhas gerais. Pode-se também ter um link para a página de versões do software, onde terá informações mais detalhadas.
\r\n