nblog_zon 0.0.9 → 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 +594 -419
  3. metadata +2 -2
data/lib/nblog_zon.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
 
@@ -1957,7 +2022,7 @@ class Wordpress
1957
2022
  @video = Array.new
1958
2023
  while true
1959
2024
  for n in 0..@data['table'].length-1
1960
- @data['table'][n][10] = 0
2025
+ @data['table'][n][11] = 0
1961
2026
  end
1962
2027
 
1963
2028
  while true
@@ -1995,6 +2060,17 @@ class Wordpress
1995
2060
  rescue
1996
2061
  option['bun'] = ''
1997
2062
  end
2063
+
2064
+ begin
2065
+ option['template'] = table[7].to_s.force_encoding('utf-8').to_s
2066
+ if option['template'].to_s == '템플릿 사용시 번호 ex)1' || option['template'].to_s == '0'
2067
+ option['template'] = ''
2068
+
2069
+ end
2070
+ rescue
2071
+ option['template'] = ''
2072
+ end
2073
+
1998
2074
 
1999
2075
  option['proxy'] = ''
2000
2076
  if @data['포스트설정']['프록시'].checked?
@@ -2005,7 +2081,7 @@ class Wordpress
2005
2081
  end
2006
2082
  end
2007
2083
 
2008
- if table[7].to_i > table[10].to_i
2084
+ if table[8].to_i > table[11].to_i
2009
2085
  if @data['포스트설정']['테더링'].checked?
2010
2086
  puts 'tedering ip change...'
2011
2087
  stdout, stderr, status = Open3.capture3('./adb devices')
@@ -2567,50 +2643,7 @@ class Wordpress
2567
2643
  end
2568
2644
 
2569
2645
  position = position.sort
2570
- ###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
2571
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2572
- # image_url22 = get_image_file().force_encoding('utf-8')
2573
- # end
2574
-
2575
- # position.each do |i|
2576
- # image_url = get_image_file().force_encoding('utf-8')
2577
- # puts image_url
2578
-
2579
- # puts '사진넣는위치 => '+i.to_s
2580
- # if @data['포스트설정']['내용사진링크'].checked?
2581
- # 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>'+""
2582
- # content5.insert(i, '**image**')
2583
- # else
2584
- # image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'" class="aligncenter size-full">'+""
2585
- # content5.insert(i, '**image**')
2586
- # end
2587
- # end
2588
-
2589
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt'].checked?
2590
- # content = content5.join("\n")+'(자동생성글)'+content55
2591
- # iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
2592
- # content = iconv.iconv(content)
2593
- # content = content.encode('UTF-8', 'binary', invalid: :replace, replace: '')
2594
- # puts content
2595
- # image_url = image_url22
2596
-
2597
- # if @data['포스트설정']['자동글 수식에 입력'].checked?
2598
-
2599
- # else
2600
- # if @data['포스트설정']['내용사진링크'].checked?
2601
- # content = content.split('(자동생성글)')[0]+""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2602
- # else
2603
- # content = content.split('(자동생성글)')[0]+""+'<img src="'+image_url+'" alt="'+keyword+'" >'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2604
- # end
2605
- # end
2606
- # else
2607
- # content = content5.join("\n")
2608
- # end
2609
- # end
2610
- # end
2611
- ###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
2612
-
2613
- ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
2646
+
2614
2647
  if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2615
2648
  sleep(2)
2616
2649
  puts '이미지 자동 세탁 중 · · · '
@@ -2638,6 +2671,8 @@ class Wordpress
2638
2671
  end
2639
2672
  end
2640
2673
  end
2674
+
2675
+
2641
2676
  ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
2642
2677
  @data['table'][index][-1] = 70
2643
2678
  @data['table'] << []
@@ -2669,12 +2704,7 @@ class Wordpress
2669
2704
  ttr = 0
2670
2705
  @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2671
2706
  ttr = 1
2672
- # image_url = get_image_file().force_encoding('utf-8')
2673
- # if @data['포스트설정']['내용사진링크'].checked?
2674
- # 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>')
2675
- # else
2676
- # content = content.split(i.force_encoding('utf-8')).join('<img src="'+image_url+'" alt="'+keyword+'">')
2677
- # end
2707
+
2678
2708
  content = content.split(i.force_encoding('utf-8'))
