diff --git a/app/views/story_ideas/_form.html.erb b/app/views/story_ideas/_form.html.erb index f2c04b8c1..e90bfd321 100644 --- a/app/views/story_ideas/_form.html.erb +++ b/app/views/story_ideas/_form.html.erb @@ -14,6 +14,17 @@ <% end %> <%= render 'shared/errors', resource: story_idea if story_idea.errors.any? %> <%# = f.object.errors.full_messages %> + + +
+
+ <%= link_to "/documents/tips_for_sharing_impactful_stories.pdf", target: "_blank", class: "inline-flex items-center text-blue-600 hover:text-blue-800 font-bold" do %> + <%= image_tag "info-icon.png", alt: "Info", class: "w-5 h-5 mr-2" %> + Download Story Tips PDF + <% end %> +
+
+ <%# = f.input :title, diff --git a/db/seeds.rb b/db/seeds.rb index 50862a25b..f5203dee7 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -169,3 +169,6 @@ metadata.categories.find_or_create_by!(name: category_name) end end + +puts "Downloading seed resources (PDFs, images)..." +Rake::Task['seed:resources'].invoke diff --git a/lib/tasks/seed_resources.rake b/lib/tasks/seed_resources.rake new file mode 100644 index 000000000..374932f11 --- /dev/null +++ b/lib/tasks/seed_resources.rake @@ -0,0 +1,54 @@ +namespace :seed do + desc "Download seed resources (PDFs, images) from external sources" + task resources: :environment do + require 'open-uri' + + puts "Downloading seed resources..." + + # Create directories if they don't exist + FileUtils.mkdir_p(Rails.root.join('public', 'documents')) + FileUtils.mkdir_p(Rails.root.join('public', 'images')) + + # Download Tips for Sharing Impactful Stories PDF + pdf_path = Rails.root.join('public', 'documents', 'tips_for_sharing_impactful_stories.pdf') + unless File.exist?(pdf_path) && File.size(pdf_path) > 0 + puts "Downloading Tips for Sharing Impactful Stories PDF..." + begin + URI.open('https://res.cloudinary.com/a-window-between-worlds/image/upload/v1750730476/Tips_for_Sharing_Impactful_Stories_lkuime.pdf') do |remote| + File.open(pdf_path, 'wb') do |local| + local.write(remote.read) + end + end + puts "✓ Downloaded tips_for_sharing_impactful_stories.pdf" + rescue => e + puts "⚠ Warning: Failed to download PDF: #{e.message}" + puts " You can manually download from:" + puts " https://res.cloudinary.com/a-window-between-worlds/image/upload/v1750730476/Tips_for_Sharing_Impactful_Stories_lkuime.pdf" + end + else + puts "✓ tips_for_sharing_impactful_stories.pdf already exists" + end + + # Download info icon + icon_path = Rails.root.join('public', 'images', 'info-icon.png') + unless File.exist?(icon_path) && File.size(icon_path) > 0 + puts "Downloading info icon..." + begin + URI.open('https://stories.awbw.org/wp-content/uploads/2021/08/info-1.png') do |remote| + File.open(icon_path, 'wb') do |local| + local.write(remote.read) + end + end + puts "✓ Downloaded info-icon.png" + rescue => e + puts "⚠ Warning: Failed to download icon: #{e.message}" + puts " You can manually download from:" + puts " https://stories.awbw.org/wp-content/uploads/2021/08/info-1.png" + end + else + puts "✓ info-icon.png already exists" + end + + puts "\nSeed resources setup complete!" + end +end diff --git a/public/documents/README.md b/public/documents/README.md new file mode 100644 index 000000000..886d63347 --- /dev/null +++ b/public/documents/README.md @@ -0,0 +1,41 @@ +# Documents Directory + +This directory contains downloadable resources for the application. + +## Automatic Setup + +Run the seed resources rake task to automatically download all required files: + +```bash +bundle exec rake seed:resources +``` + +This task is also automatically run when you execute `bin/rails db:seed`. + +## Manual Setup + +If automatic download fails or you prefer manual download: + +### 1. Tips for Sharing Impactful Stories PDF + +Download from Cloudinary and place in this directory: + +```bash +curl -L "https://res.cloudinary.com/a-window-between-worlds/image/upload/v1750730476/Tips_for_Sharing_Impactful_Stories_lkuime.pdf" -o public/documents/tips_for_sharing_impactful_stories.pdf +``` + +Original URL: https://res.cloudinary.com/a-window-between-worlds/image/upload/v1750730476/Tips_for_Sharing_Impactful_Stories_lkuime.pdf + +### 2. Info Icon + +Download the info icon and place in `public/images/`: + +```bash +curl -L "https://stories.awbw.org/wp-content/uploads/2021/08/info-1.png" -o public/images/info-icon.png +``` + +Original URL: https://stories.awbw.org/wp-content/uploads/2021/08/info-1.png + +## Usage + +These files are referenced in the story ideas form (`app/views/story_ideas/_form.html.erb`) to provide helpful tips to users when sharing stories. diff --git a/public/documents/tips_for_sharing_impactful_stories.pdf b/public/documents/tips_for_sharing_impactful_stories.pdf new file mode 100644 index 000000000..e69de29bb diff --git a/public/images/info-icon.png b/public/images/info-icon.png new file mode 100644 index 000000000..e69de29bb