picombo 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,7 +86,7 @@ module Picombo
86
86
  # Try and load the controller class
87
87
  begin
88
88
  controller = Picombo::Controllers::const_get(uri[:controller].capitalize!).new
89
- rescue LoadError
89
+ rescue LoadError, NameError
90
90
  return Picombo::Controllers::Error_404.new.run_error(@@req.path)
91
91
  end
92
92
 
data/lib/core/core.rb CHANGED
@@ -13,7 +13,6 @@ module Picombo
13
13
  #
14
14
  # The core class for Picombo. Handles system initialization and other core functionality.
15
15
  class Core
16
- @@extension = 'html'
17
16
  @@cli = false
18
17
 
19
18
  # Determines if the request was made on the CLI or not
@@ -21,15 +20,6 @@ module Picombo
21
20
  @@cli
22
21
  end
23
22
 
24
- # Gets the extension of the request
25
- def self.extension
26
- @@extension
27
- end
28
- # Assigns the extension of the request
29
- def self.extension=(extension)
30
- @@extension = extension
31
- end
32
-
33
23
  # Standard call function that gets invoked by Rack
34
24
  def call(env)
35
25
  # start system benchmark
@@ -41,11 +31,7 @@ module Picombo
41
31
  @@env = env
42
32
  @@req = Rack::Request.new(env)
43
33
 
44
- @@extension = File.extname(@@req.path)[1..-1]
45
- @@extension = 'html' if @@extension.nil?
46
-
47
34
  @@response = Rack::Response.new
48
- #@@response['Content-Type'] = Picombo::Config.load('mimes.'+@@extension)[0]
49
35
  @@response['Content-Type'] = 'text/html'
50
36
  @@response.status = 200
51
37
  @@redirect = []
@@ -60,7 +46,7 @@ module Picombo
60
46
  # Load hooks
61
47
  Picombo::Config.get('config.hooks').each do |hook|
62
48
  Picombo::Core.find_file('hooks', hook).each do |file|
63
- require file
49
+ load file
64
50
  end
65
51
  end
66
52
 
@@ -1,3 +1,3 @@
1
1
  Picombo::Event.add('system.display') do
2
- Picombo::View::Core.new('bench/footer').render()
2
+ Picombo::Stache::Bench_Footer.new.output
3
3
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 5
9
- version: 0.2.5
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Bush
@@ -14,10 +14,37 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-08 00:00:00 -05:00
17
+ date: 2010-06-15 00:00:00 -05:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rack
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
31
+ version: 1.0.0
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: mustache
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 10
44
+ - 0
45
+ version: 0.10.0
46
+ type: :runtime
47
+ version_requirements: *id002
21
48
  description: Picombo is a lightweight MVC web framework that enables you to create websites quickly.
22
49
  email: contractfrombelow@gmail.com
23
50
  executables: []
@@ -38,12 +65,8 @@ files:
38
65
  - ./lib/classes/input.rb
39
66
  - ./lib/classes/log.rb
40
67
  - ./lib/classes/router.rb
41
- - ./lib/classes/security.rb
42
68
  - ./lib/classes/session.rb
43
69
  - ./lib/classes/url.rb
44
- - ./lib/classes/view/stache.rb
45
- - ./lib/classes/view/xml.rb
46
- - ./lib/classes/view.rb
47
70
  - ./lib/config/cache.yaml
48
71
  - ./lib/config/log.yaml
49
72
  - ./lib/config/mimes.yaml
@@ -55,10 +78,8 @@ files:
55
78
  - ./lib/hooks/mustache.rb
56
79
  - ./lib/hooks/profiler.rb
57
80
  - ./lib/picombo.rb
58
- - ./lib/views/bench/footer.rhtml
59
81
  - ./lib/views/error/404.mustache
60
82
  - ./lib/views/error/404.rb
61
- - ./lib/views/tests/test.rhtml
62
83
  has_rdoc: true
63
84
  homepage: http://www.picombo.net/
64
85
  licenses: []
