nblog_duo 0.0.7 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nblog_duo.rb +597 -421
  3. metadata +2 -2
data/lib/nblog_duo.rb CHANGED
@@ -549,7 +549,7 @@ class Naver
549
549
  sleep(1)
550
550
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]'))
551
551
 
552
- sleep(2)
552
+ sleep(1)
553
553
  page_data = @driver.page_source
554
554
  loading_counter = 1
555
555
  begin
@@ -568,7 +568,7 @@ class Naver
568
568
  begin
569
569
  sleep(1)
570
570
  puts '[작성 중인 글이 있습니다] 팝업 체크 중 (약 10초 소요)...'
571
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
571
+ wait = Selenium::WebDriver::Wait.new(:timeout => 9)
572
572
  #요소가 나타날 때까지 60초 동안 기다립니다.
573
573
  wait.until { @driver.find_element(:xpath, '//*[@class="se-popup-button se-popup-button-cancel"]') }
574
574
  sleep(1)
@@ -581,8 +581,8 @@ class Naver
581
581
  end
582
582
 
583
583
  begin
584
- puts '[도움말] 팝업 체크 중 (약 10초 소요)...'
585
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
584
+ puts '[도움말] 팝업 체크 중 (약 3초 소요)...'
585
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
586
586
  #요소가 나타날 때까지 60초 동안 기다립니다.
587
587
  wait.until { @driver.find_element(:xpath, '//*[@class="se-help-panel-close-button"]') }
588
588
  sleep(1)
@@ -594,79 +594,103 @@ class Naver
594
594
  puts '[도움말] 팝업 팝업을 발견하지못했습니다! 다음으로 진행합니다...'
595
595
  end
596
596
 
597
- ele = @driver.find_element(:xpath, '//*[@id="'+title_id+'"]/div[1]/div')
597
+
598
+ template = option['template']
599
+ begin
600
+
601
+ if template.to_s == ''
602
+
603
+ else
604
+ @driver.find_element(:xpath, '//*[@data-name="template"]').click
605
+ sleep(1.5)
606
+
607
+ @driver.find_element(:xpath, '//*[@data-log="ltpl.my"]').click
608
+ sleep(1)
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') }
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
613
+ puts '탬플릿 ['+template.to_s+'] 번을 사용합니다'
614
+ sleep(1)
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') }
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
619
+ puts '탬플릿 ['+template.to_s+'] 번을 찾지못해 첫번째 탬플릿을 사용합니다.'
620
+ sleep(1)
621
+ end
622
+
623
+ begin
624
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
625
+ alert = wait.until { @driver.switch_to.alert }
626
+ sleep(1)
627
+ @driver.switch_to.alert.accept
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
+
640
+ @driver.find_element(:xpath, '//*[@data-name="template"]').click
641
+ sleep(1)
642
+ end
643
+ rescue
644
+ end
645
+
646
+
647
+ #제목 입력
648
+ ele = @driver.find_element(:xpath, '//*[@draggable="false"]')
598
649
  @driver.action.click(ele).perform
599
- sleep(2)
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
+
600
662
  title = title.strip
601
663
  @driver.action.send_keys(title).perform
602
- sleep(2)
603
- @driver.action.key_down(:enter).key_up(:enter).perform
604
- sleep(2)
605
-
606
- # category = get_category()
607
- # puts category
608
- # puts category[option['category']].to_s
609
- # puts option['category']
610
- # category_value = ''
611
- # if option['category'].to_s == ''
612
- # category_value = category[category.keys[0]].to_s
613
- # else
614
- # category_value = category[option['category'].force_encoding('utf-8').to_s].to_s
615
- # end
616
- # if category_value == ''
617
- # category_value = category[category.keys[0]].to_s
618
- # end
664
+ sleep(1)
665
+ @driver.action.key_down(:down).key_up(:down).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
+
680
+
681
+
682
+
683
+
684
+
619
685
 
620
686
  puts content
621
687
  noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
622
688
  toomung = 0
623
689
  h = Hash.new
624
- # h[:authority] = 'blog.naver.com'
625
- # h[:method] = 'POST'
626
- # h[:path] = '/RabbitWrite.naver'
627
- # h[:scheme] = 'https'
628
- # h['accept'] = 'application/json, text/plain, */*'
629
- # h['accept-encoding'] = 'gzip, deflate, br'
630
- # h['accept-language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
631
- # h['content-type'] = 'application/x-www-form-urlencoded'
632
- # h['cookie'] = @cookie
633
- # h['origin'] = 'https://blog.naver.com'
634
- # h['referer'] = 'https://blog.naver.com/'+@user_id+'/postwrite?categoryNo=1'
635
- # h['sec-ch-ua'] = '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"'
636
- # h['sec-ch-ua-mobile'] = '?0'
637
- # h['sec-ch-ua-platform'] = '"Windows"'
638
- # h['sec-fetch-dest'] = 'empty'
639
- # h['sec-fetch-mode'] = 'cors'
640
- # h['sec-fetch-site'] = 'same-origin'
641
- # h['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'
690
+
642
691
 
643
692
  data = Hash.new
