nblog_zon 0.0.10 → 0.0.30

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nblog_zon.rb +386 -179
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e35ed1ed855fc1fba2f406242d3ae83764a079d374f418e97d9631143009abb7
4
- data.tar.gz: 523852fd06a38c18599737e673a6f7ba5e807516c6bec12567467cb7abcde5c1
3
+ metadata.gz: d9f0276ddb9596a1e1597fa3ed72d973ae9eee4037f7f57d18281b45fe77fb3c
4
+ data.tar.gz: 49e9b89cd0043cd47dc5d1b1399491902df6c0e28675992c34f0daeabeee4072
5
5
  SHA512:
6
- metadata.gz: 33d332822b073be2607f2fdd7d045490b471c9f59349d4809a470772f5fcd6d3d90e2991bed140e26e774fd3cf1b4cb38aeddc7c0cf6af527b552b30f2adedec
7
- data.tar.gz: 9d73eb2698fa64fb4a34b8898c30cb9f7c184d2c109e4538477054077ef8e24e161b9d1a32745c8fcc195731e0a988219ad350e7a822020ed6d529ea4eedbf9b
6
+ metadata.gz: 39630a0452d2d6c852e4b41c220de5b587b0cd569b5cd0fd729f294f5ef2df8e2a1e6279debf66ef1da105d8045640c2b672ae787f7c1ffcfd0337bbec12d668
7
+ data.tar.gz: ce384ad4fdae33e746cf91a3aff2b8a5fdf8f9a0c99295d5b78c8d60e0e99a3b16cacbd09c7a8e6cb54e1fc96d2c3f477d2d1d21622053b47327a3d0b05e2a54
data/lib/nblog_zon.rb CHANGED
@@ -607,43 +607,76 @@ class Naver
607
607
  @driver.find_element(:xpath, '//*[@data-log="ltpl.my"]').click
608
608
  sleep(1)
609
609
  begin
610
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3.7)
611
+ wait.until { @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[1]/aside/div/div[3]/div[1]/div[2]/ul/li['+template.to_s+']/a') }
610
612
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[1]/aside/div/div[3]/div[1]/div[2]/ul/li['+template.to_s+']/a').click
611
613
  puts '탬플릿 ['+template.to_s+'] 번을 사용합니다'
614
+ sleep(1)
612
615
  rescue
616
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3.7)
617
+ wait.until { @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[1]/aside/div/div[3]/div[1]/div[2]/ul/li/a') }
613
618
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[1]/aside/div/div[3]/div[1]/div[2]/ul/li/a').click
614
619
  puts '탬플릿 ['+template.to_s+'] 번을 찾지못해 첫번째 탬플릿을 사용합니다.'
615
620
  sleep(1)
616
621
  end
622
+
623
+ begin
624
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
625
+ alert = wait.until { @driver.switch_to.alert }
626
+ sleep(1)
617
627
  @driver.switch_to.alert.accept
618
- sleep(5)
628
+ rescue
629
+ end
630
+
631
+ begin
632
+ wait = Selenium::WebDriver::Wait.new(timeout: 10) # 최대 10초까지 대기
633
+ element = wait.until {
634
+ elem = @driver.find_element(:css, "div[style*='position: fixed; top: 0px; left: -9999px; width: 17px; height: 100%; border: 0px;']")
635
+ elem.style("display") == "block" ? elem : nil
636
+ }
637
+ rescue
638
+ end
639
+
619
640
  @driver.find_element(:xpath, '//*[@data-name="template"]').click
620
641
  sleep(1)
621
-
622
-
623
-
624
642
  end
625
643
  rescue
626
-
627
644
  end
628
645
 
629
646
 
630
647
  #제목 입력
631
648
  ele = @driver.find_element(:xpath, '//*[@draggable="false"]')
632
649
  @driver.action.click(ele).perform
633
- sleep(1)
634
- @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
635
- sleep(1)
636
- @driver.action.key_down(:delete).key_up(:delete).perform
637
- sleep(1)
650
+ sleep(0.5)
651
+ if template.to_s == ''
652
+ # 템플릿이 사용되지 않았을 경우
653
+ else
654
+ # 템플릿이 사용된 경우
655
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
656
+ sleep(0.5)
657
+ @driver.action.key_down(:delete).key_up(:delete).perform
658
+ sleep(0.5)
659
+ end
660
+
661
+
638
662
  title = title.strip
639
663
  @driver.action.send_keys(title).perform
640
664
  sleep(1)
641
- @driver.action.key_down(:enter).key_up(:enter).perform
642
- sleep(1)
643
- @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
644
- sleep(1)
645
665
  @driver.action.key_down(:down).key_up(:down).perform
646
- @driver.action.key_down(:enter).key_up(:enter).perform
666
+ sleep(1)
667
+
668
+
669
+ if template.to_s == ''
670
+ # 템플릿이 사용되지 않았을 경우
671
+ else
672
+ # 템플릿이 사용된 경우
673
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
674
+ sleep(1)
675
+ @driver.action.key_down(:down).key_up(:down).perform
676
+ sleep(1)
677
+ @driver.action.key_down(:enter).key_up(:enter).perform
678
+ end
679
+
647
680
 
648
681
 
649
682
 
@@ -678,15 +711,20 @@ class Naver
678
711
  sleep(1)
679
712
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[12]/div/div/button[2]').click
680
713
  sleep(1)
714
+ #@driver.actions.key_down(:control).key_down(:alt).send_keys('l').key_up(:alt).key_up(:control).perform
715
+
681
716
  elsif i.to_s.include?('right')
682
717
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[12]/div/button').click
683
718
  sleep(1)
684
719
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[12]/div/div/button[3]').click
685
720
  sleep(1)
721
+ #@driver.actions.key_down(:control).key_down(:alt).send_keys('r').key_up(:alt).key_up(:control).perform
722
+
686
723
  else
687
-
724
+
688
725
  end
689
726
  end
727
+
690
728
 
691
729
  i.children.each do |i2|
692
730
  puts i.to_s
@@ -694,7 +732,7 @@ class Naver
694
732
  node_value = Hash.new
695
733
  node_value['id'] = create_id()
696
734
  node_value['@ctype'] = 'textNode'
697
- sleep(1)
735
+ #sleep(1)
698
736
  if i2.to_s.include?('<img')
699
737
  path = i2.to_s.split('src="')[1].split('"')[0]
700
738
  path = URI.decode_www_form(path)[0][0]
@@ -709,7 +747,7 @@ class Naver
709
747
  iframe = wait.until { @driver.find_element(id: 'mainFrame') }
710
748
  @driver.switch_to.frame(iframe)
711
749
  begin
712
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
750
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
713
751
  wait.until { @driver.find_element(:xpath, '//*[@class="se-popup-button-text"]') }
714
752
  @driver.find_element(:xpath, '//*[@class="se-popup-button-text"]').click
715
753
  sleep(1)
@@ -783,9 +821,7 @@ class Naver
783
821
  sleep(1)
784
822
  end
785
823
 
786
-
787
-
788
-
824
+
789
825
  # end
790
826
  # components_value['src'] = 'https://blogfiles.pstatic.net'+image_data['item']['url']+'?type=w1'
791
827
  # components_value['internalResource'] = true
@@ -839,6 +875,167 @@ class Naver
839
875
  @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
840
876
  sleep(3)
841
877
 
878
+
879
+ elsif i2.to_s.include?('<slide')
880
+ if option['라이브러리사용안함'] == 'true'
881
+
882
+ posting_url = @driver.current_url
883
+ @driver.execute_script("window.open('#{posting_url}');")
884
+ sleep(1)
885
+ @driver.switch_to.window(@driver.window_handles[1])
886
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
887
+ iframe = wait.until { @driver.find_element(id: 'mainFrame') }
888
+ @driver.switch_to.frame(iframe)
889
+ begin
890
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
891
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-popup-button-text"]') }
892
+ @driver.find_element(:xpath, '//*[@class="se-popup-button-text"]').click
893
+ sleep(1)
894
+ rescue
895
+ end
896
+
897
+ slide_content = i2.to_s.split('<slide>').last.split('</slide>').first.strip
898
+ paths = slide_content.scan(/"([^"]+)"/).flatten # 큰따옴표로 감싸진 경로만 추출
899
+
900
+ # 2. 전체 경로를 추출하여 윈도우 경로로 변환
901
+ full_paths = paths.map { |path| path.strip.gsub('/', '\\') } # 윈도우 경로 구분자로 변경
902
+
903
+ paths_with_quotes = full_paths.map { |path| "\"#{path}\"" }.join(' ')
904
+ image_names = paths.map { |path| File.basename(path) }.map { |name| "\"#{name}\"" }.join(' ') # 큰따옴표로 감싼 파일 이름만 추출
905
+ # 3. 전체 경로를 클립보드에 복사
906
+ Clipboard.copy(paths_with_quotes)
907
+
908
+ # 4. 전체 경로를 붙여넣기
909
+ @driver.find_element(:xpath, '//*[@class="se-toolbar-item se-toolbar-item-image"]').click
910
+ sleep(1)
911
+
912
+ key_down('ctrl')
913
+ key_stroke('v')
914
+ key_up('ctrl')
915
+ sleep(1)
916
+ key_stroke('enter')
917
+ sleep(2)
918
+ #@driver.action.key_down(:control).send_keys('z').key_up(:control).perform
919
+ @driver.find_element(:xpath, '//*[@class="se-popup-close-button"]').click
920
+
921
+ # 6. 이미지 이름만 클립보드에 복사 (큰따옴표 포함)
922
+ Clipboard.copy(image_names)
923
+
924
+ # 8. 이미지 이름만 클립보드에 복사 후 붙여넣기
925
+ @driver.find_element(:xpath, '//*[@class="se-toolbar-item se-toolbar-item-image"]').click
926
+ sleep(1)
927
+ sleep(1)
928
+ key_down('ctrl')
929
+ key_stroke('v')
930
+ key_up('ctrl')
931
+ sleep(1)
932
+ key_stroke('enter')
933
+ sleep(2)
934
+
935
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
936
+ wait.until { @driver.find_element(:xpath, '//*[@for="image-type-slide"]') }
937
+ @driver.find_element(:xpath, '//*[@for="image-type-slide"]').click
938
+ sleep(1)
939
+ @driver.action.send_keys(:up).perform
940
+ sleep(1)
941
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
942
+ wait.until { @driver.find_element(:xpath, '//*[@data-log="ct.arrfit"]') }
943
+ @driver.find_element(:xpath, '//*[@data-log="ct.arrfit"]').click
944
+ sleep(1)
945
+
946
+
947
+ @driver.action.key_down(:control).send_keys('c').key_up(:control).perform
948
+ @driver.switch_to.default_content()
949
+ @driver.close
950
+ sleep(1)
951
+ @driver.switch_to.window(@driver.window_handles[0])
952
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
953
+ iframe = wait.until { @driver.find_element(id: 'mainFrame') }
954
+ @driver.switch_to.frame(iframe)
955
+ #@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
956
+ key_down('ctrl')
957
+ key_stroke('v')
958
+ key_up('ctrl')
959
+ sleep(1)
960
+
961
+ else
962
+
963
+ slide_content = i2.to_s.split('<slide>').last.split('</slide>').first.strip
964
+ paths = slide_content.scan(/"([^"]+)"/).flatten # 큰따옴표로 감싸진 경로만 추출
965
+
966
+ # 2. 전체 경로를 추출하여 윈도우 경로로 변환
967
+ full_paths = paths.map { |path| path.strip.gsub('/', '\\') } # 윈도우 경로 구분자로 변경
968
+
969
+ paths_with_quotes = full_paths.map { |path| "\"#{path}\"" }.join(' ')
970
+ image_names = paths.map { |path| File.basename(path) }.map { |name| "\"#{name}\"" }.join(' ') # 큰따옴표로 감싼 파일 이름만 추출
971
+ # 3. 전체 경로를 클립보드에 복사
972
+ Clipboard.copy(paths_with_quotes)
973
+
974
+ # 4. 전체 경로를 붙여넣기
975
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
976
+ sleep(1)
977
+
978
+ key_down('ctrl')
979
+ key_stroke('v')
980
+ key_up('ctrl')
981
+ sleep(1)
982
+ key_stroke('enter')
983
+ sleep(2)
984
+
985
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
986
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-popup-close-button"]') }
987
+ @driver.find_element(:xpath, '//*[@class="se-popup-close-button"]').click
988
+
989
+
990
+ # 6. 이미지 이름만 클립보드에 복사 (큰따옴표 포함)
991
+ Clipboard.copy(image_names)
992
+
993
+ # 8. 이미지 이름만 클립보드에 복사 후 붙여넣기
994
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
995
+ sleep(1)
996
+ sleep(1)
997
+ key_down('ctrl')
998
+ key_stroke('v')
999
+ key_up('ctrl')
1000
+ sleep(1)
1001
+ key_stroke('enter')
1002
+ sleep(2)
1003
+
1004
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
1005
+ wait.until { @driver.find_element(:xpath, '//*[@for="image-type-slide"]') }
1006
+ @driver.find_element(:xpath, '//*[@for="image-type-slide"]').click
1007
+ sleep(1)
1008
+ @driver.action.send_keys(:up).perform
1009
+ sleep(1)
1010
+
1011
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
1012
+ wait.until { @driver.find_element(:xpath, '//*[@data-log="ct.arrfit"]') }
1013
+ @driver.find_element(:xpath, '//*[@data-log="ct.arrfit"]').click
1014
+ sleep(1)
1015
+ @driver.action.key_down(:enter).key_up(:enter).perform
1016
+
1017
+
1018
+ end
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
842
1039
  elsif i2.to_s.include?('<inyonggoo')
