wco_email 0.1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/README.txt +129 -0
  3. data/Rakefile +5 -0
  4. data/app/assets/config/wco_email_manifest.js +7 -0
  5. data/app/assets/javascript/vendor-trash/jquery-ui.min.js +13 -0
  6. data/app/assets/javascript/vendor-trash/jquery.fileupload.js +1482 -0
  7. data/app/assets/javascript/vendor-trash/jquery.iframe-transport.js +224 -0
  8. data/app/assets/javascript/vendor-trash/jquery.ui.widget.js +572 -0
  9. data/app/assets/javascript/vendor-trash/summernote-bs4.min.js +3 -0
  10. data/app/assets/javascript/wco_email/application.js +11 -0
  11. data/app/assets/javascript/wco_email/contexts.js +19 -0
  12. data/app/assets/javascript/wco_email/conversations.js +177 -0
  13. data/app/assets/javascript/wco_email/file_upload.js-trash +32 -0
  14. data/app/assets/javascript/wco_email/shared.js +22 -0
  15. data/app/assets/stylesheets/wco_email/application.scss +29 -0
  16. data/app/assets/stylesheets/wco_email/contexts.scss +63 -0
  17. data/app/assets/stylesheets/wco_email/conversations.scss +16 -0
  18. data/app/assets/stylesheets/wco_email/tags.scss +6 -0
  19. data/app/controllers/wco_email/application_controller.rb +16 -0
  20. data/app/controllers/wco_email/contexts_controller.rb +156 -0
  21. data/app/controllers/wco_email/conversations_controller.rb +129 -0
  22. data/app/controllers/wco_email/email_action_templates_controller.rb +77 -0
  23. data/app/controllers/wco_email/email_actions_controller.rb +55 -0
  24. data/app/controllers/wco_email/email_campaigns_controller.rb +73 -0
  25. data/app/controllers/wco_email/email_filters_controller.rb +72 -0
  26. data/app/controllers/wco_email/email_layouts_controller.rb +13 -0
  27. data/app/controllers/wco_email/email_templates_controller.rb +124 -0
  28. data/app/controllers/wco_email/message_stubs_controller.rb +14 -0
  29. data/app/controllers/wco_email/messages_controller.rb +28 -0
  30. data/app/controllers/wco_email/obfuscated_redirects_controller.rb +20 -0
  31. data/app/controllers/wco_email/sessions_controller.rb +19 -0
  32. data/app/controllers/wco_email/unsubscribes_controller.rb +40 -0
  33. data/app/helpers/wco_email/application_helper.rb +20 -0
  34. data/app/jobs/wco_email/message_intake_job.rb +54 -0
  35. data/app/mailers/wco_email/application_mailer.rb +98 -0
  36. data/app/views/202212 Mailchimp Templates/202212 1col fixed-width.html +863 -0
  37. data/app/views/202212 Mailchimp Templates/202212 1col full-width.html +906 -0
  38. data/app/views/202212 Mailchimp Templates/202212 2col fixed-width 2.html +1003 -0
  39. data/app/views/202212 Mailchimp Templates/202212 2col fixed-width.html +1082 -0
  40. data/app/views/202212 Mailchimp Templates/202212 2col full-width 2.html +1053 -0
  41. data/app/views/202212 Mailchimp Templates/202212 2col full-width.html +1147 -0
  42. data/app/views/202212 Mailchimp Templates/202212 3col fixed-width.html +1087 -0
  43. data/app/views/202212 Mailchimp Templates/202212 3col full-width.html +1136 -0
  44. data/app/views/202212 Mailchimp Templates/202212 catalog various-colors-1.html +1223 -0
  45. data/app/views/202212 Mailchimp Templates/202212 educate.html +1080 -0
  46. data/app/views/202212 Mailchimp Templates/202212 follow up.html +1001 -0
  47. data/app/views/202212 Mailchimp Templates/202212 make an announcement.html +1048 -0
  48. data/app/views/202212 Mailchimp Templates/202212 sell-a-product.html +977 -0
  49. data/app/views/202212 Mailchimp Templates/202212 tell a story.html +1168 -0
  50. data/app/views/202212 Mailchimp Templates/202212 theme art-newsletter.html +1612 -0
  51. data/app/views/202212 Mailchimp Templates/202212 theme caribou-xmas.html +856 -0
  52. data/app/views/202212 Mailchimp Templates/202212 theme colorbox.html +1027 -0
  53. data/app/views/202212 Mailchimp Templates/202212 theme competition-invitation.html +918 -0
  54. data/app/views/202212 Mailchimp Templates/202212 theme event-veerle.html +1132 -0
  55. data/app/views/202212 Mailchimp Templates/202212 theme fall-colors.html +1407 -0
  56. data/app/views/202212 Mailchimp Templates/202212 theme gift-giving.html +787 -0
  57. data/app/views/202212 Mailchimp Templates/202212 theme giftgiving-snowmen.html +731 -0
  58. data/app/views/202212 Mailchimp Templates/202212 theme heart-of-flowers.html +795 -0
  59. data/app/views/202212 Mailchimp Templates/202212 theme hero-card.html +915 -0
  60. data/app/views/202212 Mailchimp Templates/202212 theme hero-image.html +1148 -0
  61. data/app/views/202212 Mailchimp Templates/202212 theme monthly-contest.html +967 -0
  62. data/app/views/202212 Mailchimp Templates/202212 theme multiple-event.html +1189 -0
  63. data/app/views/202212 Mailchimp Templates/202212 theme postcard.html +914 -0
  64. data/app/views/202212 Mailchimp Templates/202212 theme snowy-fields.html +733 -0
  65. data/app/views/202212 Mailchimp Templates/202212 theme soft.html +849 -0
  66. data/app/views/202212 Mailchimp Templates/202212 theme sophisticated.html +1079 -0
  67. data/app/views/202212 Mailchimp Templates/202212 theme subtle.html +1218 -0
  68. data/app/views/202212 Mailchimp Templates/202212 theme ticket.html +1015 -0
  69. data/app/views/202212 Mailchimp Templates/202212 theme whale.html +888 -0
  70. data/app/views/202310 Email Templates/_acknowledgement_of_document_receipt.html.erb +23 -0
  71. data/app/views/202310 Email Templates/_support_ticket_created.html.erb +26 -0
  72. data/app/views/layouts/wco_email/application.haml +64 -0
  73. data/app/views/layouts/wco_email/mailbox.haml-trash +62 -0
  74. data/app/views/wco_email/_analytics.erb +16 -0
  75. data/app/views/wco_email/_main_header.haml +31 -0
  76. data/app/views/wco_email/_sidebar.haml +10 -0
  77. data/app/views/wco_email/application_mailer/_footer_unsubscribe.html.erb +24 -0
  78. data/app/views/wco_email/application_mailer/_header_logo.html.erb +12 -0
  79. data/app/views/wco_email/application_mailer/forwarder_notify.html.erb +17 -0
  80. data/app/views/wco_email/contexts/_form.haml +59 -0
  81. data/app/views/wco_email/contexts/_form_reply.haml +27 -0
  82. data/app/views/wco_email/contexts/_header.haml +22 -0
  83. data/app/views/wco_email/contexts/_index.haml +8 -0
  84. data/app/views/wco_email/contexts/edit.haml +8 -0
  85. data/app/views/wco_email/contexts/iframe_src.haml +3 -0
  86. data/app/views/wco_email/contexts/index.haml +51 -0
  87. data/app/views/wco_email/contexts/new.haml +5 -0
  88. data/app/views/wco_email/contexts/show.haml +34 -0
  89. data/app/views/wco_email/contexts/summary.csv.erb +4 -0
  90. data/app/views/wco_email/contexts/summary.haml +16 -0
  91. data/app/views/wco_email/conversations/_actions.haml +21 -0
  92. data/app/views/wco_email/conversations/_search.haml +14 -0
  93. data/app/views/wco_email/conversations/index.haml +43 -0
  94. data/app/views/wco_email/conversations/show.haml +27 -0
  95. data/app/views/wco_email/email_action_templates/_form.haml +45 -0
  96. data/app/views/wco_email/email_action_templates/_header.haml +8 -0
  97. data/app/views/wco_email/email_action_templates/edit.haml +7 -0
  98. data/app/views/wco_email/email_action_templates/index.haml +36 -0
  99. data/app/views/wco_email/email_action_templates/new.haml +9 -0
  100. data/app/views/wco_email/email_action_templates/show.haml +11 -0
  101. data/app/views/wco_email/email_actions/_form.haml +24 -0
  102. data/app/views/wco_email/email_actions/_form_mini.haml-trash +28 -0
  103. data/app/views/wco_email/email_actions/_header.haml +8 -0
  104. data/app/views/wco_email/email_actions/edit.haml +4 -0
  105. data/app/views/wco_email/email_actions/index.haml +31 -0
  106. data/app/views/wco_email/email_actions/new.haml +4 -0
  107. data/app/views/wco_email/email_actions/show.haml +0 -0
  108. data/app/views/wco_email/email_campaigns/_form.haml +33 -0
  109. data/app/views/wco_email/email_campaigns/_header.haml +5 -0
  110. data/app/views/wco_email/email_campaigns/edit.haml +5 -0
  111. data/app/views/wco_email/email_campaigns/index.haml +14 -0
  112. data/app/views/wco_email/email_campaigns/new.haml +5 -0
  113. data/app/views/wco_email/email_campaigns/show.haml +17 -0
  114. data/app/views/wco_email/email_filters/_form.haml +40 -0
  115. data/app/views/wco_email/email_filters/_header.haml +5 -0
  116. data/app/views/wco_email/email_filters/edit.haml +5 -0
  117. data/app/views/wco_email/email_filters/index.haml +48 -0
  118. data/app/views/wco_email/email_filters/new.haml +5 -0
  119. data/app/views/wco_email/email_templates/_form.haml +48 -0
  120. data/app/views/wco_email/email_templates/_form_mini.haml +9 -0
  121. data/app/views/wco_email/email_templates/_form_reply_mini.haml +8 -0
  122. data/app/views/wco_email/email_templates/_form_schedule_mini.haml +11 -0
  123. data/app/views/wco_email/email_templates/_header.haml +6 -0
  124. data/app/views/wco_email/email_templates/_index.haml +26 -0
  125. data/app/views/wco_email/email_templates/_index_expanded.haml +13 -0
  126. data/app/views/wco_email/email_templates/_m20221201react.html.erb +1202 -0
  127. data/app/views/wco_email/email_templates/_m20221222merryxmas.html.erb +766 -0
  128. data/app/views/wco_email/email_templates/_m202309_feedback.html.erb +1161 -0
  129. data/app/views/wco_email/email_templates/_m202309_ror4.html.erb +1068 -0
  130. data/app/views/wco_email/email_templates/_marketing_node_1.html.erb +984 -0
  131. data/app/views/wco_email/email_templates/_marketing_react_1.html +0 -0
  132. data/app/views/wco_email/email_templates/_marketing_react_2.html.erb +749 -0
  133. data/app/views/wco_email/email_templates/_marketing_react_3.html.erb +628 -0
  134. data/app/views/wco_email/email_templates/_marketing_ror_1.html +751 -0
  135. data/app/views/wco_email/email_templates/_marketing_ror_2.html.erb +755 -0
  136. data/app/views/wco_email/email_templates/_marketing_ror_3.html.erb +25 -0
  137. data/app/views/wco_email/email_templates/_marketing_ror_4.html.erb +25 -0
  138. data/app/views/wco_email/email_templates/_marketing_ror_5.html.erb +17 -0
  139. data/app/views/wco_email/email_templates/_marketing_wordpress_1.html +0 -0
  140. data/app/views/wco_email/email_templates/_marketing_wordpress_2.html +0 -0
  141. data/app/views/wco_email/email_templates/_meta.haml +6 -0
  142. data/app/views/wco_email/email_templates/_piousbox_roundborders.html.erb +1007 -0
  143. data/app/views/wco_email/email_templates/_piousbox_social.html.erb +181 -0
  144. data/app/views/wco_email/email_templates/_plain.haml +15 -0
  145. data/app/views/wco_email/email_templates/_rec_resume_shared_with_you.html.erb +39 -0
  146. data/app/views/wco_email/email_templates/_slug-1.html.erb +0 -0
  147. data/app/views/wco_email/email_templates/_slug-2.html.erb +0 -0
  148. data/app/views/wco_email/email_templates/_slug-3.html.erb +0 -0
  149. data/app/views/wco_email/email_templates/_tracking_footer.html.erb +13 -0
  150. data/app/views/wco_email/email_templates/_wasyaco_roundborders.html.erb +686 -0
  151. data/app/views/wco_email/email_templates/_wasyaco_social.html.erb +181 -0
  152. data/app/views/wco_email/email_templates/edit.haml +6 -0
  153. data/app/views/wco_email/email_templates/new.haml +6 -0
  154. data/app/views/wco_email/email_templates/show.haml +11 -0
  155. data/app/views/wco_email/email_templates/show_iframe.haml +2 -0
  156. data/app/views/wco_email/lead_action_templates/_header.haml +7 -0
  157. data/app/views/wco_email/lead_actions/_header.haml +8 -0
  158. data/app/views/wco_email/message_stubs/_index.haml +10 -0
  159. data/app/views/wco_email/messages/_form_reply.haml-trash +17 -0
  160. data/app/views/wco_email/messages/_meta.haml +30 -0
  161. data/app/views/wco_email/messages/show.haml +13 -0
  162. data/app/views/wco_email/messages/show_iframe.haml +5 -0
  163. data/app/views/wco_email/sessions/new.html.erb +4 -0
  164. data/app/views/wco_email/unsubscribes/_header.haml +4 -0
  165. data/app/views/wco_email/unsubscribes/_table.haml +22 -0
  166. data/config/initializers/assets.rb +10 -0
  167. data/config/routes.rb +49 -0
  168. data/lib/tasks/bjjcollective/sitemap.rb +50 -0
  169. data/lib/tasks/db_tasks.rake +12 -0
  170. data/lib/tasks/direct_mail_tasks.rake +35 -0
  171. data/lib/tasks/infinite_shelter/sitemap.rb +25 -0
  172. data/lib/tasks/piousbox/sitemap.rb +80 -0
  173. data/lib/tasks/publish2_wordpress_tasks.rake +54 -0
  174. data/lib/tasks/scrape_reddit_tasks.rake-bk +23 -0
  175. data/lib/tasks/trash/email_tasks.rake-trash +126 -0
  176. data/lib/tasks/trash/sitemap_tasks.rake-trash +146 -0
  177. data/lib/tasks/wasya_co/sitemap.rb +281 -0
  178. data/lib/tasks/wco_email_tasks.rake +117 -0
  179. data/lib/wco_email/README_email_actions.rb +7 -0
  180. data/lib/wco_email/README_email_contexts.rb +7 -0
  181. data/lib/wco_email/engine.rb +8 -0
  182. data/lib/wco_email.rb +19 -0
  183. metadata +493 -0
