trivial 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,5 +1,10 @@
1
1
  Manifest
2
2
  Rakefile
3
3
  bin/trivialize
4
+ content/index.html
4
5
  dist/htaccess.dist
5
6
  lib/trivial.php
7
+ readme.md
8
+ styles/application.css
9
+ trivial.gemspec
10
+ views/application.inc
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('trivial', '0.0.2') do |p|
5
+ Echoe.new('trivial', '0.0.3') do |p|
6
6
  p.summary = "Ultra-lightweight website framework for PHP"
7
7
  p.description = <<-EOT
8
8
  For those who are using PHP to build their sites and want a very simple framework
data/bin/trivialize CHANGED
@@ -12,13 +12,14 @@ FileUtils.mkdir ARGV[0] if (!File.directory? ARGV[0])
12
12
  FileUtils.mkdir File.join(ARGV[0], dir) if (!File.directory? File.join(ARGV[0], dir))
13
13
  end
14
14
 
15
- FileUtils.cp(File.join(File.dirname(__FILE__), '..', 'lib', 'trivial.php'), File.join(ARGV[0], 'lib', 'trivial.php'))
16
- FileUtils.cp(File.join(File.dirname(__FILE__), '..', 'dist', 'htaccess.dist'), File.join(ARGV[0], '.htaccess'))
17
-
18
- if !File.exists? File.join(ARGV[0], 'content', 'index.html')
19
- File.open File.join(ARGV[0], 'content', 'index.html'), "w" do |fh|
20
- fh.puts %{Your Website construction work just became <a href="http://github.com/johnbintz/trivial/">trivial</a>!}
21
- end
15
+ [
16
+ [ [File.dirname(__FILE__), '..', 'lib', 'trivial.php'], [ARGV[0], 'lib', 'trivial.php'] ],
17
+ [ [File.dirname(__FILE__), '..', 'dist', 'htaccess.dist'], [ARGV[0], '.htaccess'] ],
18
+ [ [File.dirname(__FILE__), '..', 'views', 'application.inc'], [ARGV[0], 'views', 'application.inc'] ],
19
+ [ [File.dirname(__FILE__), '..', 'content', 'index.html'], [ARGV[0], 'content', 'index.html'] ],
20
+ [ [File.dirname(__FILE__), '..', 'styles', 'application.css'], [ARGV[0], 'styles', 'application.css'] ]
21
+ ].each do |src, dest|
22
+ FileUtils.cp(File.join(*src), File.join(*dest))
22
23
  end
23
24
 
24
25
  puts "Done! Make sure you can use .htaccess files in your Webserver setup."
@@ -0,0 +1,5 @@
1
+ <h1>Welcome to Trivial</h1>
2
+
3
+ <p>
4
+ Buiding your site has now become <a href="http://github.com/johnbintz/trivial">trivial</a>!
5
+ </p>
data/lib/trivial.php CHANGED
@@ -39,11 +39,11 @@ $requested = preg_replace('#/$#', '/index.html', $_SERVER['REDIRECT_URL']);
39
39
  $requested = preg_replace("#${trim}/(.*)\.[^\.]+\$#", '\1', $requested);
40
40
 
41
41
  function styles($additional = array()) {
42
- return head_component($additional, 'styles/%s.css', '<link rel="stylesheet" href="%s" type="text/css" />');
42
+ return head_component($additional, 'styles/%s.css', '<link rel="stylesheet" href="styles/%s.css" type="text/css" />');
43
43
  }
44
44
 
45
45
  function scripts($additional = array()) {
46
- return head_component($additional, 'scripts/%s.js', '<script type="text/javascript" src="%s"></script>');
46
+ return head_component($additional, 'scripts/%s.js', '<script type="text/javascript" src="scripts/%s.js"></script>');
47
47
  }
48
48
 