843
1040
  if i2.text == ''
844
1041
 
@@ -874,6 +1071,11 @@ class Naver
874
1071
  # components_value['source'] = nil
875
1072
  # components_value['@ctype'] = 'quotation'
876
1073
  end
1074
+
1075
+
1076
+
1077
+
1078
+
877
1079
  elsif i2.to_s.include?('<sticker')
878
1080
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[4]/button').click
879
1081
  sleep(1)
@@ -1061,49 +1263,6 @@ class Naver
1061
1263
  @driver.action.key_down(:space).key_up(:space).perform
1062
1264
  @driver.action.key_down(:left).key_up(:left).perform
1063
1265
  end
1064
-
1065
- # begin
1066
- # if i.to_s.split('text-align: ')[1].split(';')[0] == 'center'
1067
- # if value_data['style'] == nil
1068
- # value_data['style'] = Hash.new
1069
- # end
1070
- # value_data['style']['align'] = 'center'
1071
- # value_data['style']['@ctype'] = 'paragraphStyle'
1072
- # elsif i.to_s.split('text-align: ')[1].split(';')[0] == 'right'
1073
- # if value_data['style'] == nil
1074
- # value_data['style'] = Hash.new
1075
- # end
1076
- # value_data['style']['align'] = 'right'
1077
- # value_data['style']['@ctype'] = 'paragraphStyle'
1078
- # else
1079
-
1080
- # end
1081
- # rescue => e
1082
- # puts e
1083
-
1084
- # end
1085
-
1086
- # if toomung == 1
1087
- # if node_value['style'] == nil
1088
- # node_value['style'] = Hash.new
1089
- # end
1090
- # node_value['style']['fontSizeCode'] = 'fs0'
1091
- # end
1092
-
1093
- # if i2.to_s.include?('<a href="')
1094
- # if i2.to_s.include?('<img src=')
1095
-
1096
- # else
1097
- # node_value['link'] = {
1098
- # 'url' => i2.to_s.split('href="')[1].split('"')[0],
1099
- # '@ctype' => 'urlLink'
1100
- # }
1101
- # end
1102
- # end
1103
-
1104
- # if node_value['style'] != nil
1105
- # node_value['style']['@ctype'] = 'nodeStyle'
1106
- # end
1107
1266
  end
