Module: WpWrapper::Modules::Setup
- Included in:
- Client
- Defined in:
- lib/wp_wrapper/modules/setup.rb
Instance Method Summary collapse
- #set_permalinks_options(options = {}) ⇒ Object
- #set_setup_form_options(setup_page, title: nil, email: nil) ⇒ Object
- #setup(title: nil, email: nil) ⇒ Object
Instance Method Details
#set_permalinks_options(options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/wp_wrapper/modules/setup.rb', line 48 def ( = {}) permalink_structure = .fetch(:permalink_structure, '/%postname%/') category_base = .fetch(:category_base, 'kategori') tag_base = .fetch(:tag_base, 'etikett') opts = { :custom_selection => {:identifier => :id, :checked => true, :type => :radiobutton}, :permalink_structure => {:value => permalink_structure, :type => :input}, :category_base => {:value => category_base, :type => :input}, :tag_base => {:value => tag_base, :type => :input}, } return ("options-permalink.php", {:action => 'options-permalink.php'}, opts, :first, {:should_reset_radio_buttons => true}) end |
#set_setup_form_options(setup_page, title: nil, email: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/wp_wrapper/modules/setup.rb', line 23 def (setup_page, title: nil, email: nil) success = false setup_form = setup_page.form_with(action: 'install.php?step=2') if (setup_form && title.present? && self.username.present? && self.password.present? && email.present?) puts "#{Time.now}: Url: #{self.url}. Setting up site..." setup_form.field_with(name: 'weblog_title').value = title setup_form.field_with(name: 'user_name').value = self.username setup_form.field_with(name: 'admin_password').value = self.password setup_form.field_with(name: 'admin_password2').value = self.password setup_form.field_with(name: 'admin_email').value = email confirmation_page = setup_form.submit puts "[WpWrapper::Modules::Setup] - #{Time.now}: Url: #{self.url}. The WordPress-blog has now been installed!" success = true else puts "[WpWrapper::Modules::Setup] - #{Time.now}: Url: #{self.url}. The blog has already been setup or the registration form couldn't be found or some data is missing." puts "[WpWrapper::Modules::Setup] - #{Time.now}: Url: #{self.url}. Information supplied:\nTitle: #{title}.\nUsername: #{self.username}.\nPassword: #{self.password}.\nEmail: #{email}." end return success end |
#setup(title: nil, email: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wp_wrapper/modules/setup.rb', line 5 def setup(title: nil, email: nil) success = false step_1_page = self.mechanize_client.open_url(get_url(:home)) if step_1_page step_1_form = step_1_page.form_with(action: '?step=1') if step_1_form step_2_page = step_1_form.submit success = (step_2_page, title: title, email: email) else success = (step_1_page, title: title, email: email) end end return success end |