644
- # data['blogId'] = @user_id
645
- # data['documentModel'] = Hash.new
646
- # data['documentModel']['documentId'] = ''
647
- # data['documentModel']['document'] = Hash.new
648
- # data['documentModel']['document']['version'] = '2.6.0'
649
- # data['documentModel']['document']['theme'] = 'default'
650
- # data['documentModel']['document']['language'] = 'ko-KR'
651
- # data['documentModel']['document']['components'] = Array.new
652
- # data['documentModel']['document']['components'][0] = {
653
- # 'id' => create_id(),
654
- # 'layout' => 'default',
655
- # 'title' => [
656
- # {
657
- # 'id' => create_id(),
658
- # 'nodes' => [{
659
- # 'id' => create_id(),
660
- # 'value' => title,
661
- # '@ctype' => 'textNode'
662
- # }],
663
- # '@ctype' => 'paragraph'
664
- # }
665
- # ],
666
- # 'subTitle' => nil,
667
- # 'align' => 'left',
668
- # '@ctype' => 'documentTitle'
669
- # }
693
+
670
694
 
671
695
  check_position = 1
672
696
  noko.css('p').each do |i|
@@ -687,15 +711,20 @@ class Naver
687
711
  sleep(1)
688
712
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[12]/div/div/button[2]').click
689
713
  sleep(1)
714
+ #@driver.actions.key_down(:control).key_down(:alt).send_keys('l').key_up(:alt).key_up(:control).perform
715
+
690
716
  elsif i.to_s.include?('right')
691
717
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[12]/div/button').click
692
718
  sleep(1)
693
719
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[12]/div/div/button[3]').click
694
720
  sleep(1)
721
+ #@driver.actions.key_down(:control).key_down(:alt).send_keys('r').key_up(:alt).key_up(:control).perform
722
+
695
723
  else
696
-
724
+
697
725
  end
698
726
  end
727
+
699
728
 
700
729
  i.children.each do |i2|
701
730
  puts i.to_s
@@ -703,34 +732,67 @@ class Naver
703
732
  node_value = Hash.new
704
733
  node_value['id'] = create_id()
705
734
  node_value['@ctype'] = 'textNode'
706
- sleep(1)
735
+ #sleep(1)
707
736
  if i2.to_s.include?('<img')
708
737
  path = i2.to_s.split('src="')[1].split('"')[0]
709
738
  path = URI.decode_www_form(path)[0][0]
710
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
711
- sleep(2)
712
- Clipboard.copy(path.split('/').join("\\"))
713
- key_down('ctrl')
714
- key_stroke('v')
715
- key_up('ctrl')
716
- sleep(3)
717
- key_stroke('enter')
718
- sleep(3)
719
- # @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
720
- # puts path = CGI.unescape(path)
721
- # image_data = image_update(path)
722
- # components_value = Hash.new
723
- # components_value['id'] = create_id()
724
- # components_value['layout'] = 'default'
725
- # begin
726
- # if i.to_s.split('text-align: ')[1].split(';')[0] == 'center'
727
- # components_value['align'] = 'center'
728
- # elsif i.to_s.split('text-align: ')[1].split(';')[0] == 'right'
729
- # components_value['align'] = 'right'
730
- # else
731
-
732
- # end
733
- # rescue
739
+ if option['라이브러리사용안함'] == 'true'
740
+ # 현재 탭의 URL을 가져오기
741
+
742
+ posting_url = @driver.current_url
743
+ @driver.execute_script("window.open('#{posting_url}');")
744
+ sleep(1)
745
+ @driver.switch_to.window(@driver.window_handles[1])
746
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
747
+ iframe = wait.until { @driver.find_element(id: 'mainFrame') }
748
+ @driver.switch_to.frame(iframe)
749
+ begin
750
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
751
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-popup-button-text"]') }
752
+ @driver.find_element(:xpath, '//*[@class="se-popup-button-text"]').click
753
+ sleep(1)
754
+ rescue
755
+ end
756
+ @driver.action.key_down(:control).key_down(:alt).send_keys('i').key_up(:alt).key_up(:control).perform
757
+ sleep(1)
758
+ Clipboard.copy(path.split('/').join("\\"))
759
+ key_down('ctrl')
760
+ key_stroke('v')
761
+ key_up('ctrl')
762
+ sleep(1)
763
+ key_stroke('enter')
764
+ sleep(2)
765
+ @driver.action.send_keys(:up).perform
766
+ sleep(1)
767
+ @driver.action.key_down(:control).send_keys('c').key_up(:control).perform
768
+ sleep(1)
769
+ @driver.switch_to.default_content()
770
+ @driver.close
771
+ sleep(1)
772
+ @driver.switch_to.window(@driver.window_handles[0])
773
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
774
+ iframe = wait.until { @driver.find_element(id: 'mainFrame') }
775
+ @driver.switch_to.frame(iframe)
776
+ #@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
777
+ key_down('ctrl')
778
+ key_stroke('v')
779
+ key_up('ctrl')
780
+ sleep(1)
781
+
782
+ else
783
+ #@driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
784
+ @driver.action.key_down(:control).key_down(:alt).send_keys('i').key_up(:alt).key_up(:control).perform
785
+ sleep(2)
786
+ Clipboard.copy(path.split('/').join("\\"))
787
+ key_down('ctrl')
788
+ key_stroke('v')
789
+ key_up('ctrl')
790
+ sleep(1)
791
+ key_stroke('enter')
792
+ sleep(2)
793
+ end
794
+
795
+
734
796
 
735
797
  if i2.to_s.split('href="')[1] != nil
736
798
  href2 = i2.to_s.split('href="')[1].split('"')[0]
@@ -759,9 +821,7 @@ class Naver
759
821
  sleep(1)
760
822
  end
761
823
 
762
-
763
-
764
-
824
+
765
825
  # end
766
826
  # components_value['src'] = 'https://blogfiles.pstatic.net'+image_data['item']['url']+'?type=w1'
