nblog_duo 0.0.10 → 0.0.33
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 +4 -4
- data/lib/nblog_duo.rb +386 -179
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb58379556d62df27bdbc3366df75c4758e55486a71cc92cbf64a0541acdbaba
|
4
|
+
data.tar.gz: 2780d5ca68b65c6340e1d841f604d75b603d1619815cba25e569b43db5eca6e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e1ba1d4a9d96120b6afc0d62bf25add7e240e3f244db9fd3d1bd54ba41bee45b819390f2138e2f7110263df6083cedc2f8e00952d10148d3fbc41d1e1dfdb9
|
7
|
+
data.tar.gz: 02127f0437128ad68a0d63550a9bfe95078abcbe8b0ef91dc90c6f17859f95544d9dab7fb4236c1684784ccde88c2c49d3b9315e2364dabbf7eebfdcb161f2bd
|
data/lib/nblog_duo.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
|
-
|
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(
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
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
|
-
|
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 =>
|
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(
|
1353
|
+
sleep(0.5)
|
1195
1354
|
@driver.action.key_down(:end).key_up(:end).perform
|
1196
|
-
sleep(
|
1355
|
+
sleep(0.5)
|
1197
1356
|
@driver.action.key_down(:enter).key_up(:enter).perform
|
1198
|
-
sleep(
|
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
|
-
|
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
|
|
@@ -2673,6 +2783,7 @@ class Wordpress
|
|
2673
2783
|
if i.force_encoding('utf-8').to_s.include?('@')
|
2674
2784
|
image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
|
2675
2785
|
content[index3] = content[index3] + '**image()**'
|
2786
|
+
|
2676
2787
|
else
|
2677
2788
|
image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
|
2678
2789
|
content[index3] = content[index3] + '**image**'
|
@@ -2682,10 +2793,61 @@ class Wordpress
|
|
2682
2793
|
content = content.join('')
|
2683
2794
|
end
|
2684
2795
|
end
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2796
|
+
|
2797
|
+
if @data['포스트설정']['슬라이드로변경'].checked?
|
2798
|
+
@data['포스트설정']['단어슬라이드변경'].text.to_s.force_encoding('utf-8').split(',').each do |i|
|
2799
|
+
content = content.split(i.force_encoding('utf-8'))
|
2800
|
+
content.each_with_index do |ccm, index3|
|
2801
|
+
if index3 == content.length - 1
|
2802
|
+
# 마지막 인덱스인 경우, 아무 작업하지 않음
|
2803
|
+
else
|
2804
|
+
image_url = get_image_file().force_encoding('utf-8') # 실제 이미지 경로
|
2805
|
+
image_number = @data['포스트설정']['슬라이드사진수량'].text.to_s.force_encoding('utf-8').to_i
|
2806
|
+
image = Magick::Image.read(image_url).first
|
2807
|
+
image_width = image.columns # 이미지의 가로 크기
|
2808
|
+
image_height = image.rows # 이미지의 세로 크기
|
2809
|
+
split_width = image_width / image_number # 가로로 나누는 너비
|
2810
|
+
|
2811
|
+
# 이미지 분할 작업
|
2812
|
+
slide_images = (0...image_number).map do |n|
|
2813
|
+
split_image = image.crop(n * split_width, 0, split_width, image_height)
|
2814
|
+
|
2815
|
+
# 현재 초를 사용하여 고유한 파일 이름 생성
|
2816
|
+
timestamp = Time.now.to_i
|
2817
|
+
split_image_path = "./image/#{@keyword}_slide_#{n + 1}_#{timestamp}.png"
|
2818
|
+
absolute_path = File.expand_path(split_image_path) # 절대 경로 계산
|
2819
|
+
|
2820
|
+
# 이미지 저장
|
2821
|
+
split_image.write(absolute_path)
|
2822
|
+
|
2823
|
+
# 이미지 파일 이름만 추출
|
2824
|
+
image_name = File.basename(absolute_path)
|
2825
|
+
|
2826
|
+
# 1. 전체 경로를 포함한 <slide> 태그
|
2827
|
+
full_path_slide = "\"#{absolute_path}\""
|
2828
|
+
|
2829
|
+
# 2. 이미지 이름만 포함한 <slide1> 태그
|
2830
|
+
name_only_slide = "\"#{image_name}\""
|
2831
|
+
|
2832
|
+
# 전체 경로와 이미지 이름을 각각 모아서 반환
|
2833
|
+
[full_path_slide, name_only_slide]
|
2834
|
+
end
|
2835
|
+
|
2836
|
+
# <slide> 태그는 전체 경로만, <slide1> 태그는 이미지 이름만 포함
|
2837
|
+
slide_full_paths = slide_images.map { |pair| pair[0] }.join(' ')
|
2838
|
+
slide_names_only = slide_images.map { |pair| pair[1] }.join(' ')
|
2839
|
+
|
2840
|
+
# 각각 <slide>와 <slide1> 태그로 감싸기
|
2841
|
+
slide_html_full = "<slide>" + slide_full_paths + "</slide>"
|
2842
|
+
slide_html_names = "<slide1>" + slide_names_only + "</slide1>"
|
2843
|
+
|
2844
|
+
# 두 태그를 content에 추가
|
2845
|
+
content[index3] = content[index3] + slide_html_full
|
2846
|
+
end
|
2847
|
+
end
|
2848
|
+
content = content.join('')
|
2849
|
+
end
|
2850
|
+
end
|
2689
2851
|
|
2690
2852
|
con_memory = Array.new
|
2691
2853
|
index5 = 0
|
@@ -2905,14 +3067,23 @@ class Wordpress
|
|
2905
3067
|
|
2906
3068
|
if @data['포스트설정']['중앙정렬'].checked?
|
2907
3069
|
content = content.split("\n").map {|row| '<p style="text-align: center;">'+row+'</p>'}.join("\n")
|
3070
|
+
option['중앙정렬'] = 'true'
|
3071
|
+
else
|
3072
|
+
option['중앙정렬'] = 'false'
|
2908
3073
|
end
|
2909
3074
|
|
2910
3075
|
if @data['포스트설정']['우측정렬'].checked?
|
2911
3076
|
content = content.split("\n").map {|row| '<p style="text-align: right;">'+row+'</p>'}.join("\n")
|
3077
|
+
option['우측정렬'] = 'true'
|
3078
|
+
else
|
3079
|
+
option['우측정렬'] = 'false'
|
2912
3080
|
end
|
2913
3081
|
|
2914
3082
|
if @data['포스트설정']['좌측정렬'].checked?
|
2915
3083
|
content = content.split("\n").map {|row| '<p style="text-align: left;">'+row+'</p>'}.join("\n")
|
3084
|
+
option['좌측정렬'] = 'true'
|
3085
|
+
else
|
3086
|
+
option['좌측정렬'] = 'false'
|
2916
3087
|
end
|
2917
3088
|
|
2918
3089
|
@data['table'][index][-1] = 90
|
@@ -4191,15 +4362,80 @@ class Wordpress
|
|
4191
4362
|
}
|
4192
4363
|
}
|
4193
4364
|
}
|
4365
|
+
|
4366
|
+
horizontal_box{
|
4367
|
+
stretchy false
|
4368
|
+
label('※이미지 리스트와 위 세팅을 하였다면 포스트설정1 탭에서 어떤위치(방식)으로 삽입시킬지 세팅이 필요합니다.'){
|
4369
|
+
}
|
4370
|
+
}
|
4371
|
+
horizontal_box{
|
4372
|
+
stretchy false
|
4373
|
+
label('※이미지를 아래 특정단어 슬라이드 변경 기능만 사용한다면 포스트설정1 탭에서 설정을 할 필요는 없습니다.'){
|
4374
|
+
}
|
4375
|
+
}
|
4194
4376
|
vertical_separator{
|
4195
4377
|
stretchy false
|
4196
|
-
|
4378
|
+
}
|
4197
4379
|
horizontal_box{
|
4198
4380
|
stretchy false
|
4199
4381
|
@data['포스트설정']['라이브러리사용안함'] = checkbox('사진 라이브러리에서 제외시키기 적용'){
|
4200
4382
|
|
4201
4383
|
}
|
4202
|
-
}
|
4384
|
+
}
|
4385
|
+
horizontal_box{
|
4386
|
+
stretchy false
|
4387
|
+
label('※해당 기능에 체크시 로직 활용으로 브라우저 창을 하나 더 사용하게 되므로 PC 사양(인터넷속도) 낮은 환경에서는 비 추천입니다.'){
|
4388
|
+
}
|
4389
|
+
}
|
4390
|
+
|
4391
|
+
vertical_separator{
|
4392
|
+
stretchy false
|
4393
|
+
}
|
4394
|
+
horizontal_box{
|
4395
|
+
stretchy false
|
4396
|
+
@data['포스트설정']['슬라이드로변경'] = checkbox('특정단어를 슬라이드사진 변경'){
|
4397
|
+
}
|
4398
|
+
@data['포스트설정']['단어슬라이드변경'] = entry{
|
4399
|
+
text 'ex)특정단어a'
|
4400
|
+
}
|
4401
|
+
grid{
|
4402
|
+
@data['포스트설정']['슬라이드사진수량'] = entry{
|
4403
|
+
text '수량 ex)3'
|
4404
|
+
}
|
4405
|
+
}
|
4406
|
+
}
|
4407
|
+
horizontal_box{
|
4408
|
+
stretchy false
|
4409
|
+
grid{
|
4410
|
+
label('※이미지 순서 사용시 참고 사항!!'){
|
4411
|
+
top 0
|
4412
|
+
left 0
|
4413
|
+
|
4414
|
+
}
|
4415
|
+
label('내용 중 원하는 위치에 특정단어 예로 "특정단어a" 분할사진" 이라 넣어 두고 해당 항목에도 "특정단어a" 단어를 넣어주세요. '){
|
4416
|
+
top 1
|
4417
|
+
left 0
|
4418
|
+
|
4419
|
+
}
|
4420
|
+
label('삽입되는 사진부터 계산 후 슬라이드 사용 이미지를 계산하며, 예로 이미지5개 중 사진 삽입이 3장, 슬라이드 사용 사진 2장이라면'){
|
4421
|
+
top 2
|
4422
|
+
left 0
|
4423
|
+
|
4424
|
+
}
|
4425
|
+
|
4426
|
+
label('사진 삽입에 1번부터~3번까지 차례로 순서를 정하고 슬라이드에 사용되는 사진이 다음으로 4번부터~5번까지가 설정됩니다'){
|
4427
|
+
top 3
|
4428
|
+
left 0
|
4429
|
+
|
4430
|
+
}
|
4431
|
+
|
4432
|
+
}
|
4433
|
+
}
|
4434
|
+
horizontal_box{
|
4435
|
+
stretchy false
|
4436
|
+
label('※수량은 이미지 하나를 분할하려는 수이며, 블로그 규정에 맞게 최대10 이하로 설정해주세요'){
|
4437
|
+
}
|
4438
|
+
}
|
4203
4439
|
}
|
4204
4440
|
}
|
4205
4441
|
}
|
@@ -4221,26 +4457,7 @@ class Wordpress
|
|
4221
4457
|
text '특정단어'
|
4222
4458
|
}
|
4223
4459
|
|
4224
|
-
|
4225
|
-
# top 1
|
4226
|
-
# left 0
|
4227
|
-
# }
|
4228
|
-
# @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
|
4229
|
-
# top 1
|
4230
|
-
# left 1
|
4231
|
-
# on_clicked{
|
4232
|
-
# file = open_file
|
4233
|
-
# if file != nil
|
4234
|
-
# file_data = File.open(file, 'r', :encoding => 'utf-8').read()
|
4235
|
-
# file_data.split("\n").each do |i|
|
4236
|
-
# i2 = i.split('>')
|
4237
|
-
# text_key = i2[0].to_s
|
4238
|
-
# text_val = i2[1].to_s.split(',')
|
4239
|
-
# @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
|
4240
|
-
# end
|
4241
|
-
# end
|
4242
|
-
# }
|
4243
|
-
# }
|
4460
|
+
|
4244
4461
|
@data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
|
4245
4462
|
top 2
|
4246
4463
|
left 0
|
@@ -4565,16 +4782,6 @@ class Wordpress
|
|
4565
4782
|
}
|
4566
4783
|
|
4567
4784
|
|
4568
|
-
# @data['포스트설정']['슬라이드로변경'] = checkbox('특정단어를 슬라이드사진 변경'){
|
4569
|
-
# top 6
|
4570
|
-
# left 0
|
4571
|
-
# }
|
4572
|
-
# @data['포스트설정']['단어슬라이드변경'] = entry{
|
4573
|
-
# top 6
|
4574
|
-
# left 1
|
4575
|
-
# text '특정단어'
|
4576
|
-
# }
|
4577
|
-
|
4578
4785
|
@data['포스트설정']['스티커로변경'] = checkbox('특정단어를 스티커로 변경'){
|
4579
4786
|
top 6
|
4580
4787
|
left 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nblog_duo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|