@@ -0,0 +1,54 @@
1
+
2
+
3
+ require 'httparty'
4
+ require 'json'
5
+
6
+
7
+ def puts! args, label=""
8
+ puts "+++ +++ #{label}"
9
+ puts args.inspect
10
+ end
11
+
12
+ namespace :wordpress do
13
+
14
+ desc 'post to pi_wp'
15
+ task :post_to_pi_wp => :environment do
16
+
17
+ start_date = '2023-01-26'.to_date
18
+ count = 1
19
+ title = "Jan'23 Graphics Gallery"
20
+ gallery_slug = '20230126'
21
+ ## categories
22
+ ## 203 - trees
23
+ ## 197 - jan'23 graphics
24
+ ## 200 - jan'23 NFT's
25
+ categories = 197
26
+
27
+ gallery_url = "https://manager.piousbox.com/api/galleries/view/#{gallery_slug}.json"
28
+ pics = HTTParty.get( gallery_url ).body
29
+ pics = JSON.parse( pics )['gallery']['photos']
30
+ pics.each do |pic|
31
+ response = HTTParty.post("#{ENV['WP_HOST']}/wp-json/wp/v2/posts",
32
+ basic_auth: { username: ENV['WP_USERNAME'], password: ENV['WP_PASSWORD'] },
33
+ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'},
34
+ body: {
35
+ title: "#{title} ##{count}",
36
+ content: "<!--more--><div style='text-align: center'><img src='#{pic['large_url']}' /></div></center>",
37
+ status: 'publish',
38
+ categories: categories,
39
+ date: "#{start_date.to_s}T00:00:00",
40
+ meta: {
41
+ wps_subtitle: "<img src='#{pic['small_url']}' />",
42
+ }
43
+ }.to_json,
44
+ :debug_output => $stdout
45
+ )
46
+ start_date = start_date + 1.day
47
+ count = count + 1
48
+ resp = JSON.parse(response.body)
49
+ puts! resp, 'ze response body'
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,23 @@
1
+ require 'redd'
2
+
3
+ namespace :reddit do
4
+
5
+ desc "reddit crawler 1 - sentiment of gmejungle ?"
6
+ task :crawl_1 => :environment do
7
+ session = Redd.it({
8
+ user_agent: 'Redd:IshBot:v0.0.0',
9
+ client_id: '<>',
10
+ secret: '<>',
11
+ })
12
+
13
+ top = session.subreddit('gmejungle').top
14
+ submission = top[1]
15
+ byebug
16
+ puts! submission.self_text, 'self text'
17
+
18
+ end
19
+
20
+ end
21
+
22
+
23
+
@@ -0,0 +1,126 @@
1
+
2
+ namespace :email do
3
+
4
+ ## Not used until I revisit it. _vp_ 2023-04-02
5
+ desc 'email:churn_mbox mbox_path=<filepath> '
6
+ task churn_mbox: :environment do
7
+
8
+ ## Usage
9
+ if !ENV['mbox_path']
10
+ puts ""
11
+ puts "Usage: email:churn_mbox mbox_path=<filepath> "
12
+ puts ""
13
+ exit 22
14
+ end
15
+
16
+ which_file = ENV['mbox_path']
17
+ message = nil
18
+
19
+ # Tag
20
+ tag_names = [
21
+ File.basename( ENV['mbox_path'], '.*' ),
22
+ "20230302-import",
23
+ ]
24
+ term_ids = tag_names.map do |tag_name|
25
+ tag = WpTag.where( name: tag_name ).first
26
+ tag ||= WpTag.my_create( name: tag_name, taxonomy: 'email_tag' )
27
+ tag.id
28
+ end
29
+
30
+ client = Aws::S3::Client.new({
31
+ region: ::S3_CREDENTIALS[:region],
32
+ access_key_id: ::S3_CREDENTIALS[:access_key_id],
33
+ secret_access_key: ::S3_CREDENTIALS[:secret_access_key] })
34
+
35
+
36
+ File.readlines( which_file, encoding: "ISO8859-1" ).each do |line|
37
+ if (line.match(/\AFrom /))
38
+
39
+ ## @TODO: remove copy-paste [ref-1]
40
+ if message
41
+ the_mail = Mail.new(message)
42
+ filename = the_mail.date.in_time_zone.to_s[0..18].gsub(' ', 'T').gsub(':', '_')
43
+ filename = "#{filename}F#{the_mail.from[0].sub('@', '_').gsub('.', '_')}"
44
+ flag = client.put_object({ bucket: ::S3_CREDENTIALS[:bucket_ses],
45
+ key: filename,
46
+ body: message,
47
+ })
48
+ @stub = ::Office::EmailMessageStub.create({
49
+ object_key: filename,
50
+ object_path: "https://#{::S3_CREDENTIALS[:bucket_ses]}.s3.amazonaws.com/#{filename}",
51
+ state: ::Office::EmailMessageStub::STATE_PENDING,
52
+ term_ids: term_ids,
53
+ })
54
+ if @stub.persisted?
55
+ Ishapi::EmailMessageIntakeJob.perform_later( @stub.id.to_s )
56
+ else
57
+ puts! @stub.errors.full.messages.join(", "), "111 Cannot save this stub: #{@stub.id}."
58
+ end
59
+ print '.'
60
+ end
61
+ message = ''
62
+
63
+ else
64
+ message << line.sub(/^\>From/, 'From')
65
+ end
66
+ end
67
+
68
+ ## @TODO: remove copy-paste [ref-1]
69
+ if message
70
+ the_mail = Mail.new(message)
71
+ filename = the_mail.date.in_time_zone.to_s[0..18].gsub(' ', 'T').gsub(':', '_')
72
+ filename = "#{filename}F#{the_mail.from[0].sub('@', '_').gsub('.', '_')}"
73
+ flag = client.put_object( bucket: ::S3_CREDENTIALS[:bucket_ses],
74
+ key: filename,
75
+ body: message )
76
+ @stub = ::Office::EmailMessageStub.create({
77
+ object_key: filename,
78
+ object_path: "https://#{::S3_CREDENTIALS[:bucket_ses]}.s3.amazonaws.com/#{filename}",
79
+ state: ::Office::EmailMessageStub::STATE_PENDING,
80
+ term_ids: term_ids,
81
+ })
82
+ if @stub.persisted?
83
+ Ishapi::EmailMessageIntakeJob.perform_later( @stub.id.to_s )
84
+ else
85
+ puts! @stub.errors.full.messages.join(", "), "222 Cannot save this stub: #{@stub.id}."
86
+ end
87
+ print '.'
88
+ end
89
+ message = ''
90
+
91
+ puts "ok"
92
+ end
93
+
94
+ ## Not used until I revisit it. _vp_ 2023-04-02
95
+ desc 'after lambda puts object_key in mdb'
96
+ task churn_messages: :environment do
97
+ Office::EmailMessageStub.pending.each do |msg|
98
+ Ishapi::EmailMessageIntakeJob.process_later( msg.id )
99
+ end
100
+ end
101
+
102
+ desc 'be rake email:churn_one key_id=0ijbh58ocnat5oal6iqchn4rosj9q99u3opq37o1'
103
+ task churn_one: :environment do
104
+ object_key = ENV['key_id'] || 'iao4kfrcot6d3pd3hqp9af21e28iev6b5eoi6781'
105
+ stub = MsgStub.find_or_create_by({ object_key: object_key }).update({ state: 'state_pending' })
106
+ stub = MsgStub.find_by({ object_key: object_key })
107
+ EIJ.new.perform( stub.id )
108
+ end
109
+
110
+ desc '2023-09-23 test 2'
111
+ task :churn_leads_20230923 => :environment do
112
+ Office::EmailConversation.all.each do |conv|
113
+ conv.lead_ids.each do |lead_id|
114
+ Office::EmailConversationLead.find_or_create_by({
115
+ email_conversation_id: conv.id,
116
+ lead_id: lead_id,
117
+ })
118
+ print '.'
119
+ end
120
+ puts '^'
121
+ end
122
+ end
123
+
124
+ end
125
+
126
+
@@ -0,0 +1,146 @@
1
+
2
+ require 'httparty'
3
+ require 'json'
4
+
5
+ require_relative './ish/sitemap'
6
+ require_relative './pi/sitemap'
7
+ require_relative './wco/sitemap'
8
+
9
+ def puts! args, label=""
10
+ puts "+++ +++ #{label}"
11
+ puts args.inspect
12
+ end
13
+
14
+ ##
15
+ ## curl https://piousbox.com/index.php?p=2399 -I -H 'Cache-Control: no-cache, no-store'
16
+ ##
17
+
18
+ NAMESPACES = %w| Ish Wco Pi |
19
+
20
+ namespace :sitemap do
21
+
22
+ desc 'be rake sitemap:export namespace=Ish|Pi|Wco [ origin="https://wasyaco.com" ] '
23
+ task :export => :environment do
24
+
25
+ if !ENV['namespace']
26
+ puts "Usage: "
27
+ puts 'be rake sitemap:export namespace=Ish|Pi|Wco [ origin="https://wasyaco.com" ] '
28
+ exit
29
+ end
30
+
31
+ if !NAMESPACES.include?( ENV['namespace'] )
32
+ puts "Available namespaces: "
33
+ puts NAMESPACES
34
+ exit
35
+ end
36
+
37
+ origin = ENV['origin'] || "#{ENV['namespace']}::Sitemap".constantize::DEFAULT_ORIGIN
38
+
39
+ out = "#{ENV['namespace']}::Sitemap".constantize.new.checks.select do |item|
40
+ item[:selector].present? && !item[:private]
41
+ end
42
+ out.each do |check|
43
+ puts "#{origin}#{check[:path]}"
44
+ end
45
+
46
+ end
47
+
48
+ desc 'be rake sitemap:text namespace=Ish|Pi|Wco [ origin="http://wco_local:8088" ] '
49
+ task :test => :environment do
50
+
51
+ if !ENV['namespace']
52
+ puts "Usage: "
53
+ puts 'be rake sitemap:test namespace=Ish|Pi|Wco [ origin="https://wasyaco.com" ] '
54
+ exit
55
+ end
56
+
57
+ if !NAMESPACES.include?( ENV['namespace'] )
58
+ puts "Available namespaces: "
59
+ puts NAMESPACES
60
+ exit
61
+ end
62
+
63
+ results = []
64
+ total_count = 0
65
+ error_count = 0
66
+
67
+ origin = ENV['origin'] || "#{ENV['namespace']}::Sitemap".constantize::DEFAULT_ORIGIN
68
+
69
+ "#{ENV['namespace']}::Sitemap".constantize.new.checks.each do |check|
70
+ total_count += 1
71
+
72
+ # puts "Checking #{check[:path]}:"
73
+ if check[:selector]
74
+ begin
75
+ body = HTTParty.get( "#{origin}#{check[:path]}" ).body
76
+ rescue OpenSSL::SSL::SSLError => err
77
+ results.push "NOT OK [ssl-exception] #{check[:path]}".red
78
+ next
79
+ end
80
+ doc = Nokogiri::HTML( body )
81
+ out = doc.search check[:selector]
82
+ if out.present?
83
+ results.push "OK #{check[:path]}"
84
+ else
85
+ results.push "NOT OK [selector-missing] #{check[:path]}".red
86
+ error_count += 1
87
+ end
88
+
89
+ if check[:meta_description]
90
+ out = doc.search( 'head meta[name="description"]' )[0]['content']
91
+ if check[:meta_description] == out
92
+ results.push "OK #{check[:path]} meta_description"
93
+ else
94
+ results.push "NOT OK [meta-description-missing] #{check[:path]}".red
95
+ error_count += 1
96
+ end
97
+ end
98
+
99
+ elsif check[:redirect_to]
100
+ out = HTTParty.get( "#{origin}#{check[:path]}", follow_redirects: false )
101
+ if( out.headers[:location] == check[:redirect_to] ||
102
+ out.headers[:location] == "#{origin}#{check[:redirect_to]}" )
103
+ results.push "OK #{check[:path]}"
104
+ else
105
+ results.push "NOT OK [redirect-missing] #{check[:path]}".red
106
+
107
+ puts!( out.response, 'response' ) if DEBUG
108
+ # puts!( out.body, 'body' ) if DEBUG
109
+
110
+ error_count += 1
111
+
112
+ puts "NOT OK #{check[:path]}".red
113
+ puts out.headers[:location]
114
+ puts check[:redirect_to]
115
+ end
116
+ else
117
+ results.push "SKIP #{check[:path]}"
118
+ end
119
+
120
+ if check[:selectors]
121
+ check[:selectors].each do |selector|
122
+ body = HTTParty.get( "#{origin}#{check[:path]}" ).body
123
+ doc = Nokogiri::HTML( body )
124
+ out = doc.search selector
125
+ if out.present?
126
+ results.push "OK #{check[:path]} selectors:#{selector}"
127
+ else
128
+ results.push "NOT OK [selectors-missing:#{selector}] #{check[:path]}".red
129
+ error_count += 1
130
+ end
131
+ end
132
+ end
133
+
134
+ end
135
+
136
+ puts "Results:".green
137
+ results.each do |r|
138
+ puts r
139
+ end
140
+ puts "Total count: #{total_count}"
141
+ puts "Error count: #{error_count}"
142
+ end
143
+
144
+ end
145
+
146
+
@@ -0,0 +1,281 @@
1
+
2
+ class Wco::Sitemap
3
+
4
+ DEFAULT_ORIGIN = 'https://wasyaco.com'
5
+
6
+ def checks
7
+ out = [
8
+ # { path: '/shop/investment-opportunities/8-infinite-business-plan.html', selector: '.product-id-8' },
9
+ # ]; tmp = [
10
+
11
+ ##
12
+ ## Digits
13
+ ##
14
+ { path: '/2023q3-issue', redirect_to: '/issues/2023q3-issue' },
15
+ { path: '/32-consulting-services', redirect_to: '/services/consulting' }, ## @TODO: there is no such thing
16
+ { path: '/31-services', redirect_to: '/services/consulting' }, ## @TODO: there is no such thing
17
+
18
+
19
+ { path: '/2022/12/auriculares-tozo-nc2', redirect_to: '/' },
20
+
21
+
22
+ { path: '/2023/03/2023-03-31-site-updates', selector: 'article.wco-id-130' },
23
+ { path: '/2022/12/soporte-portatil-para-laptops', selector: 'article#post-3412' },
24
+ { path: '/2022/12/teclado-plegable-portatil', selector: 'article#post-3417' },
25
+ { path: '/2022/05/20220522-site-updates', selector: 'article.wco-id-141' },
26
+ { path: '/2023/01/2023-01-10-site-updates', selector: 'article.wco-id-133' },
27
+ { path: '/2023/02/firechat-with-an-engineer-what-is-scrum-methodology-in-testing', selector: 'article#post-3731' },
28
+ { path: '/2022/11/creek-enterprise-the-invoicing-tool-2017', selector: 'article#post-3157' },
29
+ { path: '/2023/05/how-to-organize-a-wordpress-blog-into-magazine-like-issues-2', selector: 'article#post-3239' },
30
+ { path: '/2023/04/what-does-it-mean-when-financial-professionals-say-cash-is-a-position', selector: 'article#post-3943' },
31
+ { path: '/2022/12/currently-testing-my-todo-list-should-contain-no-more-than-1-elements', selector: 'article#post-3249' },
32
+ { path: '/2023/08/capistrano-authentication-failed-for-user-ubuntuxx-xxx-xxx-xxx-netsshauthenticationfailed', selector: 'article#post-4376' },
33
+ { path: '/2022/09/20220920-site-updates', selector: 'article.wco-id-140' },
34
+ { path: '/2022/10/20220914-infinite-shelter-updates', selector: 'article.wco-id-139' },
35
+ { path: '/2022/12/samsung-galaxy-a22', selector: 'article#post-3392' },
36
+ { path: '/2022/12/announcement-the-team-adds-ai-assisted-writing-capabilities', selector: 'article#post-2997' },
37
+ # /2023/11/our-corporate-culture
38
+ # /2023/11/learn-gpt-architecture-a-minimal-example
39
+
40
+ # /2022/10/20220904-infinite-shelter-updates
41
+ # /2023/02/202302-site-updates
42
+ # /2022/12/2022-12-06-site-updates
43
+ # /2022/11/2022-11-22-site-updates
44
+ # /2022/11/2022-11-10-site-updates
45
+ # /2022/10/20221013-site-updates
46
+ # /2023/05/20230518-site-updates
47
+ # /2023/01/a-gentle-minimalist-intro-to-machine-learning
48
+
49
+ { path: '/2022/09/sturfee-build-pipeline', selector: 'article.wco-id-100' },
50
+ { path: '/2022/03/bundler-and-private-repositories', selector: 'article.wco-id-112' },
51
+ { path: '/2022/03/ruby-on-rails-allow-parameters-to-have-dot', selector: 'article.wco-id-100' },
52
+ { path: '/2022/03/ruby-on-rails-allow-parameters-to-have-dot/', selector: 'article.wco-id-100' },
53
+ { path: '/2023/04/a-good-looking-css-only-chip', selector: 'article.wco-id-101' },
54
+ { path: '/2023/08/navigating-the-gauntlet-hardships-of-acquiring-technical-talent-for-software-development-startups', selector: 'article.post-4378' },
55
+ { path: '/2023/09/notes-on-naming-conventions', selector: 'article.wco-id-109' },
56
+ { path: '/2023/11/open-source-contribution-drupal-module-consent_popup', selector: 'article[data-history-node-id="154"]' },
57
+
58
+
59
+
60
+ ##
61
+ ## C
62
+ ##
63
+
64
+ { path: '/case-studies', redirect_to: '/categories/case-studies' },
65
+ { path: '/consulting-services', redirect_to: '/services/consulting' },
66
+ { path: '/contact-us', redirect_to: '/contact-us/contact-us-step1' },
67
+ { path: '/contact-us-2', redirect_to: '/contact-us/project-intake' },
68
+ { path: '/contact-us-3', redirect_to: '/contact-us/contact-us-step-1' },
69
+ { path: '/contact-us-4', redirect_to: '/contact-us/contact-us-step-1' },
70
+ { path: '/contact-us/send-message', redirect_to: '/contact-us/project-intake' },
71
+
72
+
73
+ { path: '/careers', selector: 'article[data-history-node-id="124"]' },
74
+ { path: '/careers/submit-resume', selector: 'article[data-history-node-id="124"]' },
75
+ { path: '/categories/2023q3-issue/202305-software-architecture', selector: 'body.category-126' },
76
+ { path: '/categories/2023q2-issue/2023q2-site-updates', selector: 'body.category-112' },
77
+ { path: '/categories/case-studies', selector: '.category-case-studies' },
78
+ { path: '/categories/uncategorized', selector: 'body.category-1' },
79
+ { path: '/contact-us/contact-us-step1', selector: '.contact-us-4-step1', },
80
+ { path: '/contact-us/project-intake',
81
+ # selector: 'article[data-history-node-id="79"]' },
82
+ selector: '#mauticform_wrapper_projectintake',
83
+ },
84
+
85
+ ##
86
+ ## D
87
+ ##
88
+
89
+ { path: '/design-services', redirect_to: '/services/graphic-design' },
90
+ { path: '/dev-js', redirect_to: '/services/javascript-development' },
91
+ { path: '/dev-react', redirect_to: '/services/reactjs-development' },
92
+ { path: '/dev-ror', redirect_to: '/services/ruby-on-rails-web-application-development' },
93
+ { path: '/dev-php', redirect_to: '/services/php-development' },
94
+ { path: '/dev-wp', redirect_to: '/services/wordpress-development' },
95
+
96
+ # /donate
97
+ # /donate/with-paypal
98
+ # /donate/with-email-and-message
99
+
100
+ { path: '/documentation', selector: 'article[data-history-node-id="119"]' },
101
+ { path: '/documentation/basic-setup', selector: 'article[data-history-node-id="119"]' },
102
+
103
+ ##
104
+ ## E
105
+ ##
106
+
107
+ { path: '/es/paginas', selector: 'article[data-history-node-id="102"]' },
108
+ { path: '/es/paginas/terminos-y-condiciones', selector: 'article[data-history-node-id="14"]' },
109
+ { path: '/es/pimsleur-ingles-para-espanol', selector: 'body.page-id-3291', private: true },
110
+
111
+ ##
112
+ ## H
113
+ ##
114
+
115
+ # /hosted-appliances/
116
+ # /hosted-appliances/jenkins
117
+ # /hosted-appliances/matomo-analytics
118
+ # /hosted-appliances/redmine
119
+
120
+ ##
121
+ ## I
122
+ ##
123
+
124
+ { path: '/issues', selector: 'body.page-id-4022' },
125
+ { path: '/issues/2023q3-issue',
126
+ selector: 'article#a2023q3issue',
127
+ selectors: [ 'section.issues-navigator' ],
128
+ meta_description: 'Wasya Co - Application Prototyping & Rapid Software Development',
129
+ },
130
+ { path: '/issues/2023q4-issue',
131
+ selector: 'article#a2023q4issue',
132
+ },
133
+ # /issues/2024q1-issue/newsfeed
134
+
135
+ ##
136
+ ## O
137
+ ##
138
+
139
+ { path: '/our-services-2', redirect_to: '/our-services' },
140
+ { path: '/our-services-reactjs', redirect_to: '/reactjs-development-services' },
141
+ { path: '/our-process', redirect_to: '/our-process-2' },
142
+ { path: '/our-services', redirect_to: '/services' },
143
+ { path: '/our-services/application-layer-development', redirect_to: '/services' },
144
+ # /our-work
145
+
146
+ { path: '/our-process-2', selector: 'article[data-history-node-id="77"]' },
147
+
148
+ ##
149
+ ## P
150
+ ##
151
+
152
+ { path: '/pages/terms-of-service', redirect_to: '/pages/terms-and-conditions' },
153
+ { path: '/project-intake', redirect_to: '/contact-us/project-intake' },
154
+ { path: '/project-intake-1', redirect_to: '/contact-us/project-intake' },
155
+ { path: '/pudeyev-resume-2', redirect_to: '/pudeyev-resume' },
156
+
157
+ { path: '/pages', selector: 'article[data-history-node-id="103"]' },
158
+ { path: '/pages/terms-and-conditions', selector: 'article[data-history-node-id="14"]' },
159
+ { path: '/pages/our-commitment-to-employees-personal-growth-career-growth-and-continuous-learning', selector: 'article[data-history-node-id="104"]' },
160
+ { path: '/pages/privacy-policy', selector: 'article[data-history-node-id="105"]' },
161
+ { path: '/pages/thank-you', selector: 'article[data-history-node-id="106"]' },
162
+ { path: '/pages/vaccine-policy', selector: 'article[data-history-node-id="107"]' },
163
+ { path: '/pages/workplace-policy', selector: 'article[data-history-node-id="108"]' },
164
+
165
+ { path: '/products', selector: 'article[data-history-node-id="92"]' },
166
+ { path: '/products/piousbox-crm', selector: 'article[data-history-node-id="95"]' },
167
+ # { path: '/products/us-business-for-sale', selector: 'article[data-history-node-id="90"]' },
168
+
169
+ { path: '/pudeyev-resume', selector: 'body.page-id-2880' },
170
+
171
+ { path: '/pages/investors', selector: 'article[data-history-node-id="127"]' },
172
+ { path: '/pages/our-team', selector: 'article[data-history-node-id="113"]' },
173
+ { path: '/pages/public-relations', selector: 'article[data-history-node-id="115"]' },
174
+
175
+ ##
176
+ ## S
177
+ ##
178
+
179
+ { path: '/services/ruby-on-rails', redirect_to: '/services/ruby-on-rails-web-application-development' },
180
+
181
+ # /services/ab-testing-ruby-on-rails-a-b
182
+ # /services/59-custom-logo-design.html
183
+ # /services/60-illustration.html
184
+ # /services/64-3d-object-design.html
185
+ # /services/graphic-design
186
+ # /services/single-sign-on - but should really be products, not services.
187
+
188
+ { path: '/services/hosted-appliances', selector: 'article[data-history-node-id="127"]' },
189
+ { path: '/services/owasp-security-audit', selector: 'article[data-history-node-id="88"]' },
190
+
191
+ # /services/web-analytics
192
+ # /services/document-signing
193
+
194
+ { path: '/services', selector: 'article[data-history-node-id="89"]' },
195
+ # { path: '/services/ai-ml-development', selector: '.Service' },
196
+ # { path: '/services/consulting', selector: '.Service' },
197
+ # { path: '/services/design', selector: '.Service' },
198
+ # { path: '/services/javascript-development', selector: '.Service' },
199
+ { path: '/services/php-development', selector: 'article[data-history-node-id="83"]' },
200
+ { path: '/services/reactjs-development', selector: 'article[data-history-node-id="82"]' },
201
+ { path: '/services/ruby-on-rails-web-application-development', selector: 'article[data-history-node-id="99"]' },
202
+ { path: '/services/ssl-certificate-installation-management', selector: 'article[data-history-node-id="21"]' },
203
+ { path: '/services/wordpress-development', selector: 'article[data-history-node-id="20"]' },
204
+
205
+ { path: '/shop', selector: 'body#index' },
206
+ { path: '/shop/3-stl-prints', selector: 'body.category-id-3' },
207
+ { path: '/shop/4-downloads', selector: 'body.category-id-4' },
208
+ { path: '/shop/5-services', selector: 'body.category-id-5' },
209
+ { path: '/shop/downloads/2-victor-pudeyev-resume.html', selector: 'body.product-id-2' },
210
+ { path: '/shop/investment-opportunities/8-infinite-business-plan.html', selector: 'body.product-id-8' },
211
+ { path: '/shop/services/5-mentorship-30min.html', selector: 'body.product-id-5' },
212
+ { path: '/shop/services/6-mentorship-1hr.html', selector: 'body.product-id-6' },
213
+ { path: '/shop/services/7-interview-90min.html', selector: 'body.product-id-7' },
214
+ { path: '/shop/stl-prints/1-stylus-holder.html', selector: 'body.product-id-1' },
215
+
216
+
217
+ ##
218
+ ## T
219
+ ##
220
+
221
+ # /tags/ai-ml
222
+ # /tags/case-studies
223
+ # /tags/css
224
+ # /tags/corporate-governance
225
+ # /tags/devops
226
+ # /tags/drupal-tutorials
227
+ # /tags/engineering-blog
228
+ # /tags/human-resources
229
+ # /tags/infinite-business-plan
230
+ # /tags/our-work
231
+ # /tags/react-js
232
+ # /tags/scrum
233
+ # /tags/tutorials
234
+ # /tags/uiux
235
+ # /tags/open-source-contributions
236
+ { path: '/tags/2023q1-issue', selector: '#taxonomy-term-25' },
237
+ # /tags/documentation
238
+
239
+
240
+
241
+ { path: '/thank-you', redirect_to: '/pages/thank-you' },
242
+
243
+ { path: '/tags/cyber-security', selector: '#taxonomy-term-27' },
244
+ { path: '/tags/ruby-on-rails', selector: '#taxonomy-term-17' },
245
+ { path: '/tags/site-updates', selector: '#taxonomy-term-3' },
246
+
247
+ ##
248
+ ## U
249
+ ##
250
+
251
+ { path: '/unsubscribe-1', redirect_to: '/unsubscribe' },
252
+
253
+ { path: '/unsubscribe', selector: 'body.page-id-3343' },
254
+
255
+ ##
256
+ ##
257
+ ##
258
+
259
+ # /volunteer
260
+
261
+
262
+ ##
263
+ ## W
264
+ ##
265
+
266
+ # /wasyaco
267
+
268
+ # { path: '/w/20221024', redirect_to: 'https://staging.infiniteshelter.com/en/locations/show/austin-wasyaco' },
269
+
270
+ { path: '/w/c', redirect_to: '/contact-us/project-intake' },
271
+ { path: '/w/c2', redirect_to: '/services/consulting' },
272
+ { path: '/w/contact-us', redirect_to: '/contact-us/contact-us-step1' },
273
+ { path: '/w/pimsleur', redirect_to: '/es/pimsleur-ingles-para-espanol' },
274
+ { path: '/w/pudeyev-resume', redirect_to: '/pudeyev-resume' },
275
+ { path: '/w/unsubscribe', redirect_to: '/unsubscribe' },
276
+
277
+ ]
278
+ return out
279
+ end
280
+ end
281
+