767
827
  # components_value['internalResource'] = true
@@ -815,6 +875,167 @@ class Naver
815
875
  @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
816
876
  sleep(3)
817
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
+
818
1039
  elsif i2.to_s.include?('<inyonggoo')
819
1040
  if i2.text == ''
820
1041
 
@@ -850,6 +1071,11 @@ class Naver
850
1071
  # components_value['source'] = nil
851
1072
  # components_value['@ctype'] = 'quotation'
852
1073
  end
1074
+
1075
+
1076
+
1077
+
1078
+
853
1079
  elsif i2.to_s.include?('<sticker')
854
1080
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[4]/button').click
855
1081
  sleep(1)
@@ -867,75 +1093,6 @@ class Naver
867
1093
  sleep(1)
868
1094
 
869
1095
 
870
- elsif i2.to_s.include?('<template')
871
- @driver.find_element(:xpath, '//*[@data-name="template"]').click
872
- sleep(1.5)
873
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[1]/aside/div/div[2]/ul/li[3]/button').click
874
- sleep(1.5)
875
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[1]/aside/div/div[3]/div[1]/div[2]/ul/li/a').click
876
- sleep(1.5)
877
- @driver.switch_to.alert.accept
878
- sleep(5)
879
- @driver.find_element(:xpath, '//*[@data-name="template"]').click
880
- #sleep(1)
881
- #@driver.find_element(:xpath, '//*[@class="save_count_btn__ZTLNa"]').click
882
- #sleep(1)
883
- #@driver.find_element(:xpath, '//*[@id="root"]/div/div[2]/div[2]/div[3]/div/div[2]/div[2]/div/button').click
884
- #sleep(1)
885
- #@driver.find_element(:xpath, '//*[@class="label__HjFsk"]').click
886
- #sleep(1)
887
- #@driver.find_element(:xpath, '//*[@id="root"]/div/div[2]/div[2]/div[3]/div/div[2]/div[2]/div/div/button[2]').click
888
- #sleep(1.5)
889
- #@driver.switch_to.alert.accept
890
- #sleep(1.5)
891
- #@driver.find_element(:xpath, '//*[@id="root"]/div/div[2]/div[2]/div[3]/div/div[2]/div[2]/div/div/button[3]').click
892
- #sleep(1)
893
- #@driver.find_element(:xpath, '//*[@class="close_button__YWXJ_"]').click
894
-
895
-
896
-
897
- #제목 다시 입력
898
- ele = @driver.find_element(:xpath, '//*[@draggable="false"]')
899
- @driver.action.click(ele).perform
900
- sleep(1)
901
- @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
902
- sleep(1)
903
- @driver.action.key_down(:delete).key_up(:delete).perform
904
- sleep(2)
905
- title = title.strip
906
- @driver.action.send_keys(title).perform
907
- sleep(2)
908
- @driver.action.key_down(:enter).key_up(:enter).perform
909
- sleep(2)
910
- @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
911
- sleep(1)
912
- @driver.action.key_down(:down).key_up(:down).perform
913
-
914
- # components_value = Hash.new
915
- # components_value['id'] = create_id()
916
- # components_value['layout'] = 'default'
917
- # begin
918
- # if i.to_s.split('text-align: ')[1].split(';')[0] == 'center'
919
- # components_value['align'] = 'center'
920
- # elsif i.to_s.split('text-align: ')[1].split(';')[0] == 'right'
921
- # components_value['align'] = 'right'
922
- # else
923
-
924
- # end
925
- # rescue
926
-
927
- # end
928
- # sticker_random = rand(1..9)
929
- # components_value['packCode'] = 'linesoft_01'
930
- # components_value['seq'] = sticker_random
931
- # components_value['thumbnail'] = {
932
- # 'src' => "https://storep-phinf.pstatic.net/linesoft_01/original_"+sticker_random.to_s+".gif",
933
- # "width" => 185,
934
- # 'height' => 160,
935
- # '@ctype' => 'thumbnail'
936
- # }
937
- # components_value['format'] = "animated"
938
- # components_value['@ctype'] = "sticker"
939
1096
  elsif i2.to_s.include?('<koreamap')
940
1097
  where = i2.to_s.split('>')[1].split('<')[0]
941
1098
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[7]/button').click
@@ -1106,49 +1263,6 @@ class Naver
1106
1263
  @driver.action.key_down(:space).key_up(:space).perform
1107
1264
  @driver.action.key_down(:left).key_up(:left).perform
1108
1265
  end
1109
-
1110
- # begin
1111
- # if i.to_s.split('text-align: ')[1].split(';')[0] == 'center'
1112
- # if value_data['style'] == nil
1113
- # value_data['style'] = Hash.new
1114
- # end
1115
- # value_data['style']['align'] = 'center'
1116
- # value_data['style']['@ctype'] = 'paragraphStyle'
1117
- # elsif i.to_s.split('text-align: ')[1].split(';')[0] == 'right'
1118
- # if value_data['style'] == nil
1119
- # value_data['style'] = Hash.new
1120
- # end
1121
- # value_data['style']['align'] = 'right'
1122
- # value_data['style']['@ctype'] = 'paragraphStyle'
1123
- # else
1124
-
1125
- # end
1126
- # rescue => e
1127
- # puts e
1128
-
1129
- # end
1130
-
1131
- # if toomung == 1
1132
- # if node_value['style'] == nil
1133
- # node_value['style'] = Hash.new
1134
- # end
1135
- # node_value['style']['fontSizeCode'] = 'fs0'
1136
- # end
1137
-
1138
- # if i2.to_s.include?('<a href="')
1139
- # if i2.to_s.include?('<img src=')
1140
-
1141
- # else
1142
- # node_value['link'] = {
1143
- # 'url' => i2.to_s.split('href="')[1].split('"')[0],
1144
- # '@ctype' => 'urlLink'
1145
- # }
1146
- # end
1147
- # end
1148
-
1149
- # if node_value['style'] != nil
1150
- # node_value['style']['@ctype'] = 'nodeStyle'
1151
- # end
1152
1266
  end