1108
1267
 
1109
1268
  if check_image == 0
@@ -1191,50 +1350,14 @@ class Naver
1191
1350
  end
1192
1351
  end
1193
1352
  end
1194
- sleep(1)
1353
+ sleep(0.5)
1195
1354
  @driver.action.key_down(:end).key_up(:end).perform
1196
- sleep(1)
1355
+ sleep(0.5)
1197
1356
  @driver.action.key_down(:enter).key_up(:enter).perform
1198
- sleep(1)
1199
- # if check_image == 0
1200
- # if value_data['nodes'].length == 0
1201
- # value_data['nodes'][0] = {
1202
- # 'id' => create_id(),
1203
- # '@ctype' => 'textNode',
1204
- # 'value' => ''
1205
- # }
1206
- # end
1207
- # begin
1208
- # components_value['value'] << value_data
1209
- # rescue
1210
-
1211
- # end
1212
- # end
1213
-
1214
- # if components_value['value'] != nil
1215
- # if components_value['value'].length == 0
1216
- # components_value['value'][0] = {
1217
- # 'id' => create_id(),
1218
- # 'nodes' => [{
1219
- # 'id' => create_id(),
1220
- # '@ctype' => 'textNode',
1221
- # 'value' => ''
1222
- # }],
1223
- # '@ctype' => 'paragraph'
1224
- # }
1225
- # end
1226
- # end
1227
- # data['documentModel']['document']['components'] << components_value
1357
+ sleep(0.5)
1228
1358
  end