2679
2709
  content.each_with_index do |ccm, index3|
2680
2710
  if index3 == content.length-1
@@ -2684,6 +2714,7 @@ class Wordpress
2684
2714
  if i.force_encoding('utf-8').to_s.include?('@')
2685
2715
  image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
2686
2716
  content[index3] = content[index3] + '**image()**'
2717
+
2687
2718
  else
2688
2719
  image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
2689
2720
  content[index3] = content[index3] + '**image**'
@@ -2693,6 +2724,61 @@ class Wordpress
2693
2724
  content = content.join('')
2694
2725
  end
2695
2726
  end
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
2696
2782
 
2697
2783
  con_memory = Array.new
2698
2784
  index5 = 0
@@ -2733,14 +2819,6 @@ class Wordpress
2733
2819
 
2734
2820
 
2735
2821
 
2736
- if @data['포스트설정']['내템플릿사용하기'].checked?
2737
- @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2738
- content = content.split(i.force_encoding('utf-8')).join("<template></template>")
2739
- end
2740
- end
2741
-
2742
-
2743
-
2744
2822
  if @data['포스트설정']['영상으로변경'].checked?
2745
2823
  if @video.length == 0
2746
2824
  path = @data['포스트설정']['동영상폴더위치'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
@@ -2878,9 +2956,11 @@ class Wordpress
2878
2956
 
2879
2957
  end
2880
2958
 
2881
-
2882
-
2883
-
2959
+ if @data['포스트설정']['라이브러리사용안함'].checked?
2960
+ option['라이브러리사용안함'] = 'true'
2961
+ else
2962
+ option['라이브러리사용안함'] = 'false'
2963
+ end
2884
2964
 
2885
2965
  if @data['포스트설정']['외부공유허용'].checked?
2886
2966
  option['외부공유허용'] = 'true'
@@ -2918,21 +2998,31 @@ class Wordpress
2918
2998
 
2919
2999
  if @data['포스트설정']['중앙정렬'].checked?
2920
3000
  content = content.split("\n").map {|row| '<p style="text-align: center;">'+row+'</p>'}.join("\n")
3001
+ option['중앙정렬'] = 'true'
3002
+ else
3003
+ option['중앙정렬'] = 'false'
2921
3004
  end
2922
3005
 
2923
3006
  if @data['포스트설정']['우측정렬'].checked?
2924
3007
  content = content.split("\n").map {|row| '<p style="text-align: right;">'+row+'</p>'}.join("\n")
3008
+ option['우측정렬'] = 'true'
3009
+ else
3010
+ option['우측정렬'] = 'false'
2925
3011
  end
2926
3012
 
2927
3013
  if @data['포스트설정']['좌측정렬'].checked?
2928
3014
  content = content.split("\n").map {|row| '<p style="text-align: left;">'+row+'</p>'}.join("\n")
3015
+ option['좌측정렬'] = 'true'
3016
+ else
3017
+ option['좌측정렬'] = 'false'
2929
3018
  end
2930
3019
 
2931
3020
  @data['table'][index][-1] = 90
2932
3021
  @data['table'] << []
2933
3022
  @data['table'].pop
2934
3023
 
2935
- dd_time = @data['table'][index][9].to_s.force_encoding('utf-8').to_i
3024
+ dd_time = @data['table'][index][10].to_s.force_encoding('utf-8').to_i
3025
+ template_no = @data['table'][index][7].to_s.force_encoding('utf-8').to_i
2936
3026
  naver.update(title,content,option,soosick_1,soosick_2, dd_time)
2937
3027
 
2938
3028
 
@@ -2951,11 +3041,11 @@ class Wordpress
2951
3041
  # @data2['content'] = content+'</div>'
2952
3042
 
2953
3043
  #완료했으니 수량 카운터
2954
- @data['table'][index][10] = @data['table'][index][10].to_i + 1
3044
+ @data['table'][index][11] = @data['table'][index][11].to_i + 1
2955
3045
  @data['table'][index][-1] = 100
2956
3046
  @data['table'] << []
2957
3047
  @data['table'].pop
2958
- sleep(@data['table'][index][8].to_i)
3048
+ sleep(@data['table'][index][9].to_i)
2959
3049
  end
2960
3050
  # rescue => exception
2961
3051
  # puts exception
@@ -3229,8 +3319,8 @@ class Wordpress
3229
3319
  end
3230
3320
 
3231
3321
  if i.class == Array
3232
- i[7] = i[7].to_i
3233
3322
  i[8] = i[8].to_i
3323
+ i[9] = i[9].to_i
3234
3324
  @data[key] << i
3235
3325
  @data[key] << i
3236
3326
  @data[key].pop
@@ -3300,11 +3390,14 @@ class Wordpress
3300
3390
  @data['bun'] = entry{
3301
3391
  text '예약 발행 분 단위 ex)00'
3302
3392
  }
3393
+ @data['template'] = entry{
3394
+ text '템플릿 사용시 번호 ex)1'
3395
+ }
3303
3396
 
3304
3397
  button('등록'){
3305
3398
  on_clicked {
3306
- @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]
3307
- @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]
3399
+ @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]
3400
+ @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]
3308
3401
  @data['table'].pop