1153
1267
 
1154
1268
  if check_image == 0
@@ -1236,50 +1350,14 @@ class Naver
1236
1350
  end
1237
1351
  end
1238
1352
  end
1239
- sleep(1)
1353
+ sleep(0.5)
1240
1354
  @driver.action.key_down(:end).key_up(:end).perform
1241
- sleep(1)
1355
+ sleep(0.5)
1242
1356
  @driver.action.key_down(:enter).key_up(:enter).perform
1243
- sleep(1)
1244
- # if check_image == 0
1245
- # if value_data['nodes'].length == 0
1246
- # value_data['nodes'][0] = {
1247
- # 'id' => create_id(),
1248
- # '@ctype' => 'textNode',
1249
- # 'value' => ''
1250
- # }
1251
- # end
1252
- # begin
1253
- # components_value['value'] << value_data
1254
- # rescue
1255
-
1256
- # end
1257
- # end
1258
-
1259
- # if components_value['value'] != nil
1260
- # if components_value['value'].length == 0
1261
- # components_value['value'][0] = {
1262
- # 'id' => create_id(),
1263
- # 'nodes' => [{
1264
- # 'id' => create_id(),
1265
- # '@ctype' => 'textNode',
1266
- # 'value' => ''
1267
- # }],
1268
- # '@ctype' => 'paragraph'
1269
- # }
1270
- # end
1271
- # end
1272
- # data['documentModel']['document']['components'] << components_value
1357
+ sleep(0.5)
1273
1358
  end
1274
1359
 
1275
1360
  if soosick_1 != ''
1276
- # data['documentModel']['document']['components'] << {
1277
- # 'id' => create_id(),
1278
- # 'layout' => 'default',
1279
- # 'fontSizeCode' => 'fs13',
1280
- # 'codeContents' => soosick_1,
1281
- # '@ctype' => 'code'
1282
- # }
1283
1361
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[13]/button').click
1284
1362
  sleep(3)
1285
1363
  # @driver.action.send_keys(soosick_1.text).perform
@@ -1291,13 +1369,6 @@ class Naver
1291
1369
  end
1292
1370
 
1293
1371
  if soosick_2 != ''
1294
- # data['documentModel']['document']['components'] << {
1295
- # 'id' => create_id(),
1296
- # 'layout' => 'default',
1297
- # 'fontSizeCode' => 'fs13',
1298
- # 'codeContents' => soosick_2,
1299
- # '@ctype' => 'code'
1300
- # }
1301
1372
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[13]/button').click
1302
1373
  sleep(3)
1303
1374
  # @driver.action.send_keys(soosick_2).perform
@@ -1308,6 +1379,32 @@ class Naver
1308
1379
  sleep(3)
1309
1380
  end
1310
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
+
1311
1408
  @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]').click #1차 등록버튼
1312
1409
  sleep(3)
1313
1410
  category = option['category']
@@ -1448,45 +1545,13 @@ class Naver
1448
1545
 
1449
1546
  end
1450
1547
 
1451
-
1452
-
1453
-
1454
-
1455
-
1456
- #sleep(dd_time.to_i)
1457
- #@driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[8]/div/button').click
1458
-
1459
- #sleep(10)
1460
1548
  begin
1461
1549
  @driver.close
1462
1550
  rescue
1463
1551
 
1464
1552
  end
1465
1553
 
1466
- # if option['proxy'] == ''
1467
- # http = HTTP.headers(h).post('https://api-blog.blog.naver.com/rabbit/auto/save', :form => data)
1468
- # else
1469
- # ip = option['proxy'].to_s.split(':')[0]
1470
- # port = option['proxy'].to_s.split(':')[1]
1471
- # http = HTTP.via(ip, port.to_i).headers(h).post('https://api-blog.blog.naver.com/rabbit/auto/save', :form => data)
1472
- # end
1473
- # puts http.to_s
1474
- # http.cookies.each do |i|
1475
- # puts i
1476
- # end
1477
- # sleep(3)
1478
- # data['productApiVersion'] = 'v1'
1479
- # if option['proxy'] == ''
1480
- # http = HTTP.headers(h).post('https://blog.naver.com/RabbitWrite.naver', :form => data)
1481
- # else
1482
- # ip = option['proxy'].to_s.split(':')[0]
1483
- # port = option['proxy'].to_s.split(':')[1]
1484
- # http = HTTP.via(ip, port.to_i).headers(h).post('https://blog.naver.com/RabbitWrite.naver', :form => data)
1485
- # end
1486
- # puts http.to_s
1487
- # http.cookies.each do |i|
1488
- # puts i
1489
- # end
1554
+
1490
1555
  end
1491
1556
  end
1492
1557
 
@@ -2026,7 +2091,7 @@ class Wordpress
2026
2091
  @video = Array.new
2027
2092
  while true
2028
2093
  for n in 0..@data['table'].length-1