1229
1359
 
1230
1360
  if soosick_1 != ''
1231
- # data['documentModel']['document']['components'] << {
1232
- # 'id' => create_id(),
1233
- # 'layout' => 'default',
1234
- # 'fontSizeCode' => 'fs13',
1235
- # 'codeContents' => soosick_1,
1236
- # '@ctype' => 'code'
1237
- # }
1238
1361
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[13]/button').click
1239
1362
  sleep(3)
1240
1363
  # @driver.action.send_keys(soosick_1.text).perform
@@ -1246,13 +1369,6 @@ class Naver
1246
1369
  end
1247
1370
 
1248
1371
  if soosick_2 != ''
1249
- # data['documentModel']['document']['components'] << {
1250
- # 'id' => create_id(),
1251
- # 'layout' => 'default',
1252
- # 'fontSizeCode' => 'fs13',
1253
- # 'codeContents' => soosick_2,
1254
- # '@ctype' => 'code'
1255
- # }
1256
1372
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[13]/button').click
1257
1373
  sleep(3)
1258
1374
  # @driver.action.send_keys(soosick_2).perform
@@ -1263,6 +1379,32 @@ class Naver
1263
1379
  sleep(3)
1264
1380
  end
1265
1381
 
1382
+ if option['중앙정렬'] == 'true'
1383
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
1384
+ sleep(1)
1385
+ @driver.action.key_down(:control).key_down(:alt).send_keys('c').key_up(:alt).key_up(:control).perform
1386
+ sleep(1)
1387
+ else
1388
+
1389
+ end
1390
+ if option['좌측정렬'] == 'true'
1391
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
1392
+ sleep(1)
1393
+ @driver.action.key_down(:control).key_down(:alt).send_keys('l').key_up(:alt).key_up(:control).perform
1394
+ sleep(1)
1395
+ else
1396
+
1397
+ end
1398
+ if option['우측정렬'] == 'true'
1399
+ @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
1400
+ sleep(1)
1401
+ @driver.action.key_down(:control).key_down(:alt).send_keys('r').key_up(:alt).key_up(:control).perform
1402
+ sleep(1)
1403
+ else
1404
+
1405
+ end
1406
+
1407
+
1266
1408
  @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]').click #1차 등록버튼