3309
3402
  }
3310
3403
  }
@@ -3316,8 +3409,8 @@ class Wordpress
3316
3409
  file_data.split("\n").each do |i|
3317
3410
  i3 = i.to_s.force_encoding('utf-8').to_s
3318
3411
  i2 = i3.split(',')
3319
- @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]
3320
- @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]
3412
+ @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]
3413
+ @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]
3321
3414
  @data['table'].pop
3322
3415
  end
3323
3416
  end
@@ -3352,6 +3445,9 @@ class Wordpress
3352
3445
  text_column('예약 분'){
3353
3446
  editable true
3354
3447
  }
3448
+ text_column('템플릿 넘버'){
3449
+ editable true
3450
+ }
3355
3451
 
3356
3452
 
3357
3453
  text_column('수량'){
@@ -3418,7 +3514,11 @@ class Wordpress
3418
3514
 
3419
3515
  grid{
3420
3516
  stretchy false
3421
-
3517
+ @data['table_template_input'] = entry{
3518
+ top 1
3519
+ left 3
3520
+ text '템플릿 넘버 ex) 3'
3521
+ }
3422
3522
  @data['table_counter_input'] = entry{
3423
3523
  top 1
3424
3524
  left 4
@@ -3432,7 +3532,7 @@ class Wordpress
3432
3532
  @data['table_delay_input2'] = entry{
3433
3533
  top 1
3434
3534
  left 6
3435
- text '등록전딜레이'
3535
+ text '등록 전 딜레이'
3436
3536
  }
3437
3537
 
3438
3538
  button('전체설정'){
@@ -3440,9 +3540,10 @@ class Wordpress
3440
3540
  left 7
3441
3541
  on_clicked{
3442
3542
  for n in 0..@data['table'].length-1
3443
- @data['table'][n][7] = @data['table_counter_input'].text.to_i
3444
- @data['table'][n][8] = @data['table_delay_input'].text.to_s
3445
- @data['table'][n][9] = @data['table_delay_input2'].text.to_s
3543
+ @data['table'][n][7] = @data['table_template_input'].text.to_i
3544
+ @data['table'][n][8] = @data['table_counter_input'].text.to_i
3545
+ @data['table'][n][9] = @data['table_delay_input'].text.to_s
3546
+ @data['table'][n][10] = @data['table_delay_input2'].text.to_s
3446
3547
  @data['table'] << []
3447
3548
  @data['table'].pop
3448
3549
  end
@@ -3836,20 +3937,35 @@ class Wordpress
3836
3937
  stretchy false
3837
3938
  text "내용폴더경로 ex)C:\\내용\\폴더1"
3838
3939
  }
3839
- button('폴더째로 불러오기'){
3840
-
3841
- on_clicked{
3842
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3843
- Dir.entries(@data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')).each do |file|
3844
- if file == '.' or file == '..'
3845
3940
 
3846
- else
3847
- file_data = File.open(path+'/'+file,'r', :encoding => 'utf-8').read()
3848
- @data['내용설정']['내용'] << [false, file, file_data]
3941
+ button('폴더째로 불러오기') {
3942
+ on_clicked {
3943
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
3944
+
3945
+ # 경로가 유효한지 확인
3946
+ if Dir.exist?(path)
3947
+ Dir.entries(path).each do |file|
3948
+ if file == '.' or file == '..'
3949
+ next
3950
+ else
3951
+ begin
3952
+ # 파일을 열고 내용을 읽어서 추가
3953
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
3954
+ @data['내용설정']['내용'] << [false, file, file_data]
3955
+ rescue => e
3956
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
3957
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
3958
+ end
3959
+ end
3849
3960
  end
3961
+
3962
+ # 내용 배열에서 마지막 빈 항목 제거
3963
+ @data['내용설정']['내용'] << []
3964
+ @data['내용설정']['내용'].pop
3965
+ else
3966
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
3967
+ puts "경로가 존재하지 않습니다: #{path}"
3850
3968
  end
3851
- @data['내용설정']['내용'] << []
3852
- @data['내용설정']['내용'].pop
3853
3969
  }
3854
3970
  }
3855
3971
  }
@@ -3948,25 +4064,35 @@ class Wordpress
3948
4064
  horizontal_box{
3949
4065
  stretchy false
3950
4066
  @data['이미지설정']['폴더경로'] = entry{
3951
- stretchy false
3952
- text "사진폴더경로 ex)C:\\사진\\폴더2"
3953
- }
3954
- button('폴더째로 불러오기'){
3955
-
3956
- on_clicked{
3957
- path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
3958
- Dir.entries(@data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')).each do |file|
3959
- if file == '.' or file == '..'
4067
+ stretchy false
4068
+ text "사진폴더경로 ex)C:\\사진\\폴더2"
4069
+ }
4070
+
4071
+ button('폴더째로 불러오기') {
4072
+ on_clicked {
4073
+ path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')
3960
4074
 
4075
+ # 경로가 유효한지 확인
4076
+ if Dir.exist?(path)
4077
+ Dir.entries(path).each do |file|
4078
+ if file == '.' or file == '..'
4079
+ next
3961
4080
  else
3962
- @data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
4081
+ # 폴더 내의 파일을 이미지 리스트에 추가
4082
+ @data['이미지설정']['이미지'] << [false, file, path + "\\" + file.force_encoding('utf-8')]
3963
4083
  end
3964
4084
  end
4085
+
4086
+ # 마지막 빈 항목 추가 후 제거 (원래 로직에 맞춰)
3965
4087
  @data['이미지설정']['이미지'] << []
3966
4088
  @data['이미지설정']['이미지'].pop
3967
- }
4089
+ else
4090
+ # 경로가 존재하지 않으면 경고 메시지 출력
4091
+ puts "경로가 존재하지 않습니다: #{path}"
4092
+ end
3968
4093
  }
3969
4094
  }
4095
+ }
3970
4096
 
3971
4097
  }
3972
4098
  vertical_separator{
@@ -4161,6 +4287,80 @@ class Wordpress
4161
4287
  }
4162
4288
  }
4163
4289
  }
4290
+
4291
+ horizontal_box{
4292
+ stretchy false
4293
+ label('※이미지 리스트와 위 세팅을 하였다면 포스트설정1 탭에서 어떤위치(방식)으로 삽입시킬지 세팅이 필요합니다.'){
4294
+ }
4295
+ }
4296
+ horizontal_box{
4297
+ stretchy false
4298
+ label('※이미지를 아래 특정단어 슬라이드 변경 기능만 사용한다면 포스트설정1 탭에서 설정을 할 필요는 없습니다.'){
4299
+ }
4300
+ }
4301
+ vertical_separator{
4302
+ stretchy false
4303
+ }
4304
+ horizontal_box{
4305
+ stretchy false
4306
+ @data['포스트설정']['라이브러리사용안함'] = checkbox('사진 라이브러리에서 제외시키기 적용'){
4307
+
4308
+ }
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
+ }
4164
4364
  }
4165
4365
  }
4166
4366
  }
@@ -4182,26 +4382,7 @@ class Wordpress
4182
4382
  text '특정단어'
4183
4383
  }