2029
- @data['table'][n][10] = 0
2094
+ @data['table'][n][11] = 0
2030
2095
  end
2031
2096
 
2032
2097
  while true
@@ -2064,6 +2129,17 @@ class Wordpress
2064
2129
  rescue
2065
2130
  option['bun'] = ''
2066
2131
  end
2132
+
2133
+ begin
2134
+ option['template'] = table[7].to_s.force_encoding('utf-8').to_s
2135
+ if option['template'].to_s == '템플릿 사용시 번호 ex)1' || option['template'].to_s == '0'
2136
+ option['template'] = ''
2137
+
2138
+ end
2139
+ rescue
2140
+ option['template'] = ''
2141
+ end
2142
+
2067
2143
 
2068
2144
  option['proxy'] = ''
2069
2145
  if @data['포스트설정']['프록시'].checked?
@@ -2074,7 +2150,7 @@ class Wordpress
2074
2150
  end
2075
2151
  end
2076
2152
 
2077
- if table[7].to_i > table[10].to_i
2153
+ if table[8].to_i > table[11].to_i
2078
2154
  if @data['포스트설정']['테더링'].checked?
2079
2155
  puts 'tedering ip change...'
2080
2156
  stdout, stderr, status = Open3.capture3('./adb devices')
@@ -2128,7 +2204,7 @@ class Wordpress
2128
2204
  gpt_text1 = chat.message(title)
2129
2205
  title = gpt_text1.to_s
2130
2206
  end
2131
-
2207
+
2132
2208
 
2133
2209
  @data['table'][index][-1] = 5
2134
2210
  @data['table'] << []
@@ -2168,6 +2244,7 @@ class Wordpress
2168
2244
  end
2169
2245
  end
2170
2246
 
2247
+
2171
2248
  if @data['포스트설정']['gpt내용'].checked?
2172
2249
  api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
2173
2250
  #key_change = @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8')
@@ -2184,7 +2261,7 @@ class Wordpress
2184
2261
  gpt_text3 = chat.message(content)
2185
2262
  content = gpt_text3.to_s
2186
2263
  end
2187
-
2264
+
2188
2265
  content_tag = content.split('@##@')[1]
2189
2266
  content = content.split('@##@')[0]
2190
2267
  @data['table'][index][-1] = 15
@@ -2635,50 +2712,7 @@ class Wordpress
2635
2712
  end
2636
2713
 
2637
2714
  position = position.sort
2638
- ###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
2639
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2640
- # image_url22 = get_image_file().force_encoding('utf-8')
2641
- # end
2642
-
2643
- # position.each do |i|
2644
- # image_url = get_image_file().force_encoding('utf-8')
2645
- # puts image_url
2646
-
2647
- # puts '사진넣는위치 => '+i.to_s
2648
- # if @data['포스트설정']['내용사진링크'].checked?
2649
- # image_memory << ""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword.force_encoding('utf-8')+'"></a>'+""
2650
- # content5.insert(i, '**image**')
2651
- # else
2652
- # image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'" class="aligncenter size-full">'+""
2653
- # content5.insert(i, '**image**')
2654
- # end
2655
- # end
2656
-
2657
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2658
- # content = content5.join("\n")+'(자동생성글)'+content55
2659
- # iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
2660
- # content = iconv.iconv(content)
2661
- # content = content.encode('UTF-8', 'binary', invalid: :replace, replace: '')
2662
- # puts content
2663
- # image_url = image_url22
2664
-
2665
- # if @data['포스트설정']['자동글 수식에 입력'].checked?
2666
-
2667
- # else
2668
- # if @data['포스트설정']['내용사진링크'].checked?
2669
- # content = content.split('(자동생성글)')[0]+""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2670
- # else
2671
- # content = content.split('(자동생성글)')[0]+""+'<img src="'+image_url+'" alt="'+keyword+'" >'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2672
- # end
2673
- # end
2674
- # else
2675
- # content = content5.join("\n")
2676
- # end
2677
- # end
2678
- # end
2679
- ###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
2680
-
2681
- ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
2715
+
2682
2716
  if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2683
2717
  sleep(2)
2684
2718
  puts '이미지 자동 세탁 중 · · · '
@@ -2706,6 +2740,8 @@ class Wordpress
2706
2740
  end
2707
2741
  end
2708
2742
  end
2743
+
2744
+
2709
2745
  ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
2710
2746
  @data['table'][index][-1] = 70
2711
2747
  @data['table'] << []
@@ -2737,12 +2773,7 @@ class Wordpress
2737
2773
  ttr = 0
2738
2774
  @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2739
2775
  ttr = 1
2740
- # image_url = get_image_file().force_encoding('utf-8')
2741
- # if @data['포스트설정']['내용사진링크'].checked?
2742
- # content = content.split(i.force_encoding('utf-8')).join('<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>')
2743
- # else
2744
- # content = content.split(i.force_encoding('utf-8')).join('<img src="'+image_url+'" alt="'+keyword+'">')
2745
- # end
2776
+
2746
2777
  content = content.split(i.force_encoding('utf-8'))
2747
2778
  content.each_with_index do |ccm, index3|
2748
2779
  if index3 == content.length-1
@@ -2752,6 +2783,7 @@ class Wordpress
2752
2783
  if i.force_encoding('utf-8').to_s.include?('@')
2753
2784
  image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
2754
2785
  content[index3] = content[index3] + '**image()**'
2786
+
2755
2787
  else
2756
2788
  image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
2757
2789
  content[index3] = content[index3] + '**image**'