1267
1409
  sleep(3)
1268
1410
  category = option['category']
@@ -1403,45 +1545,13 @@ class Naver
1403
1545
 
1404
1546
  end
1405
1547
 
1406
-
1407
-
1408
-
1409
-
1410
-
1411
- #sleep(dd_time.to_i)
1412
- #@driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[8]/div/button').click
1413
-
1414
- #sleep(10)
1415
1548
  begin
1416
1549
  @driver.close
1417
1550
  rescue
1418
1551
 
1419
1552
  end
1420
1553
 
1421
- # if option['proxy'] == ''
1422
- # http = HTTP.headers(h).post('https://api-blog.blog.naver.com/rabbit/auto/save', :form => data)
1423
- # else
1424
- # ip = option['proxy'].to_s.split(':')[0]
1425
- # port = option['proxy'].to_s.split(':')[1]
1426
- # http = HTTP.via(ip, port.to_i).headers(h).post('https://api-blog.blog.naver.com/rabbit/auto/save', :form => data)
1427
- # end
1428
- # puts http.to_s
1429
- # http.cookies.each do |i|
1430
- # puts i
1431
- # end
1432
- # sleep(3)
1433
- # data['productApiVersion'] = 'v1'
1434
- # if option['proxy'] == ''
1435
- # http = HTTP.headers(h).post('https://blog.naver.com/RabbitWrite.naver', :form => data)
1436
- # else
1437
- # ip = option['proxy'].to_s.split(':')[0]
1438
- # port = option['proxy'].to_s.split(':')[1]
1439
- # http = HTTP.via(ip, port.to_i).headers(h).post('https://blog.naver.com/RabbitWrite.naver', :form => data)
1440
- # end
1441
- # puts http.to_s
1442
- # http.cookies.each do |i|
1443
- # puts i
1444
- # end
1554
+
1445
1555
  end
1446
1556
  end
1447
1557
 
@@ -2604,6 +2714,7 @@ class Wordpress
2604
2714
  if i.force_encoding('utf-8').to_s.include?('@')
2605
2715
  image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
2606
2716
  content[index3] = content[index3] + '**image()**'
2717
+
2607
2718
  else
2608
2719
  image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
2609
2720
  content[index3] = content[index3] + '**image**'
@@ -2613,10 +2724,61 @@ class Wordpress
2613
2724
  content = content.join('')
2614
2725
  end
2615
2726
  end