4184
4384
 
4185
- # @data['포스트설정']['제목단어변경'] = checkbox('제목에 특정 단어를 변경'){
4186
- # top 1
4187
- # left 0
4188
- # }
4189
- # @data['포스트설정']['제목단어변경파일불러오기'] = button('설정 파일 불러오기'){
4190
- # top 1
4191
- # left 1
4192
- # on_clicked{
4193
- # file = open_file
4194
- # if file != nil
4195
- # file_data = File.open(file, 'r', :encoding => 'utf-8').read()
4196
- # file_data.split("\n").each do |i|
4197
- # i2 = i.split('>')
4198
- # text_key = i2[0].to_s
4199
- # text_val = i2[1].to_s.split(',')
4200
- # @data['포스트설정']['제목특정단어변경데이터'][text_key] = text_val
4201
- # end
4202
- # end
4203
- # }
4204
- # }
4385
+
4205
4386
  @data['포스트설정']['제목에키워드삽입'] = checkbox('제목에 키워드 삽입'){
4206
4387
  top 2
4207
4388
  left 0
@@ -4505,7 +4686,7 @@ class Wordpress
4505
4686
  text 'URL'
4506
4687
  }
4507
4688
 
4508
- @data['포스트설정']['단어사진으로변경'] = checkbox('내용 특정단어를 사진으로 변경'){
4689
+ @data['포스트설정']['단어사진으로변경'] = checkbox('특정단어를 사진으로 변경'){
4509
4690
  top 4
4510
4691
  left 0
4511
4692
  }
@@ -4525,7 +4706,8 @@ class Wordpress
4525
4706
  text 'URL'
4526
4707
  }