@@ -2761,6 +2793,61 @@ class Wordpress
2761
2793
  content = content.join('')
2762
2794
  end
2763
2795
  end
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
2764
2851
 
2765
2852
  con_memory = Array.new
2766
2853
  index5 = 0
@@ -2801,14 +2888,6 @@ class Wordpress
2801
2888
 
2802
2889
 
2803
2890
 
2804
- if @data['포스트설정']['내템플릿사용하기'].checked?
2805
- @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2806
- content = content.split(i.force_encoding('utf-8')).join("<template></template>")
2807
- end
2808
- end
2809
-
2810
-
2811
-
2812
2891
  if @data['포스트설정']['영상으로변경'].checked?
2813
2892
  if @video.length == 0
2814
2893
  path = @data['포스트설정']['동영상폴더위치'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
@@ -2946,9 +3025,11 @@ class Wordpress
2946
3025
 
2947
3026
  end
2948
3027
 
2949
-
2950
-
2951
-
3028
+ if @data['포스트설정']['라이브러리사용안함'].checked?
3029
+ option['라이브러리사용안함'] = 'true'
3030
+ else
3031
+ option['라이브러리사용안함'] = 'false'
3032
+ end
2952
3033
 
2953
3034
  if @data['포스트설정']['외부공유허용'].checked?
2954
3035
  option['외부공유허용'] = 'true'
@@ -2986,21 +3067,31 @@ class Wordpress
2986
3067
 
2987
3068
  if @data['포스트설정']['중앙정렬'].checked?
2988
3069
  content = content.split("\n").map {|row| '<p style="text-align: center;">'+row+'</p>'}.join("\n")
3070
+ option['중앙정렬'] = 'true'
3071
+ else
3072
+ option['중앙정렬'] = 'false'
2989
3073
  end
2990
3074
 
2991
3075
  if @data['포스트설정']['우측정렬'].checked?
2992
3076
  content = content.split("\n").map {|row| '<p style="text-align: right;">'+row+'</p>'}.join("\n")
3077
+ option['우측정렬'] = 'true'
3078
+ else
3079
+ option['우측정렬'] = 'false'
2993
3080
  end
2994
3081
 
2995
3082
  if @data['포스트설정']['좌측정렬'].checked?
2996
3083
  content = content.split("\n").map {|row| '<p style="text-align: left;">'+row+'</p>'}.join("\n")
3084
+ option['좌측정렬'] = 'true'
3085
+ else
3086
+ option['좌측정렬'] = 'false'
2997
3087
  end
2998
3088
 
2999
3089
  @data['table'][index][-1] = 90
3000
3090
  @data['table'] << []
3001
3091
  @data['table'].pop
3002
3092
 
3003
- dd_time = @data['table'][index][9].to_s.force_encoding('utf-8').to_i
3093
+ dd_time = @data['table'][index][10].to_s.force_encoding('utf-8').to_i
3094
+ template_no = @data['table'][index][7].to_s.force_encoding('utf-8').to_i
3004
3095
  naver.update(title,content,option,soosick_1,soosick_2, dd_time)
3005
3096
 
3006
3097
 
@@ -3019,11 +3110,11 @@ class Wordpress
3019
3110
  # @data2['content'] = content+'</div>'
3020
3111
 
3021
3112
  #완료했으니 수량 카운터
3022
- @data['table'][index][10] = @data['table'][index][10].to_i + 1
3113
+ @data['table'][index][11] = @data['table'][index][11].to_i + 1
3023
3114
  @data['table'][index][-1] = 100
3024
3115
  @data['table'] << []
3025
3116
  @data['table'].pop
3026
- sleep(@data['table'][index][8].to_i)
3117
+ sleep(@data['table'][index][9].to_i)
3027
3118
  end
3028
3119
  # rescue => exception
3029
3120
  # puts exception
@@ -3303,8 +3394,8 @@ class Wordpress
3303
3394
  end
3304
3395
 
3305
3396
  if i.class == Array
3306
- i[7] = i[7].to_i
3307
3397
  i[8] = i[8].to_i
3398
+ i[9] = i[9].to_i
3308
3399
  @data[key] << i
3309
3400
  @data[key] << i
3310
3401
  @data[key].pop
@@ -3374,11 +3465,14 @@ class Wordpress
3374
3465
  @data['bun'] = entry{
3375
3466
  text '예약 발행 분 단위 ex)00'
3376
3467
  }
3468
+ @data['template'] = entry{
3469
+ text '템플릿 사용시 번호 ex)1'
3470
+ }
3377
3471
 
3378
3472
  button('등록'){
3379
3473
  on_clicked {
3380
- @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['category'].text , @data['proxy'].text , @data['sigan'].text, @data['bun'].text, 1, 1, 1, 0,0]
3381
- @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['category'].text , @data['proxy'].text , @data['sigan'].text, @data['bun'].text, 1, 1, 1, 0,0]
3474
+ @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['category'].text , @data['proxy'].text , @data['sigan'].text, @data['bun'].text, @data['template'].text, 1, 1, 1, 0,0]
3475
+ @data['table'] << [false, @data['site_id_input'].text, @data['site_pw_input'].text,@data['category'].text , @data['proxy'].text , @data['sigan'].text, @data['bun'].text, @data['template'].text,1, 1, 1, 0,0]
3382
3476
  @data['table'].pop
3383
3477
  }
3384
3478
  }
@@ -3390,8 +3484,8 @@ class Wordpress
3390
3484
  file_data.split("\n").each do |i|