49
49
  function head_component($additional, $search, $format) {
data/readme.md ADDED
@@ -0,0 +1,37 @@
1
+ # Trivial - the ultra-lightweight Web framework for PHP
2
+
3
+ ## Installation
4
+
5
+ Installation is done via RubyGems:
6
+
7
+ `gem install trivial`
8
+
9
+ A new binary is created, `trivialize`.
10
+
11
+ ## Creating a new site
12
+
13
+ `cd` to the directory where you want your new site and type:
14
+
15
+ `trivialize my-new-site`
16
+
17
+ A directory called `my-new-site` will be created with the site structure in place. An example `content/index.html` and `views/application.inc` will also be installed.
18
+
19
+ ## The request process
20
+
21
+ When a request comes in to that directory for a file that doesn't exist, trivial
22
+ does the following (for the examples, the request was for `about_us/contact.html` and the default `$layout` value is `"application"`):
23
+
24
+ * The `content` folder is checked for a `.html` file that matches the path (`content/about_us/contact.html`). If it exists, the contents of the file are pulled into the global `$content` variable.
25
+ * The `actions` folder is checked for two files:
26
+ * `actions/application.inc`
27
+ * `actions/about_us/contact.inc`
28
+ Each found file is included into the program, potentially modifying `$content` or `$layout`.
29
+ * The `views` folder is checked for two files:
30
+ * `views/about_us/contact.inc`
31
+ * `views/application.inc`
32
+ Each found file is included into the program, including `$content` where specified and outputting back into `$content`.
33
+ * The value of `$content` is output to the visitor.
34
+
35
+ ## Styles and scripts
36
+
37
+ Styles and scripts can be searched for in a structured way. The included `views/application.inc` gives an example as to how this works.
@@ -0,0 +1,7 @@
1
+ * {
2
+ font-family: helvetica, arial
3
+ }
4
+
5
+ body {
6
+ background-color: #eee
7
+ }
data/trivial.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{trivial}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Bintz"]
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.email = %q{john@coswelproductions.com}
19
19
  s.executables = ["trivialize"]
20
20
  s.extra_rdoc_files = ["bin/trivialize", "lib/trivial.php"]
21
- s.files = ["Manifest", "Rakefile", "bin/trivialize", "dist/htaccess.dist", "lib/trivial.php", "trivial.gemspec"]
21
+ s.files = ["Manifest", "Rakefile", "bin/trivialize", "content/index.html", "dist/htaccess.dist", "lib/trivial.php", "readme.md", "styles/application.css", "trivial.gemspec", "views/application.inc"]
22
22
  s.homepage = %q{http://github.com/johnbintz/trivial}
23
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Trivial"]
23
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Trivial", "--main", "readme.md"]
24
24
  s.require_paths = ["lib"]
25
25
  s.rubyforge_project = %q{trivial}
26
26
  s.rubygems_version = %q{1.3.6}
@@ -0,0 +1,10 @@
1
+ <html>
2
+ <head>
3
+ <title>My Application</title>
4
+ <?php echo scripts() ?>
5
+ <?php echo styles() ?>
6
+ </head>
7
+ <body>
8
+ <?php echo $content ?>
9
+ </body>
10
+ </html>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Bintz
@@ -36,9 +36,13 @@ files:
36
36
  - Manifest
37
37
  - Rakefile
38
38
  - bin/trivialize
39
+ - content/index.html
39
40
  - dist/htaccess.dist
40
41
  - lib/trivial.php
42
+ - readme.md
43
+ - styles/application.css
41
44
  - trivial.gemspec
45
+ - views/application.inc
42
46
  has_rdoc: true
43
47
  homepage: http://github.com/johnbintz/trivial
44
48
  licenses: []
@@ -49,6 +53,8 @@ rdoc_options:
49
53
  - --inline-source
50
54
  - --title
51
55
  - Trivial
56
+ - --main
57
+ - readme.md
52
58
  require_paths:
53
59
  - lib
54
60
  required_ruby_version: !ruby/object:Gem::Requirement