4527
4708
 
4528
- @data['포스트설정']['스티커로변경'] = checkbox('내용 특정단어를 스티커로 변경'){
4709
+
4710
+ @data['포스트설정']['스티커로변경'] = checkbox('특정단어를 스티커로 변경'){
4529
4711
  top 6
4530
4712
  left 0
4531
4713
  }
@@ -4534,7 +4716,7 @@ class Wordpress
4534
4716
  left 1
4535
4717
  text '특정단어'
4536
4718
  }
4537
- @data['포스트설정']['영상으로변경'] = checkbox('내용 특정단어를 영상으로 변경'){
4719
+ @data['포스트설정']['영상으로변경'] = checkbox('특정단어를 영상으로 변경'){
4538
4720
  top 7
4539
4721
  left 0
4540
4722
  }
@@ -4552,7 +4734,7 @@ class Wordpress
4552
4734
  left 1
4553
4735
  text "영상폴더위치 ex) C:\\영상\\폴더3"
4554
4736
  }
4555
- @data['포스트설정']['지도로변경'] = checkbox('내용 특정단어를 지도로 변경'){
4737
+ @data['포스트설정']['지도로변경'] = checkbox('특정단어를 지도로 변경'){
4556
4738
  top 9
4557
4739
  left 0
4558
4740
  }
@@ -4570,7 +4752,7 @@ class Wordpress
4570
4752
  left 1
4571
4753
  text 'ex) OO시 OO구 OO동 270-68'
4572
4754
  }
4573
- @data['포스트설정']['인용구변경'] = checkbox('내용 특정단어를 인용구로 적용'){
4755
+ @data['포스트설정']['인용구변경'] = checkbox('특정단어를 인용구로 적용'){
4574
4756
  top 11
4575
4757
  left 0
4576
4758
  }
@@ -4594,15 +4776,8 @@ class Wordpress
4594
4776
  end
4595
4777
  }
4596
4778
  }
4597
- @data['포스트설정']['내템플릿사용하기'] = checkbox('내 템플릿 사용하기'){
4598
- top 13
4599
- left 0
4600
- }
4601
- @data['포스트설정']['내템플릿변경단어'] = entry{
4602
- top 13
4603
- left 1
4604
- text '탬플릿으로 전활시킬 특정단어'
4605
- }
4779
+
4780
+
4606
4781
  }
4607
4782
  }
4608
4783
  }