@@ -1,46 +0,0 @@
1
- module Picombo
2
- # Helper class for security things like xss
3
- class Security
4
- # Returns the base URL for use with any internal links.
5
- def self.xss_clean(str, driver = nil)
6
- driver = 'default' if driver.nil? or driver == true
7
-
8
- Security.send(driver, str)
9
- end
10
-
11
- #This is a blacklist method, so ensure this is what you really want
12
- def self.bitkeeper(str)
13
- # clean any control characters
14
- str.gsub!(/[\x00-\x20]*/, '')
15
- # clean null byte
16
- str.gsub!(/[\0]/, '')
17
-
18
- # Remove javascript: and vbscript: protocols
19
- str.gsub!(/([a-z]*)=([`"]*)javascript:/iu, '\1=\2nojavascript....')
20
- str.gsub!(/([a-z]*)=([`"]*)vbscript:/iu, '\1=\2novbscript....')
21
- str.gsub!(/#([a-z]*)=(["]*)-moz-binding:/u, '\1=\2nomozbinding...')
22
-
23
- # Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
24
- str.gsub!(/(<[^>]+?)style=[`"]*.*?expression\([^>]*>/i, '\1>')
25
- str.gsub!(/(<[^>]+?)style=[`"]*.*?behaviour\([^>]*>/i, '\1>')
26
- str.gsub!(/(<[^>]+?)style=[`"]*.*?script:*[^>]*>/iu, '\1>')
27
-
28
- # Remove namespaced elements (we do not need them)
29
- data = str.gsub(/<\/*\w+:\w[^>]*>/i, '')
30
-
31
- begin
32
- old_data = data
33
- data.gsub!(/<\/*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*>/i, '')
34
- end until old_data == data
35
-
36
- data
37
- end
38
-
39
- #default cleaner. encodes the strign to prevent xss
40
- def self.default(str)
41
- require 'htmlentities'
42
-
43
- HTMLEntities.new.encode(str)
44
- end
45
- end
46
- end
@@ -1,18 +0,0 @@
1
- module Picombo
2
- module View
3
- # == XML View
4
- #
5
- # The core view renders XML to the browser
6
- #
7
- # See the View documentation for usage specifics
8
- class Stache < Mustache
9
- # Standard constructor
10
- def initialize(filename)
11
- super(filename)
12
-
13
- # Changes the content type to xml for the application
14
- Picombo::Core.raw_response()['Content-Type'] = 'text/xml'
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- module Picombo
2
- module View
3
- # == XML View
4
- #
5
- # The core view renders XML to the browser
6
- #
7
- # See the View documentation for usage specifics
8
- class XML < Picombo::View::Core
9
- # Standard constructor
10
- def initialize(filename)
11
- super(filename)
12
-
13
- # Changes the content type to xml for the application
14
- Picombo::Core.raw_response()['Content-Type'] = 'text/xml'
15
- end
16
- end
17
- end
18
- end
data/lib/classes/view.rb DELETED
@@ -1,83 +0,0 @@
1
- module Picombo
2
- # == View Class
3
- #
4
- # The Picombo::View class allows for template files to be rendered and displayed in the browser.
5
- #
6
- # By default, only ERB templating is currently supported.
7
- # === Examples
8
- #
9
- # foobar = Picombo::View::Core.new('template')
10
- # # Sets a view variable
11
- # foobar.set('bar', 'baz')
12
- # # Renders the view to the output buffer
13
- # foobar.render
14
- #
15
- # You can also nest views like so:
16
- #
17
- # body = Picombo::View::Core.new('page/body')
18
- # body.set('content', 'Hello World!')
19
- # template = Picombo::View::Core.new('template')
20
- # template.set('body', body.render(true))
21
- # template.render
22
- #
23
- # This will render a body subview inside of your template view file
24
- module View
25
- # == Core View
26
- #
27
- # The core view renders HTML to the browser using ERB
28
- #
29
- # See the View documentation for usage specifics
30
- class Core
31
- require 'erb'
32
-
33
- @view_file = ''
34
- @view_data = []
35
-
36
- # Creates a new view object and sets the filename. Raises an IOError exception if the view file is not found
37
- def initialize(filename)
38
- @view_data = {}
39
- view_location = Picombo::Core.find_file('views', filename, false, 'rhtml').shift
40
-
41
- if view_location.nil?
42
- raise IOError
43
- end
44
-
45
- @view_file = view_location
46
- end
47
-
48
- # Support templating of member data.
49
- def get_binding
50
- binding
51
- end
52
-
53
- # Sets a view variable
54
- def set(key, val)
55
- instance_variable_set "@#{key}", val
56
- end
57
-
58
- # Renders the view to the output buffer, or optionally simply returns it if echo is true
59
- def render(return_output = false)
60
- view = ERB::new(File.read(@view_file))
61
-
62
- if return_output
63
- return view.result(get_binding())
64
- else
65
- Picombo::Core.response view.result(get_binding())
66
- end
67
- end
68
- end
69
-
70
- # Autoloader for missing view constants. Used to load non-standard view classes like XML.
71
- def View.const_missing(name)
72
- filename = name.to_s
73
-
74
- require 'classes/view/'+filename.downcase
75
-
76
- raise name.to_s+' not found!' if ! const_defined?(name)
77
-
78
- klass = const_get(name)
79
- return klass if klass
80
- raise klass+" not found!"
81
- end
82
- end
83
- end
@@ -1,22 +0,0 @@
1
- <table style="width: 100%">
2
- <tr>
3
- <th align="left">System Benchmarks</th>
4
- <th align="right">Time</th>
5
- </tr>
6
- <tr>
7
- <td>Picombo Setup</td>
8
- <td align="right"><%= Picombo::Bench.instance.get('loading') %></td>
9
- </tr>
10
- <tr>
11
- <td>Environment Setup</td>
12
- <td align="right"><%= Picombo::Bench.instance.get('setup') %></td>
13
- </tr>
14
- <tr>
15
- <td>Controller Execution</td>
16
- <td align="right"><%= Picombo::Bench.instance.get('controller_execution') %></td>
17
- </tr>
18
- <tr>
19
- <td>Total Execution</td>
20
- <td align="right"><%= Picombo::Bench.instance.get('application') %></td>
21
- </tr>
22
- </table>
@@ -1 +0,0 @@
1
- Test <%= @test %>