2616
-
2617
-
2618
-
2619
-
2727
+
2728
+ if @data['포스트설정']['슬라이드로변경'].checked?
2729
+ @data['포스트설정']['단어슬라이드변경'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2730
+ content = content.split(i.force_encoding('utf-8'))
2731
+ content.each_with_index do |ccm, index3|
2732
+ if index3 == content.length - 1
2733
+ # 마지막 인덱스인 경우, 아무 작업하지 않음
2734
+ else
2735
+ image_url = get_image_file().force_encoding('utf-8') # 실제 이미지 경로
2736
+ image_number = @data['포스트설정']['슬라이드사진수량'].text.to_s.force_encoding('utf-8').to_i
2737
+ image = Magick::Image.read(image_url).first
2738
+ image_width = image.columns # 이미지의 가로 크기
2739
+ image_height = image.rows # 이미지의 세로 크기
2740
+ split_width = image_width / image_number # 가로로 나누는 너비
2741
+
2742
+ # 이미지 분할 작업
2743
+ slide_images = (0...image_number).map do |n|
2744
+ split_image = image.crop(n * split_width, 0, split_width, image_height)
2745
+
2746
+ # 현재 초를 사용하여 고유한 파일 이름 생성
2747
+ timestamp = Time.now.to_i
2748
+ split_image_path = "./image/#{@keyword}_slide_#{n + 1}_#{timestamp}.png"
2749
+ absolute_path = File.expand_path(split_image_path) # 절대 경로 계산
2750
+
2751
+ # 이미지 저장
2752
+ split_image.write(absolute_path)
2753
+
2754
+ # 이미지 파일 이름만 추출
2755
+ image_name = File.basename(absolute_path)
2756
+
2757
+ # 1. 전체 경로를 포함한 <slide> 태그
2758
+ full_path_slide = "\"#{absolute_path}\""
2759
+
2760
+ # 2. 이미지 이름만 포함한 <slide1> 태그
2761
+ name_only_slide = "\"#{image_name}\""
2762
+
2763
+ # 전체 경로와 이미지 이름을 각각 모아서 반환
2764
+ [full_path_slide, name_only_slide]
2765
+ end
2766
+
2767
+ # <slide> 태그는 전체 경로만, <slide1> 태그는 이미지 이름만 포함
2768
+ slide_full_paths = slide_images.map { |pair| pair[0] }.join(' ')
2769
+ slide_names_only = slide_images.map { |pair| pair[1] }.join(' ')
2770
+
2771
+ # 각각 <slide>와 <slide1> 태그로 감싸기
2772
+ slide_html_full = "<slide>" + slide_full_paths + "</slide>"
2773
+ slide_html_names = "<slide1>" + slide_names_only + "</slide1>"
2774
+
2775
+ # 두 태그를 content에 추가
2776
+ content[index3] = content[index3] + slide_html_full
2777
+ end
2778
+ end
2779
+ content = content.join('')
2780
+ end
2781
+ end
2620
2782
 
2621
2783
  con_memory = Array.new
2622
2784
  index5 = 0
@@ -2836,14 +2998,23 @@ class Wordpress
2836
2998
 
2837
2999
  if @data['포스트설정']['중앙정렬'].checked?
2838
3000
  content = content.split("\n").map {|row| '<p style="text-align: center;">'+row+'</p>'}.join("\n")
3001
+ option['중앙정렬'] = 'true'
3002
+ else
3003
+ option['중앙정렬'] = 'false'
2839
3004
  end
2840
3005
 
2841
3006
  if @data['포스트설정']['우측정렬'].checked?
2842
3007
  content = content.split("\n").map {|row| '<p style="text-align: right;">'+row+'</p>'}.join("\n")
3008
+ option['우측정렬'] = 'true'
3009
+ else
3010
+ option['우측정렬'] = 'false'
2843
3011
  end
2844
3012
 
2845
3013
  if @data['포스트설정']['좌측정렬'].checked?
2846
3014
  content = content.split("\n").map {|row| '<p style="text-align: left;">'+row+'</p>'}.join("\n")
3015
+ option['좌측정렬'] = 'true'
3016
+ else
3017
+ option['좌측정렬'] = 'false'
2847
3018
  end
2848
3019
 
2849
3020
  @data['table'][index][-1] = 90
@@ -4116,15 +4287,80 @@ class Wordpress
4116
4287
  }
4117
4288
  }
4118
4289
  }