3391
3485
  i3 = i.to_s.force_encoding('utf-8').to_s
3392
3486
  i2 = i3.split(',')
3393
- @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s,i2[4].to_s,i2[5].to_s, 1,1,1,0,0]
3394
- @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s,i2[4].to_s,i2[5].to_s, 1,1,1,0,0]
3487
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s,i2[4].to_s,i2[5].to_s,i2[6].to_s, 1,1,1,0,0]
3488
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s,i2[4].to_s,i2[5].to_s,i2[6].to_s, 1,1,1,0,0]
3395
3489
  @data['table'].pop
3396
3490
  end
3397
3491
  end
@@ -3426,6 +3520,9 @@ class Wordpress
3426
3520
  text_column('예약 분'){
3427
3521
  editable true
3428
3522
  }
3523
+ text_column('템플릿 넘버'){
3524
+ editable true
3525
+ }
3429
3526
 
3430
3527
 
3431
3528
  text_column('수량'){
@@ -3492,7 +3589,11 @@ class Wordpress
3492
3589
 
3493
3590
  grid{
3494
3591
  stretchy false
3495
-
3592
+ @data['table_template_input'] = entry{
3593
+ top 1
3594
+ left 3
3595
+ text '템플릿 넘버 ex) 3'
3596
+ }
3496
3597
  @data['table_counter_input'] = entry{
3497
3598
  top 1
3498
3599
  left 4
@@ -3506,7 +3607,7 @@ class Wordpress
3506
3607
  @data['table_delay_input2'] = entry{
3507
3608
  top 1
3508
3609
  left 6
3509
- text '등록전딜레이'
3610
+ text '등록 전 딜레이'
3510
3611
  }
3511
3612
 
3512
3613
  button('전체설정'){
@@ -3514,9 +3615,10 @@ class Wordpress
3514
3615
  left 7
3515
3616
  on_clicked{
3516
3617
  for n in 0..@data['table'].length-1
3517
- @data['table'][n][7] = @data['table_counter_input'].text.to_i
3518
- @data['table'][n][8] = @data['table_delay_input'].text.to_s
3519
- @data['table'][n][9] = @data['table_delay_input2'].text.to_s
3618
+ @data['table'][n][7] = @data['table_template_input'].text.to_i
3619
+ @data['table'][n][8] = @data['table_counter_input'].text.to_i
3620
+ @data['table'][n][9] = @data['table_delay_input'].text.to_s
3621
+ @data['table'][n][10] = @data['table_delay_input2'].text.to_s
3520
3622
  @data['table'] << []
3521
3623
  @data['table'].pop
3522
3624
  end
@@ -3910,20 +4012,35 @@ class Wordpress
3910
4012
  stretchy false
3911
4013
  text "내용폴더경로 ex)C:\\내용\\폴더1"
3912
4014
  }
3913
- button('폴더째로 불러오기'){
3914
-
3915
- on_clicked{
3916
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3917
- Dir.entries(@data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')).each do |file|
3918
- if file == '.' or file == '..'
3919
4015
 
3920
- else
3921
- file_data = File.open(path+'/'+file,'r', :encoding => 'utf-8').read()
3922
- @data['내용설정']['내용'] << [false, file, file_data]
4016
+ button('폴더째로 불러오기') {
4017
+ on_clicked {
4018
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4019
+
4020
+ # 경로가 유효한지 확인
4021
+ if Dir.exist?(path)
4022
+ Dir.entries(path).each do |file|
4023
+ if file == '.' or file == '..'
4024
+ next
4025
+ else
4026
+ begin
4027
+ # 파일을 열고 내용을 읽어서 추가
4028
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4029
+ @data['내용설정']['내용'] << [false, file, file_data]
4030
+ rescue => e
4031
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
4032
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4033
+ end
4034
+ end
3923
4035
  end
4036
+
4037
+ # 내용 배열에서 마지막 빈 항목 제거
4038
+ @data['내용설정']['내용'] << []
4039
+ @data['내용설정']['내용'].pop
4040
+ else
4041
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
4042
+ puts "경로가 존재하지 않습니다: #{path}"
3924
4043
  end
3925
- @data['내용설정']['내용'] << []
3926
- @data['내용설정']['내용'].pop
3927
4044
  }
3928
4045
  }
3929
4046
  }
@@ -4022,25 +4139,35 @@ class Wordpress
4022
4139
  horizontal_box{
4023
4140
  stretchy false
4024
4141
  @data['이미지설정']['폴더경로'] = entry{
4025
- stretchy false
4026
- text "사진폴더경로 ex)C:\\사진\\폴더2"
4027
- }
4028
- button('폴더째로 불러오기'){
4029
-
4030
- on_clicked{
4031
- path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
4032
- Dir.entries(@data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')).each do |file|
4033
- if file == '.' or file == '..'
4142
+ stretchy false
4143
+ text "사진폴더경로 ex)C:\\사진\\폴더2"
4144
+ }
4145
+
4146
+ button('폴더째로 불러오기') {
4147
+ on_clicked {
4148
+ path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')
4034
4149
 
4150
+ # 경로가 유효한지 확인
4151
+ if Dir.exist?(path)
4152
+ Dir.entries(path).each do |file|
4153
+ if file == '.' or file == '..'
4154
+ next
4035
4155
  else
4036
- @data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
4156
+ # 폴더 내의 파일을 이미지 리스트에 추가
4157
+ @data['이미지설정']['이미지'] << [false, file, path + "\\" + file.force_encoding('utf-8')]
4037
4158
  end
4038
4159
  end
4160
+
4161
+ # 마지막 빈 항목 추가 후 제거 (원래 로직에 맞춰)
4039
4162
  @data['이미지설정']['이미지'] << []
4040
4163
  @data['이미지설정']['이미지'].pop
4041
- }
4164
+ else
4165
+ # 경로가 존재하지 않으면 경고 메시지 출력
4166
+ puts "경로가 존재하지 않습니다: #{path}"
4167
+ end
4042
4168
  }
4043
4169
  }
4170
+ }
4044
4171
 
4045
4172
  }
4046
4173
  vertical_separator{
@@ -4235,6 +4362,80 @@ class Wordpress
4235
4362
  }
4236
4363
  }
4237
4364
  }
4365
+
4366
+ horizontal_box{
4367
+ stretchy false
4368
+ label('※이미지 리스트와 위 세팅을 하였다면 포스트설정1 탭에서 어떤위치(방식)으로 삽입시킬지 세팅이 필요합니다.'){
4369
+ }
4370
+ }
4371
+ horizontal_box{
4372
+ stretchy false
4373
+ label('※이미지를 아래 특정단어 슬라이드 변경 기능만 사용한다면 포스트설정1 탭에서 설정을 할 필요는 없습니다.'){
4374
+ }
4375
+ }
4376
+ vertical_separator{
4377
+ stretchy false
4378
+ }
4379
+ horizontal_box{
4380
+ stretchy false
4381
+ @data['포스트설정']['라이브러리사용안함'] = checkbox('사진 라이브러리에서 제외시키기 적용'){
4382
+
4383
+ }
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
+ }
4238
4439
  }
4239
4440
  }
4240
4441
  }
@@ -4256,26 +4457,7 @@ class Wordpress
4256
4457
  text '특정단어'
4257
4458
  }
