Commit 5345e78fd9a169b57b9b60615f85fb7f822fec3c
Exists in
master
and in
1 other branch
Fix pensandoodireito/participacao-sitebase#342
Showing
9 changed files
with
81 additions
and
60 deletions
Show diff stats
Vagrantfile
... | ... | @@ -7,20 +7,20 @@ require 'ffi' |
7 | 7 | VAGRANTFILE_API_VERSION = "2" |
8 | 8 | |
9 | 9 | $firstTimeScript = <<SCRIPT |
10 | -cd /vagrant && composer update && rm -r /var/www/public && ln -s /vagrant/src /var/www/public | |
11 | - | |
12 | -cp /vagrant/config/wp-config-vagrant.php /vagrant/src/wp-config.php | |
13 | -cp /vagrant/config/htaccess-vagrant /vagrant/src/.htaccess | |
10 | +apt-get update | |
11 | +apt-get install -y subversion | |
12 | +composer self-update | |
14 | 13 | |
14 | +cd /vagrant | |
15 | +composer update | |
15 | 16 | npm install |
16 | 17 | ./node_modules/.bin/gulp |
17 | - | |
18 | 18 | service apache2 start |
19 | - | |
20 | 19 | service mysql start |
21 | 20 | |
22 | 21 | mysql --user=root --password=root -h 127.0.0.1 -e 'DROP DATABASE IF EXISTS participacao' |
23 | 22 | mysql --user=root --password=root -h 127.0.0.1 -e 'CREATE DATABASE participacao' |
23 | + | |
24 | 24 | cd /vagrant/db |
25 | 25 | bunzip2 db.sql.bz2 |
26 | 26 | mysql --user=root --password=root -h 127.0.0.1 participacao < /vagrant/db/db.sql |
... | ... | @@ -30,13 +30,13 @@ SCRIPT |
30 | 30 | |
31 | 31 | $updateServices = <<SCRIPT |
32 | 32 | |
33 | -service mysql start | |
33 | +service mysql restart | |
34 | 34 | |
35 | 35 | rm -r /var/www/public |
36 | 36 | ln -s /vagrant/src/ /var/www/public |
37 | 37 | chmod 777 /vagrant/src/wp-content/ |
38 | 38 | |
39 | -service apache2 start | |
39 | +service apache2 restart | |
40 | 40 | |
41 | 41 | SCRIPT |
42 | 42 | |
... | ... | @@ -46,6 +46,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
46 | 46 | config.vm.box = "scotch/box" |
47 | 47 | config.vm.network "forwarded_port", guest: 80, host: 80 |
48 | 48 | config.vm.network "forwarded_port", guest: 80, host: 8080 |
49 | + config.vm.network "forwarded_port", guest: 3306, host: 3306 | |
49 | 50 | # Port de debug do xdebug |
50 | 51 | config.vm.network "forwarded_port", guest: 9000, host: 9000 |
51 | 52 | config.vm.network "private_network", ip: "192.168.33.10" |
... | ... | @@ -61,6 +62,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
61 | 62 | system("sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080") |
62 | 63 | elsif FFI::Platform::IS_MAC |
63 | 64 | system('echo " |
65 | + rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 3306 -> 127.0.0.1 port 3306 | |
64 | 66 | rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080 |
65 | 67 | rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 -> 127.0.0.1 port 8443 |
66 | 68 | " | sudo pfctl -ef - > /dev/null 2>&1;') | ... | ... |
composer.json
... | ... | @@ -5,21 +5,6 @@ |
5 | 5 | "url": "http://wpackagist.org" |
6 | 6 | }, |
7 | 7 | { |
8 | - "type": "package", | |
9 | - "package": { | |
10 | - "name": "wordpress", | |
11 | - "type": "webroot", | |
12 | - "version": "4.1.1", | |
13 | - "dist": { | |
14 | - "type": "zip", | |
15 | - "url": "http://br.wordpress.org/wordpress-4.1.1-pt_BR.zip" | |
16 | - }, | |
17 | - "require" : { | |
18 | - "fancyguy/webroot-installer": "1.0.0" | |
19 | - } | |
20 | - } | |
21 | - }, | |
22 | - { | |
23 | 8 | "type": "git", |
24 | 9 | "url": "https://github.com/pensandoodireito/marcocivil-tema" |
25 | 10 | }, |
... | ... | @@ -58,7 +43,7 @@ |
58 | 43 | ], |
59 | 44 | "require": { |
60 | 45 | "php": ">=5.4.0", |
61 | - "wordpress": "4.1.1", | |
46 | + "johnpbloch/wordpress": "4.1", | |
62 | 47 | "pensandoodireito/marcocivil-tema" : "dev-master", |
63 | 48 | "pensandoodireito/dadospessoais-tema" : "dev-master", |
64 | 49 | "pensandoodireito/pensandoodireito-tema" : "dev-master", |
... | ... | @@ -67,10 +52,9 @@ |
67 | 52 | "pensandoodireito/pensandoodireito-network-functions" : "dev-master", |
68 | 53 | "pensandoodireito/blog-tema" : "dev-master", |
69 | 54 | "pensandoodireito/wp-side-comments" : "dev-master", |
70 | - "ethymos/delibera" : "dev-master", | |
55 | + "ethymos/delibera" : "dev-master", | |
71 | 56 | "wpackagist-plugin/rich-text-tags": "1.7.3", |
72 | 57 | "wpackagist-plugin/json-rest-api": "1.1.1", |
73 | - "wpackagist-plugin/contact-form-plugin": "3.89", | |
74 | 58 | "wpackagist-plugin/sendpress": ">=1.1.7.21", |
75 | 59 | "wpackagist-plugin/social-share-button": "2.1", |
76 | 60 | "wpackagist-plugin/events-manager": "5.5.7.1", |
... | ... | @@ -79,12 +63,17 @@ |
79 | 63 | "composer/installers": "~1.0" |
80 | 64 | }, |
81 | 65 | "extra": { |
82 | - "webroot-dir": "src", | |
83 | - "webroot-package": "wordpress", | |
66 | + "wordpress-install-dir": "src/wp", | |
84 | 67 | "installer-paths": { |
85 | 68 | "src/wp-content/plugins/{$name}/": ["type:wordpress-plugin"], |
86 | 69 | "src/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"], |
87 | 70 | "src/wp-content/themes/{$name}/": ["type:wordpress-theme"] |
88 | 71 | } |
72 | + }, | |
73 | + "scripts": { | |
74 | + "pre-install-cmd": "/bin/bash ./pre-update.sh", | |
75 | + "pre-update-cmd": "/bin/bash ./pre-update.sh", | |
76 | + "post-update-cmd": "/bin/bash ./post-update.sh", | |
77 | + "post-install-cmd": "/bin/bash ./post-update.sh" | |
89 | 78 | } |
90 | 79 | } | ... | ... |
... | ... | @@ -0,0 +1,30 @@ |
1 | +<?php | |
2 | +$path = $_GET{'src'}; | |
3 | + | |
4 | +$dirs = explode('/', $path); | |
5 | +$img = implode('/', $dirs); | |
6 | + | |
7 | +if(strpos($img, ".jpg") !== false || strpos($img, ".jpeg")){ | |
8 | + $contentType = "image/jpeg"; | |
9 | +}elseif(strpos($img, ".png") !== false){ | |
10 | + $contentType = "image/png"; | |
11 | +}else{ | |
12 | + $contentType = "image/gif"; | |
13 | +} | |
14 | + | |
15 | +header("Content-Type: {$contentType}", true); | |
16 | +ob_start(); | |
17 | +if(file_exists($img)){ | |
18 | + readfile($img); | |
19 | + die; | |
20 | +}else{ | |
21 | + array_pop($dirs); | |
22 | + $localDir = implode('/', $dirs); | |
23 | + if(!file_exists($localDir) || !is_dir($localDir)){ | |
24 | + mkdir($localDir, 777, true); | |
25 | + } | |
26 | + $content = file_get_contents("http://pensando.mj.gov.br/{$img}"); | |
27 | + file_put_contents($img, $content); | |
28 | + ob_clean(); | |
29 | + echo $content; | |
30 | +} | ... | ... |
config/htaccess-vagrant
... | ... | @@ -6,12 +6,12 @@ RewriteRule ^index\.php$ - [L] |
6 | 6 | # add a trailing slash to /wp-admin |
7 | 7 | RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] |
8 | 8 | |
9 | -RewriteRule (^wp\-content\/[^.]+\.(jpe?g|gif|bmp|png))$ /file.php?src=$1 [L] | |
9 | +RewriteRule (^wp\-content\/[^.]+\.(jpe?g|gif|bmp|png))$ /file-remote.php?src=$1 [L] | |
10 | 10 | |
11 | 11 | RewriteCond %{REQUEST_FILENAME} -f [OR] |
12 | 12 | RewriteCond %{REQUEST_FILENAME} -d |
13 | 13 | RewriteRule ^ - [L] |
14 | 14 | RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] |
15 | -RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] | |
15 | +RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L] | |
16 | 16 | RewriteRule . index.php [L] |
17 | 17 | </IfModule> | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * Front to the WordPress application. This file doesn't do anything, but loads | |
4 | + * wp-blog-header.php which does and tells WordPress to load the theme. | |
5 | + * | |
6 | + * @package WordPress | |
7 | + */ | |
8 | + | |
9 | +/** | |
10 | + * Tells WordPress to load the WordPress theme and output it. | |
11 | + * | |
12 | + * @var bool | |
13 | + */ | |
14 | +define('WP_USE_THEMES', true); | |
15 | + | |
16 | +/** Loads the WordPress Environment and Template */ | |
17 | +require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' ); | ... | ... |
config/wp-config-vagrant.php
... | ... | @@ -97,11 +97,14 @@ define('PATH_CURRENT_SITE', '/'); |
97 | 97 | define('SITE_ID_CURRENT_SITE', 1); |
98 | 98 | define('BLOG_ID_CURRENT_SITE', 1); |
99 | 99 | |
100 | +define( 'WP_PLUGIN_DIR', dirname(__FILE__) . '/wp-content/plugins' ); | |
101 | +define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/wp-content' ); | |
102 | + | |
100 | 103 | /* Isto é tudo, pode parar de editar! :) */ |
101 | 104 | |
102 | 105 | /** Caminho absoluto para o diretório WordPress. */ |
103 | 106 | if ( !defined('ABSPATH') ) |
104 | - define('ABSPATH', dirname(__FILE__) . '/'); | |
107 | + define('ABSPATH', dirname(__FILE__) . '/wp/'); | |
105 | 108 | |
106 | 109 | /** Configura as variáveis do WordPress e arquivos inclusos. */ |
107 | 110 | require_once(ABSPATH . 'wp-settings.php'); | ... | ... |
... | ... | @@ -0,0 +1,7 @@ |
1 | +cp config/wp-config-vagrant.php src/wp-config.php | |
2 | +cp config/htaccess-vagrant src/.htaccess | |
3 | +cp config/file-remote.php src/file-remote.php | |
4 | +cp config/index-vagrant.php src/index.php | |
5 | +rm -f src/wp/index.php | |
6 | +ln -s wp/wp-admin src/wp-admin | |
7 | +ln -s wp/wp-includes src/wp-includes | |
0 | 8 | \ No newline at end of file | ... | ... |
src/file-remote.php
... | ... | @@ -1,29 +0,0 @@ |
1 | -<?php | |
2 | -$path = $_GET{'src'}; | |
3 | - | |
4 | -$dirs = explode('/', $path); | |
5 | -$img = implode('/', $dirs); | |
6 | - | |
7 | -if(strpos($img, ".jpg") !== false || strpos($img, ".jpeg")){ | |
8 | - $contentType = "image/jpeg"; | |
9 | -}elseif(strpos($img, ".png") !== false){ | |
10 | - $contentType = "image/png"; | |
11 | -}else{ | |
12 | - $contentType = "image/gif"; | |
13 | -} | |
14 | - | |
15 | -header("Content-Type: {$contentType}", true); | |
16 | - | |
17 | -if(file_exists($img)){ | |
18 | - $content = file_get_contents($img); | |
19 | -}else{ | |
20 | - array_pop($dirs); | |
21 | - $localDir = implode('/', $dirs); | |
22 | - if(!file_exists($localDir) || is_dir($localDir)){ | |
23 | - mkdir($localDir, 777, true); | |
24 | - } | |
25 | - $content = file_get_contents("http://pensando.mj.gov.br/{$img}"); | |
26 | - file_put_contents($img, $content); | |
27 | -} | |
28 | - | |
29 | -die($content); |