parsergem 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d9a42dbc9698680bc4ec2d93489b6303936bdf0e7bb146d2d304bfa545eee9b
4
- data.tar.gz: 28c5b9773451c0edf127be1aa73e94b2638381f8b32aeac1538d3450025a8905
3
+ metadata.gz: 1c67a1e4c1a13b6a1c35f10515c9702ce67dffeffcdda47635963651898b9ba7
4
+ data.tar.gz: 36d4878138bd20771f7070c383d6a313c62019387b35a03a92f752c7678f26ea
5
5
  SHA512:
6
- metadata.gz: ce8a2e9710405c6097dd2894c47ba0c6d7e0650a70787ef386fb9e8dee9381814f9603d1652e3ef6b03f66fa3dd20f4dd57a9c236a12950962aaaec997f3e672
7
- data.tar.gz: b6a27f46f68045c4892065dd71f221394bf53bc975421ed37354a87a3951bedbdd7c83f1e2c0b50586c6fb9dd2bfb68d63f277cf87490a62cdb8e085852340ad
6
+ metadata.gz: c5ca9227f970cf96745a02aa68d182b82d5406c11d41881a2327977537b16b67fbf5fd9df4a90160f06c099a9eb2886a10e7810f187f725572389155f998c4b0
7
+ data.tar.gz: 0b17f6205514180431687ac4efd2f9d02749b82924fb5af546e9c39fb5f7ea4530679b31f0a0adfdc65c019ed61827d228ba14e482cb0018503549b2a6461619
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parsergem (0.1.4)
4
+ parsergem (0.1.5)
5
5
  activesupport (>= 5.0.0)
6
6
  aws-sdk-translate
7
7
  nokogiri
@@ -28,9 +28,7 @@ module ParserGem
28
28
  def clone # Main method
29
29
  sitemap = Nokogiri::XML(URI.open("http://#{options[:target_url]}/sitemap.xml")) # Load sitemap.xml
30
30
  controller_name = options[:target_url].split('/').last.delete('.').delete('-') # Set controller name from clear domain name
31
- actions = set_actions(sitemap) # Set actions for controller
32
-
33
- puts options[:to_partials_blocks_ids].to_s
31
+ actions = set_actions(sitemap)
34
32
 
35
33
  actions.each do |action| # Create routes
36
34
  if action[:rails_route] == '/'
@@ -244,7 +242,7 @@ module ParserGem
244
242
 
245
243
  body.css('a').each do |link| # Self absolute links to media repair
246
244
  if link['href']
247
- if link['href'].include?("http://#{options[:target_url]}") && (link['href'].include?('.png') || link['href'].include?('.jpg') || link['href'].include?('.jpeg') || link['href'].include?('.webp'))
245
+ if link['href'].include?("http://#{options[:target_url]}") && (link['href'].include?('.png') || link['href'].include?('.jpg') || link['href'].include?('.jpeg') || link['href'].include?('.webp') || link['href'].include?('.pdf'))
248
246
  link['href'] = download_media(link['href'], controller_name)
249
247
  end
250
248
  end
@@ -276,8 +274,8 @@ module ParserGem
276
274
  if action[:lang]
277
275
  body.css('a').each do |link| # Repair links for lang versions
278
276
  if link['href']
279
- if !link['href'].include?('http') && !link['href'].include?('mailto:') && !link['href'].include?('tel:')
280
- if link['href'][0] == '/' && ( !link['href'].include?('.jpg') || !link['href'].include?('.jpeg') || !link['href'].include?('.png') || !link['href'].include?('.webp'))
277
+ if !link['href'].include?('http') && !link['href'].include?('mailto:') && !link['href'].include?('tel:') && !link['href'].include?('.jpg') && !link['href'].include?('.jpeg') && !link['href'].include?('.png') && !link['href'].include?('.webp') && !link['href'].include?('.pdf')
278
+ if link['href'][0] == '/'
281
279
  link['href'] = "/#{action[:lang]}#{link['href']}"
282
280
  else
283
281
  link['href'] = "/#{action[:lang]}/#{link['href']}"
@@ -311,6 +309,14 @@ module ParserGem
311
309
  end
312
310
  end
313
311
 
312
+ if action[:lang]
313
+ body.css('img, video').each do |tag|
314
+ if tag['title'] && tag['title'].length > 2
315
+ tag['title'] = translate(tag['title'], action[:lang], client)
316
+ end
317
+ end
318
+ end
319
+
314
320
  file.puts body.to_s.gsub(/(&lt;%|%&gt;)/) {|x| x=='&lt;%' ? '<%' : '%>'} # Put edited body to view file, and repair ERB tags
315
321
  end
316
322
  repair_css(file_path, controller_name) # Repair links in inline css
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Parser
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsergem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Дмитрий Герасименко
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-14 00:00:00.000000000 Z
11
+ date: 2023-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor