middleman-php 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +12 -0
- data/Rakefile +4 -0
- data/lib/middleman-php/extension.rb +17 -0
- data/lib/middleman-php/middleware.rb +22 -0
- data/lib/middleman-php.rb +4 -0
- data/lib/middleman_extension.rb +1 -0
- data/lib/php_middleware.rb +21 -0
- data/middleman-php.gemspec +24 -0
- data/readme.md +41 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 271f40ca44968c945214e6326ef44b3ae3460dc3
|
4
|
+
data.tar.gz: f3677f60ff7356b6b6e371435fa94e360627ccfb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0abdf98107fd488ff0cb38bb5a21145425149740878c51a7bab52f7b91fbcb95fe4397756e33a0bf1b80851c41e0f5ceaa7f4bed24dc23c1d731d38162190083
|
7
|
+
data.tar.gz: 59950186010e88c02226e04f61ea06b0d030c4ec45cbad029de2226347f7dabe58a8fbc46f24aa89fa01da14583043ec4862a67f23b5908b97549b7867fd713e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# If you have OpenSSL installed, we recommend updating
|
2
|
+
# the following line to use "https"
|
3
|
+
source 'http://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in middleman-php.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem "rake"
|
10
|
+
gem "rdoc"
|
11
|
+
gem "yard"
|
12
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Middleman
|
2
|
+
class PhpExtension < Extension
|
3
|
+
# option :set_blah, "default", "An example option"
|
4
|
+
|
5
|
+
def initialize(app, options_hash={}, &block)
|
6
|
+
# Call super to build options from the options_hash
|
7
|
+
super
|
8
|
+
|
9
|
+
require 'shellwords'
|
10
|
+
app.use Middleman::PhpMiddleware
|
11
|
+
|
12
|
+
app.before do
|
13
|
+
template_extensions :php => :html
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Middleman
|
2
|
+
class PhpMiddleware
|
3
|
+
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
status, headers, response = @app.call(env)
|
10
|
+
|
11
|
+
if env['REQUEST_PATH'] =~ /\.php$/
|
12
|
+
response.body.map! do |item|
|
13
|
+
`echo #{Shellwords.escape(item)} | php`
|
14
|
+
end
|
15
|
+
headers['Content-Length'] = response.body.join.length.to_s
|
16
|
+
headers['Content-Type'] = 'text/html'
|
17
|
+
end
|
18
|
+
|
19
|
+
[status, headers, response]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "middleman-php"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class PhpMiddleware
|
2
|
+
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
status, headers, response = @app.call(env)
|
9
|
+
|
10
|
+
if env['REQUEST_PATH'] =~ /\.php$/
|
11
|
+
response.body.map! do |item|
|
12
|
+
`echo #{Shellwords.escape(item)} | php`
|
13
|
+
end
|
14
|
+
headers['Content-Length'] = response.body.join.length.to_s
|
15
|
+
headers['Content-Type'] = 'text/html'
|
16
|
+
end
|
17
|
+
|
18
|
+
[status, headers, response]
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "middleman-php"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Robert Lord"]
|
9
|
+
s.email = ["robert@lord.io"]
|
10
|
+
s.homepage = "https://github.com/lord/middleman-php"
|
11
|
+
s.summary = %q{Use Middleman to build PHP files}
|
12
|
+
# s.description = %q{A longer description of your extension}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# The version of middleman-core your extension depends on
|
20
|
+
s.add_runtime_dependency("middleman-core", [">= 3.2.1"])
|
21
|
+
|
22
|
+
# Additional dependencies
|
23
|
+
# s.add_runtime_dependency("gem-name", "gem-version")
|
24
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# middleman-php
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
In your Middleman project's `Gemfile`, add:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem "middleman-php"
|
9
|
+
```
|
10
|
+
|
11
|
+
and in your `config.rb`, add:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
configure :development do
|
15
|
+
activate :php
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
If you want the php to be parsed on builds, too (instead of left for your server to parse), just omit the `configure` block:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
activate :php
|
23
|
+
```
|
24
|
+
|
25
|
+
## FAQ
|
26
|
+
|
27
|
+
### So wait, what does this do?
|
28
|
+
|
29
|
+
It lets [Middleman](https://github.com/middleman/middleman)'s server render PHP. So your `source/kittens.php` file will actually render kittens, and not a mess of `<?php` open tags.
|
30
|
+
|
31
|
+
### Oh lord, why?? Why would you want that???
|
32
|
+
|
33
|
+
Sometimes I have clients who want little bits of PHP interactivity on their site, but I still want to use Middleman to generate the PHP pages. This makes it so you don't have to `middleman build` and then upload to your site just to get a preview.
|
34
|
+
|
35
|
+
### Are there any limitations?
|
36
|
+
|
37
|
+
It will only render on pages where the URL ends in `.php`...so if you want to see `index.php`, you'll have to actually stick `index.php` in your browser.
|
38
|
+
|
39
|
+
Also, right now the rendering is done through PHP's command line interface, which has [some limitations](http://www.php.net/manual/en/features.commandline.differences.php)...including no $_GET or $_POST. Hopefully this will be fixed in the future.
|
40
|
+
|
41
|
+
There are probably also bugs I haven't found, so if you find one, feel free to submit an issue!
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-php
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Lord
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: middleman-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.1
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- robert@lord.io
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Rakefile
|
37
|
+
- lib/middleman-php.rb
|
38
|
+
- lib/middleman-php/extension.rb
|
39
|
+
- lib/middleman-php/middleware.rb
|
40
|
+
- lib/middleman_extension.rb
|
41
|
+
- lib/php_middleware.rb
|
42
|
+
- middleman-php.gemspec
|
43
|
+
- readme.md
|
44
|
+
homepage: https://github.com/lord/middleman-php
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.2.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Use Middleman to build PHP files
|
67
|
+
test_files: []
|