4258
4459
 
4259
- # @data['포스트설정']['제목단어변경'] = checkbox('제목에 특정 단어를 변경'){
4260
- # top 1
4261
- # left 0
4262
- # }
4263
- # @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
4264
- # top 1
4265
- # left 1
4266
- # on_clicked{
4267
- # file = open_file
4268
- # if file != nil
4269
- # file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4270
- # file_data.split("\n").each do |i|
4271
- # i2 = i.split('>')
4272
- # text_key = i2[0].to_s
4273
- # text_val = i2[1].to_s.split(',')
4274
- # @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
4275
- # end
4276
- # end
4277
- # }
4278
- # }
4460
+
4279
4461
  @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
4280
4462
  top 2
4281
4463
  left 0
@@ -4579,7 +4761,7 @@ class Wordpress
4579
4761
  text 'URL'
4580
4762
  }
4581
4763
 
4582
- @data['포스트설정']['단어사진으로변경'] = checkbox('내용 특정단어를 사진으로 변경'){
4764
+ @data['포스트설정']['단어사진으로변경'] = checkbox('특정단어를 사진으로 변경'){
4583
4765
  top 4
4584
4766
  left 0
4585
4767
  }
@@ -4599,7 +4781,8 @@ class Wordpress
4599
4781
  text 'URL'
4600
4782
  }
4601
4783
 
4602
- @data['포스트설정']['스티커로변경'] = checkbox('내용 특정단어를 스티커로 변경'){
4784
+
4785
+ @data['포스트설정']['스티커로변경'] = checkbox('특정단어를 스티커로 변경'){
4603
4786
  top 6
4604
4787
  left 0
4605
4788
  }
@@ -4608,7 +4791,7 @@ class Wordpress
4608
4791
  left 1
4609
4792
  text '특정단어'
4610
4793
  }
4611
- @data['포스트설정']['영상으로변경'] = checkbox('내용 특정단어를 영상으로 변경'){
4794
+ @data['포스트설정']['영상으로변경'] = checkbox('특정단어를 영상으로 변경'){
4612
4795
  top 7
4613
4796
  left 0
4614
4797
  }
@@ -4626,7 +4809,7 @@ class Wordpress
4626
4809
  left 1
4627
4810
  text "영상폴더위치 ex) C:\\영상\\폴더3"
4628
4811
  }
4629
- @data['포스트설정']['지도로변경'] = checkbox('내용 특정단어를 지도로 변경'){
4812
+ @data['포스트설정']['지도로변경'] = checkbox('특정단어를 지도로 변경'){
4630
4813
  top 9
4631
4814
  left 0
4632
4815
  }
@@ -4644,7 +4827,7 @@ class Wordpress
4644
4827
  left 1
4645
4828
  text 'ex) OO시 OO구 OO동 270-68'
4646
4829
  }
4647
- @data['포스트설정']['인용구변경'] = checkbox('내용 특정단어를 인용구로 적용'){
4830
+ @data['포스트설정']['인용구변경'] = checkbox('특정단어를 인용구로 적용'){
4648
4831
  top 11
4649
4832
  left 0
4650
4833
  }
@@ -4668,15 +4851,8 @@ class Wordpress
4668
4851
  end
4669
4852
  }
4670
4853
  }
4671
- @data['포스트설정']['내템플릿사용하기'] = checkbox('내 템플릿 사용하기'){
4672
- top 13
4673
- left 0
4674
- }
4675
- @data['포스트설정']['내템플릿변경단어'] = entry{
4676
- top 13
4677
- left 1
4678
- text '탬플릿으로 전활시킬 특정단어'
4679
- }
4854
+
4855
+
4680
4856
  }
4681
4857
  }
4682
4858
  }