marv 0.3.1 → 0.3.2
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.
- data/CHANGELOG.md +58 -52
- data/Gemfile +2 -1
- data/Gemfile.lock +7 -7
- data/VERSION +1 -1
- data/layouts/config/router.php.erb +25 -0
- data/layouts/plugin/functions/plugin.php.erb +94 -0
- data/layouts/{default → plugin}/images/screenshot.png +0 -0
- data/layouts/{bramble → plugin}/javascripts/admin.coffee +0 -0
- data/layouts/{bramble → plugin}/javascripts/admin.js +0 -0
- data/layouts/{bramble/javascripts/theme.coffee → plugin/javascripts/plugin.coffee} +0 -0
- data/layouts/{bramble/javascripts/theme.js → plugin/javascripts/plugin.js} +0 -0
- data/layouts/plugin/stylesheets/plugin.scss +1 -0
- data/layouts/{default → theme}/functions/functions.php.erb +0 -0
- data/layouts/theme/images/screenshot.png +0 -0
- data/layouts/{default → theme}/includes/filters-admin.php.erb +0 -0
- data/layouts/{default → theme}/includes/filters.php.erb +0 -0
- data/layouts/{default → theme}/includes/helpers.php.erb +0 -0
- data/layouts/{default → theme}/javascripts/admin.coffee +0 -0
- data/layouts/{default → theme}/javascripts/admin.js +0 -0
- data/layouts/{default → theme}/javascripts/theme.coffee +0 -0
- data/layouts/{default → theme}/javascripts/theme.js +0 -0
- data/layouts/{default → theme}/stylesheets/_header.scss.erb +0 -0
- data/layouts/{bramble → theme}/stylesheets/style.scss.erb +0 -0
- data/layouts/{default → theme}/templates/404.php.erb +0 -0
- data/layouts/{default → theme}/templates/archive.php.erb +0 -0
- data/layouts/{default → theme}/templates/author.php.erb +0 -0
- data/layouts/{default → theme}/templates/footer.php +0 -0
- data/layouts/{default → theme}/templates/header.php +0 -0
- data/layouts/{default → theme}/templates/index.php +0 -0
- data/layouts/{default → theme}/templates/page.php +0 -0
- data/layouts/{default → theme}/templates/partials/comments.php.erb +0 -0
- data/layouts/{default → theme}/templates/partials/content-none.php.erb +0 -0
- data/layouts/{default → theme}/templates/partials/content-page.php +0 -0
- data/layouts/{default → theme}/templates/partials/content-single.php +0 -0
- data/layouts/{default → theme}/templates/partials/content.php.erb +0 -0
- data/layouts/{default → theme}/templates/partials/searchform.php.erb +0 -0
- data/layouts/{default → theme}/templates/partials/sidebar.php +0 -0
- data/layouts/{default → theme}/templates/search.php.erb +0 -0
- data/layouts/{default → theme}/templates/single.php +0 -0
- data/lib/marv/builder.rb +1 -1
- data/lib/marv/cli.rb +5 -5
- data/lib/marv/server.rb +65 -79
- data/marv.gemspec +44 -45
- metadata +57 -45
- data/layouts/bramble/functions/functions.php.erb +0 -112
- data/layouts/bramble/images/screenshot.png +0 -0
- data/layouts/bramble/includes/options.php.erb +0 -1339
- data/layouts/bramble/stylesheets/_header.scss.erb +0 -16
- data/layouts/bramble/templates/sample-template.php +0 -25
- data/layouts/config/rack-config.ru +0 -38
- data/layouts/default/stylesheets/style.scss.erb +0 -4
- data/lib/marv/version.rb +0 -3
data/CHANGELOG.md
CHANGED
|
@@ -1,52 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
## v0.3.2
|
|
2
|
+
* Fix bug when creating server
|
|
3
|
+
* Use Thor to download wordpress
|
|
4
|
+
* Fix marv watch not compiling assets
|
|
5
|
+
* Fix error when compression enabled
|
|
6
|
+
|
|
7
|
+
## v0.3.1
|
|
8
|
+
* Remove command servers
|
|
9
|
+
* Add option --list to server command
|
|
10
|
+
* Remove option --create from server command
|
|
11
|
+
* Add option --start to server command
|
|
12
|
+
* Remove marv link options except --folder
|
|
13
|
+
* Link projects by default to global folders
|
|
14
|
+
|
|
15
|
+
## v0.3.0
|
|
16
|
+
* Marv server (Wordpress local install)
|
|
17
|
+
* Global plugins & themes for Marv servers
|
|
18
|
+
* Config.rb option for additional assets
|
|
19
|
+
* Use local layouts on project on create
|
|
20
|
+
* Copy user folders in project root
|
|
21
|
+
* Copy file with project name from functions folder
|
|
22
|
+
* Informative error messages
|
|
23
|
+
* Remove extras folder
|
|
24
|
+
* Update dependencies
|
|
25
|
+
* Update config templates
|
|
26
|
+
* Many new functions & function updates
|
|
27
|
+
|
|
28
|
+
## v0.2.5
|
|
29
|
+
* Remove compass, sprockets-sass and yui-compressor
|
|
30
|
+
* Better error reporting in pry
|
|
31
|
+
* Add uglifier
|
|
32
|
+
* Remove unused functions
|
|
33
|
+
|
|
34
|
+
## v0.2.4
|
|
35
|
+
* Update compass version
|
|
36
|
+
|
|
37
|
+
## v0.2.3
|
|
38
|
+
* Fix marv global settings folder name
|
|
39
|
+
* Remove ie.css
|
|
40
|
+
* Add admin.css
|
|
41
|
+
* Fix errors on build
|
|
42
|
+
|
|
43
|
+
## v0.2.2
|
|
44
|
+
* Add support for layouts on marv create
|
|
45
|
+
* Bramble Framework child theme project layout
|
|
46
|
+
* Optimize images
|
|
47
|
+
|
|
48
|
+
## v0.2.1
|
|
49
|
+
* New default project layout
|
|
50
|
+
|
|
51
|
+
## v0.2.0
|
|
52
|
+
* Fix errors
|
|
53
|
+
|
|
54
|
+
## v0.1.0
|
|
55
|
+
* Fork from Forge (https://github.com/thethemefoundry/forge)
|
|
56
|
+
* Update dependencies
|
|
57
|
+
* Fix errors from old dependencies
|
|
58
|
+
* Add extras folder
|
data/Gemfile
CHANGED
|
@@ -5,7 +5,7 @@ gem 'thor', '>= 0.19.1'
|
|
|
5
5
|
gem 'guard-livereload', '>= 2.3.0'
|
|
6
6
|
gem 'sprockets', '>= 2.12.0'
|
|
7
7
|
gem 'rubyzip', '>= 1.1.6'
|
|
8
|
-
gem '
|
|
8
|
+
gem 'childprocess', '>= 0.3.5'
|
|
9
9
|
gem 'mysql2', '>= 0.3.15'
|
|
10
10
|
gem 'sass', '>= 3.3.0'
|
|
11
11
|
gem 'less', '>= 2.6.0'
|
|
@@ -19,6 +19,7 @@ gem 'uglifier', '>= 2.5.0'
|
|
|
19
19
|
group :development do
|
|
20
20
|
gem 'rake'
|
|
21
21
|
gem 'rspec'
|
|
22
|
+
gem 'aruba'
|
|
22
23
|
gem 'cucumber'
|
|
23
24
|
gem 'jeweler'
|
|
24
25
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -2,6 +2,11 @@ GEM
|
|
|
2
2
|
remote: http://rubygems.org/
|
|
3
3
|
specs:
|
|
4
4
|
addressable (2.3.6)
|
|
5
|
+
aruba (0.4.11)
|
|
6
|
+
childprocess (>= 0.2.3)
|
|
7
|
+
cucumber (>= 1.1.1)
|
|
8
|
+
ffi (>= 1.0.11)
|
|
9
|
+
rspec (>= 2.7.0)
|
|
5
10
|
builder (3.2.2)
|
|
6
11
|
celluloid (0.15.2)
|
|
7
12
|
timers (~> 1.1.0)
|
|
@@ -95,12 +100,6 @@ GEM
|
|
|
95
100
|
method_source (~> 0.8.1)
|
|
96
101
|
slop (~> 3.4)
|
|
97
102
|
rack (1.5.2)
|
|
98
|
-
rack-legacy (1.0.0)
|
|
99
|
-
childprocess
|
|
100
|
-
rack
|
|
101
|
-
rack-reverse-proxy
|
|
102
|
-
rack-reverse-proxy (0.4.4)
|
|
103
|
-
rack (>= 1.0.0)
|
|
104
103
|
rake (10.3.2)
|
|
105
104
|
rb-fsevent (0.9.4)
|
|
106
105
|
rb-inotify (0.9.5)
|
|
@@ -143,13 +142,14 @@ PLATFORMS
|
|
|
143
142
|
ruby
|
|
144
143
|
|
|
145
144
|
DEPENDENCIES
|
|
145
|
+
aruba
|
|
146
|
+
childprocess (>= 0.3.5)
|
|
146
147
|
coffee-script (>= 2.3.0)
|
|
147
148
|
cucumber
|
|
148
149
|
guard-livereload (>= 2.3.0)
|
|
149
150
|
jeweler
|
|
150
151
|
less (>= 2.6.0)
|
|
151
152
|
mysql2 (>= 0.3.15)
|
|
152
|
-
rack-legacy (>= 1.0.0)
|
|
153
153
|
rake
|
|
154
154
|
rspec
|
|
155
155
|
rubyzip (>= 1.1.6)
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.2
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
$root = $_SERVER['DOCUMENT_ROOT'];
|
|
4
|
+
chdir( $root );
|
|
5
|
+
|
|
6
|
+
$path = '/'. ltrim( parse_url( $_SERVER['REQUEST_URI'] )['path'], '/' );
|
|
7
|
+
set_include_path( get_include_path() .':'. __DIR__ );
|
|
8
|
+
|
|
9
|
+
if( file_exists( $root.$path ) ) {
|
|
10
|
+
|
|
11
|
+
if( is_dir( $root.$path ) && substr( $path, strlen( $path ) - 1, 1 ) !== '/' ) {
|
|
12
|
+
$path = rtrim( $path, '/' ) .'/index.php';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if( strpos( $path, '.php' ) === false ) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
chdir( dirname( $root.$path ) );
|
|
20
|
+
require_once $root.$path;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
include_once 'index.php';
|
|
25
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: <%= config[:name].capitalize %>
|
|
4
|
+
* Plugin URI: <%= config[:uri] %>
|
|
5
|
+
* Description: <%= config[:name].capitalize %> plugin created with Marv.
|
|
6
|
+
* Version: 0.1
|
|
7
|
+
* Author: <%= config[:author] %>
|
|
8
|
+
* Author URI: <%= config[:author_uri] %>
|
|
9
|
+
* License: GPL2
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Block direct access
|
|
13
|
+
if( ! defined( 'ABSPATH' ) ) exit;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Enqueue scripts and styles.
|
|
18
|
+
*/
|
|
19
|
+
function <%= project_id %>_styles_scripts()
|
|
20
|
+
{
|
|
21
|
+
// Styles
|
|
22
|
+
add_action( 'wp_enqueue_scripts', '<%= project_id %>_register_styles' );
|
|
23
|
+
add_action( 'wp_enqueue_scripts', '<%= project_id %>_enqueue_styles' );
|
|
24
|
+
|
|
25
|
+
// Scripts
|
|
26
|
+
add_action( 'wp_enqueue_scripts', '<%= project_id %>_register_scripts' );
|
|
27
|
+
add_action( 'wp_enqueue_scripts', '<%= project_id %>_enqueue_scripts' );
|
|
28
|
+
|
|
29
|
+
// Admin scripts
|
|
30
|
+
add_action( 'admin_enqueue_scripts', '<%= project_id %>_register_admin_scripts' );
|
|
31
|
+
add_action( 'admin_enqueue_scripts', '<%= project_id %>_enqueue_admin_scripts' );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
add_action( 'init', '<%= project_id %>_styles_scripts' );
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Register styles.
|
|
38
|
+
*/
|
|
39
|
+
function <%= project_id %>_register_styles()
|
|
40
|
+
{
|
|
41
|
+
// Theme
|
|
42
|
+
wp_register_style( 'plugin', get_stylesheet_directory_uri() . '/plugin.css', '', '', 'screen' );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Enqueue styles.
|
|
47
|
+
*/
|
|
48
|
+
function <%= project_id %>_enqueue_styles()
|
|
49
|
+
{
|
|
50
|
+
wp_enqueue_style( 'plugin' );
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Register scripts
|
|
55
|
+
*/
|
|
56
|
+
function <%= project_id %>_register_scripts()
|
|
57
|
+
{
|
|
58
|
+
// Theme
|
|
59
|
+
wp_register_script( 'plugin', get_stylesheet_directory_uri() . '/javascripts/plugin.js', array( 'jquery' ), '', true );
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Enqueue scripts
|
|
64
|
+
*/
|
|
65
|
+
function <%= project_id %>_enqueue_scripts()
|
|
66
|
+
{
|
|
67
|
+
wp_enqueue_script( 'plugin' );
|
|
68
|
+
|
|
69
|
+
if ( is_singular() && get_option( 'thread_comments' ) ) {
|
|
70
|
+
wp_enqueue_script( 'comment-reply' );
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Register admin scripts
|
|
76
|
+
*/
|
|
77
|
+
function <%= project_id %>_register_admin_scripts()
|
|
78
|
+
{
|
|
79
|
+
// Admin
|
|
80
|
+
wp_register_script( 'admin', get_stylesheet_directory_uri() . '/javascripts/admin.js', array( 'jquery' ), '', true );
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Enqueue admin scripts
|
|
85
|
+
*/
|
|
86
|
+
function <%= project_id %>_enqueue_admin_scripts()
|
|
87
|
+
{
|
|
88
|
+
wp_enqueue_script( 'admin' );
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Allow automatic updates
|
|
93
|
+
*/
|
|
94
|
+
add_filter( 'automatic_updates_is_vcs_checkout', '__return_false' );
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// This is your master stylesheet
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/marv/builder.rb
CHANGED
data/lib/marv/cli.rb
CHANGED
|
@@ -16,8 +16,8 @@ module Marv
|
|
|
16
16
|
|
|
17
17
|
desc "create DIRECTORY", "Creates a Marv project into specified directory"
|
|
18
18
|
long_desc "Creates a new project. Use the layout option to choose a scaffold"
|
|
19
|
-
method_option :layout, :type => :string, :default => '
|
|
20
|
-
method_option :local, :type => :boolean, :force => false, :desc => "Use
|
|
19
|
+
method_option :layout, :type => :string, :default => 'theme', :enum => %w{theme plugin}, :desc => "Scaffold layout for theme or plugin"
|
|
20
|
+
method_option :local, :type => :boolean, :force => false, :desc => "Use custom layout from ~/.marv/layouts folder"
|
|
21
21
|
def create(dir)
|
|
22
22
|
theme = {}
|
|
23
23
|
theme[:name] = dir
|
|
@@ -29,14 +29,14 @@ module Marv
|
|
|
29
29
|
long_desc "This command will symlink the compiled version of the project to the specified server or WordPress install path."+
|
|
30
30
|
"If you don't provide a directory or a server name, the symlink will be created in Marv global themes or plugins folder."
|
|
31
31
|
method_option :folder, :type => :string, :enum => %w{themes plugins}, :required => true, :desc => "Link Marv project in themes or plugins folfer"
|
|
32
|
-
def link(dir=
|
|
32
|
+
def link(dir=nil)
|
|
33
33
|
project = Marv::Project.new('.', self)
|
|
34
34
|
|
|
35
35
|
unless File.directory?(project.build_path)
|
|
36
36
|
FileUtils.mkdir_p project.build_path
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
if dir
|
|
39
|
+
if dir.nil?
|
|
40
40
|
link_project_globaly(options, project)
|
|
41
41
|
else
|
|
42
42
|
wp_path = File.join(dir, 'wp-content', options[:folder])
|
|
@@ -83,7 +83,7 @@ module Marv
|
|
|
83
83
|
builder.zip(filename)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
desc "server SERVER", "
|
|
86
|
+
desc "server SERVER", "Create a Marv server with the specified name"
|
|
87
87
|
method_option :list, :type => :boolean, :force => false, :desc => "List all available Marv servers"
|
|
88
88
|
method_option :start, :type => :boolean, :force => false, :desc => "Create a new Marv server"
|
|
89
89
|
method_option :stop, :type => :boolean, :force => false, :desc => "Stop a running Marv server"
|
data/lib/marv/server.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
2
|
require 'mysql2'
|
|
3
|
+
require 'childprocess'
|
|
3
4
|
|
|
4
5
|
module Marv
|
|
5
6
|
class Server
|
|
@@ -10,10 +11,6 @@ module Marv
|
|
|
10
11
|
# Deploy variables
|
|
11
12
|
@server_name = name
|
|
12
13
|
@server_path = server_path
|
|
13
|
-
|
|
14
|
-
@rack_config = rack_config
|
|
15
|
-
@wp_config = wp_config
|
|
16
|
-
|
|
17
14
|
@db_name = 'marv_'+name.gsub(/\W/, '_').downcase
|
|
18
15
|
|
|
19
16
|
# CLI Options
|
|
@@ -39,14 +36,6 @@ module Marv
|
|
|
39
36
|
File.join(ENV['HOME'], '.marv', 'servers', @server_name)
|
|
40
37
|
end
|
|
41
38
|
|
|
42
|
-
def rack_config
|
|
43
|
-
File.join(ENV['HOME'], '.marv', @server_path, 'config.ru')
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def wp_config
|
|
47
|
-
File.join(ENV['HOME'], '.marv', @server_path, 'wp-config.php')
|
|
48
|
-
end
|
|
49
|
-
|
|
50
39
|
def db_name
|
|
51
40
|
@db_name
|
|
52
41
|
end
|
|
@@ -59,15 +48,33 @@ module Marv
|
|
|
59
48
|
@db_host
|
|
60
49
|
end
|
|
61
50
|
|
|
51
|
+
def run_php_server
|
|
52
|
+
# Setup server
|
|
53
|
+
server = TCPServer.new('127.0.0.1', 0)
|
|
54
|
+
port = server.addr[1]
|
|
55
|
+
server.close()
|
|
56
|
+
|
|
57
|
+
# Run PHP server
|
|
58
|
+
::Dir.chdir @server_path
|
|
59
|
+
@php = ChildProcess.build 'php', '-S', "localhost:#{port}", 'router.php'
|
|
60
|
+
@php.start
|
|
61
|
+
|
|
62
|
+
# Write PHP proccess id to file
|
|
63
|
+
File.open(File.join(@server_path, 'php.pid'), 'w') do |file|
|
|
64
|
+
file.write(@php.pid)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
@task.say "Visit http://localhost:#{port}"
|
|
68
|
+
end
|
|
69
|
+
|
|
62
70
|
def create_server
|
|
63
71
|
create_server_directory
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
add_rack_config
|
|
73
|
+
copy_wordpress_files
|
|
74
|
+
add_config_file('router.php.erb', 'router.php')
|
|
68
75
|
|
|
69
76
|
create_server_database
|
|
70
|
-
|
|
77
|
+
add_config_file('wp-config.php.erb', 'wp-config.php')
|
|
71
78
|
|
|
72
79
|
add_global_content
|
|
73
80
|
|
|
@@ -77,12 +84,9 @@ module Marv
|
|
|
77
84
|
end
|
|
78
85
|
|
|
79
86
|
def start_server
|
|
80
|
-
update_global_projects
|
|
81
|
-
|
|
82
87
|
begin
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
end
|
|
88
|
+
update_global_projects
|
|
89
|
+
run_php_server
|
|
86
90
|
rescue Exception => e
|
|
87
91
|
@task.say "Error while starting server:"
|
|
88
92
|
@task.say e.message + "\n", :red
|
|
@@ -93,14 +97,12 @@ module Marv
|
|
|
93
97
|
def stop_server
|
|
94
98
|
begin
|
|
95
99
|
@task.shell.mute do
|
|
96
|
-
ruby_pid_file = File.join(@server_path, 'ruby.pid')
|
|
97
100
|
php_pid_file = File.join(@server_path, 'php.pid')
|
|
98
101
|
|
|
99
|
-
if File.
|
|
100
|
-
ruby_pid = File.read(ruby_pid_file).to_i
|
|
102
|
+
if File.exists?(php_pid_file)
|
|
101
103
|
php_pid = File.read(php_pid_file).to_i
|
|
102
104
|
|
|
103
|
-
Process.kill(
|
|
105
|
+
Process.kill('KILL', php_pid)
|
|
104
106
|
@task.say "Server #{@server_name} stopped", :yellow
|
|
105
107
|
else
|
|
106
108
|
@task.say "Server #{@server_name} is not running", :red
|
|
@@ -142,79 +144,66 @@ module Marv
|
|
|
142
144
|
|
|
143
145
|
private
|
|
144
146
|
|
|
147
|
+
# Creates a directory for a new server
|
|
145
148
|
def create_server_directory
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
# Create dir
|
|
150
|
+
unless ::File.exist?(self.servers_root)
|
|
151
|
+
::Dir.mkdir(servers_root)
|
|
148
152
|
end
|
|
149
|
-
|
|
150
|
-
if File.exist?(@server_path)
|
|
153
|
+
# Exit if dir exists
|
|
154
|
+
if ::File.exist?(@server_path)
|
|
151
155
|
@task.say "A server with name #{@server_name} already exists", :red
|
|
152
156
|
exit
|
|
153
157
|
end
|
|
154
158
|
end
|
|
155
159
|
|
|
160
|
+
# Downloads WordPress from wordpress.org
|
|
156
161
|
def download_wordpress
|
|
157
|
-
@
|
|
162
|
+
package = "/tmp/wordpress-#{@wp_version}.tar.gz"
|
|
158
163
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
Net::HTTP.start('wordpress.org') do |http|
|
|
165
|
-
resp = http.get("/wordpress-#{@wp_version}.tar.gz")
|
|
166
|
-
open("/tmp/wordpress-#{@wp_version}.tar.gz", 'w') do |file|
|
|
167
|
-
file.write(resp.body)
|
|
168
|
-
end
|
|
169
|
-
end
|
|
164
|
+
# Download package file
|
|
165
|
+
@task.shell.mute do
|
|
166
|
+
unless ::File.exists?(package)
|
|
167
|
+
@task.get "https://wordpress.org/wordpress-#{@wp_version}.tar.gz" do |content|
|
|
168
|
+
@task.create_file package, content
|
|
170
169
|
end
|
|
171
170
|
end
|
|
172
|
-
rescue Exception => e
|
|
173
|
-
@task.say "Error while downloading wordpress-#{@wp_version}.tar.gz:"
|
|
174
|
-
@task.say e.message + "\n", :red
|
|
175
|
-
exit
|
|
176
171
|
end
|
|
177
|
-
end
|
|
178
172
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
filestamp = Time.now.to_i
|
|
183
|
-
download_location = File.join('/tmp', "wordpress-#{@wp_version}.tar.gz")
|
|
184
|
-
tmp_dir = "/tmp/wordpress-latest-#{filestamp}"
|
|
173
|
+
# Return package file
|
|
174
|
+
package
|
|
175
|
+
end
|
|
185
176
|
|
|
186
|
-
|
|
187
|
-
|
|
177
|
+
# Copy WordPress files
|
|
178
|
+
def copy_wordpress_files
|
|
179
|
+
package = download_wordpress
|
|
188
180
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
@task.say e.message + "\n", :red
|
|
195
|
-
exit
|
|
181
|
+
# Get package content and extract to dir
|
|
182
|
+
tmp_dir = "/tmp/wordpress-latest-#{Time.now.to_i}"
|
|
183
|
+
# Create temporary dir
|
|
184
|
+
unless ::File.exists?(tmp_dir)
|
|
185
|
+
Dir.mkdir(tmp_dir)
|
|
196
186
|
end
|
|
197
|
-
@task.say "WordPress files created", :green
|
|
198
|
-
end
|
|
199
187
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
188
|
+
# Extract package to temporary dir
|
|
189
|
+
@task.shell.mute do
|
|
190
|
+
@task.run "cd #{tmp_dir};tar -xzf #{package}"
|
|
191
|
+
@task.directory "#{tmp_dir}/wordpress", @server_path
|
|
192
|
+
end
|
|
204
193
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
# Remove temporary dir
|
|
195
|
+
if ::File.exists?(tmp_dir)
|
|
196
|
+
FileUtils.rm_r(tmp_dir)
|
|
208
197
|
end
|
|
209
198
|
end
|
|
210
199
|
|
|
211
|
-
def
|
|
212
|
-
unless File.exists?(
|
|
213
|
-
|
|
214
|
-
|
|
200
|
+
def add_config_file(source, target)
|
|
201
|
+
unless File.exists?(target)
|
|
202
|
+
config = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'layouts', 'config', source))
|
|
203
|
+
config_template = ERB.new(::File.binread(config), nil, '-', '@output_buffer')
|
|
215
204
|
|
|
216
|
-
File.open(File.join(@server_path,
|
|
217
|
-
file.write(
|
|
205
|
+
File.open(File.join(@server_path, target), 'w') do |file|
|
|
206
|
+
file.write(config_template.result(binding))
|
|
218
207
|
end
|
|
219
208
|
end
|
|
220
209
|
end
|
|
@@ -233,12 +222,10 @@ module Marv
|
|
|
233
222
|
@task.say e.message + "\n", :red
|
|
234
223
|
exit
|
|
235
224
|
end
|
|
236
|
-
@task.say "Mysql database created", :green
|
|
237
225
|
end
|
|
238
226
|
|
|
239
227
|
def remove_server_database
|
|
240
228
|
begin
|
|
241
|
-
@task.say "Removing Mysql database..."
|
|
242
229
|
@task.shell.mute do
|
|
243
230
|
client = Mysql2::Client.new(:host => @db_host, :port => @db_port, :username => @db_user, :password => @db_password)
|
|
244
231
|
client.query("DROP DATABASE IF EXISTS #{@db_name}")
|
|
@@ -250,7 +237,6 @@ module Marv
|
|
|
250
237
|
@task.say "Error while removing Mysql database:"
|
|
251
238
|
@task.say e.message + "\n", :red
|
|
252
239
|
end
|
|
253
|
-
@task.say "Mysql database removed", :green
|
|
254
240
|
end
|
|
255
241
|
|
|
256
242
|
def add_global_content
|