4290
+
4291
+ horizontal_box{
4292
+ stretchy false
4293
+ label('※이미지 리스트와 위 세팅을 하였다면 포스트설정1 탭에서 어떤위치(방식)으로 삽입시킬지 세팅이 필요합니다.'){
4294
+ }
4295
+ }
4296
+ horizontal_box{
4297
+ stretchy false
4298
+ label('※이미지를 아래 특정단어 슬라이드 변경 기능만 사용한다면 포스트설정1 탭에서 설정을 할 필요는 없습니다.'){
4299
+ }
4300
+ }
4119
4301
  vertical_separator{
4120
4302
  stretchy false
4121
- }
4303
+ }
4122
4304
  horizontal_box{
4123
4305
  stretchy false
4124
4306
  @data['포스트설정']['라이브러리사용안함'] = checkbox('사진 라이브러리에서 제외시키기 적용'){
4125
4307
 
4126
4308
  }
4127
- }
4309
+ }
4310
+ horizontal_box{
4311
+ stretchy false
4312
+ label('※해당 기능에 체크시 로직 활용으로 브라우저 창을 하나 더 사용하게 되므로 PC 사양(인터넷속도) 낮은 환경에서는 비 추천입니다.'){
4313
+ }
4314
+ }
4315
+
4316
+ vertical_separator{
4317
+ stretchy false
4318
+ }
4319
+ horizontal_box{
4320
+ stretchy false
4321
+ @data['포스트설정']['슬라이드로변경'] = checkbox('특정단어를 슬라이드사진 변경'){
4322
+ }
4323
+ @data['포스트설정']['단어슬라이드변경'] = entry{
4324
+ text 'ex)특정단어a'
4325
+ }
4326
+ grid{
4327
+ @data['포스트설정']['슬라이드사진수량'] = entry{
4328
+ text '수량 ex)3'
4329
+ }
4330
+ }
4331
+ }
4332
+ horizontal_box{
4333
+ stretchy false
4334
+ grid{
4335
+ label('※이미지 순서 사용시 참고 사항!!'){
4336
+ top 0
4337
+ left 0
4338
+
4339
+ }
4340
+ label('내용 중 원하는 위치에 특정단어 예로 "특정단어a" 분할사진" 이라 넣어 두고 해당 항목에도 "특정단어a" 단어를 넣어주세요. '){
4341
+ top 1
4342
+ left 0
4343
+
4344
+ }
4345
+ label('삽입되는 사진부터 계산 후 슬라이드 사용 이미지를 계산하며, 예로 이미지5개 중 사진 삽입이 3장, 슬라이드 사용 사진 2장이라면'){
4346
+ top 2
4347
+ left 0
4348
+
4349
+ }
4350
+
4351
+ label('사진 삽입에 1번부터~3번까지 차례로 순서를 정하고 슬라이드에 사용되는 사진이 다음으로 4번부터~5번까지가 설정됩니다'){
4352
+ top 3
4353
+ left 0
4354
+
4355
+ }
4356
+
4357
+ }
4358
+ }
4359
+ horizontal_box{
4360
+ stretchy false
4361
+ label('※수량은 이미지 하나를 분할하려는 수이며, 블로그 규정에 맞게 최대10 이하로 설정해주세요'){
4362
+ }
4363
+ }
4128
4364
  }
4129
4365
  }
4130
4366
  }
@@ -4146,26 +4382,7 @@ class Wordpress
4146
4382
  text '특정단어'
4147
4383
  }
4148
4384
 
4149
- # @data['포스트설정']['제목단어변경'] = checkbox('제목에 특정 단어를 변경'){
4150
- # top 1
4151
- # left 0
4152
- # }
4153
- # @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
4154
- # top 1
4155
- # left 1
4156
- # on_clicked{
4157
- # file = open_file
4158
- # if file != nil
4159
- # file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4160
- # file_data.split("\n").each do |i|
4161
- # i2 = i.split('>')
4162
- # text_key = i2[0].to_s
4163
- # text_val = i2[1].to_s.split(',')
4164
- # @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
4165
- # end
4166
- # end
4167
- # }
4168
- # }
4385
+
4169
4386
  @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
4170
4387
  top 2
4171
4388
  left 0
@@ -4490,16 +4707,6 @@ class Wordpress
4490
4707
  }
4491
4708
 
4492
4709
 
4493
- # @data['포스트설정']['슬라이드로변경'] = checkbox('특정단어를 슬라이드사진 변경'){
4494
- # top 6
4495
- # left 0
4496
- # }
4497
- # @data['포스트설정']['단어슬라이드변경'] = entry{
4498
- # top 6
4499
- # left 1
4500
- # text '특정단어'
4501
- # }
4502
-
4503
4710
  @data['포스트설정']['스티커로변경'] = checkbox('특정단어를 스티커로 변경'){
4504
4711
  top 6
4505
4712
  left 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-30 00:00:00.000000000 Z
11
+ date: 2024-01-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: rnjstnswp123@naver.com