soxer 0.9.0 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/soxer ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/ruby
2
+ require 'fileutils'
3
+
4
+ def colorize(text, color_code); "\033#{color_code}#{text}\033[0m"; end
5
+ def b(text); colorize(text, "[1m"); end
6
+
7
+ def h
8
+ '-'*79+"\n#{b 'Soxer'}, the web publishing tool. | Copyright 2010, Toni Anzlovar.\n"+'-'*79
9
+ end
10
+
11
+ def err message
12
+ <<END
13
+ #{h}
14
+ #{b message}
15
+ Type #{b 'soxer help'} to get help.
16
+
17
+ Soxer usage:
18
+ #{b "soxer [action] [parameters]"}
19
+
20
+ END
21
+ end
22
+
23
+ def notice message
24
+ <<END
25
+ #{h}
26
+ #{b message}
27
+
28
+ END
29
+ end
30
+
31
+ @help = <<END
32
+ #{h}
33
+
34
+ Soxer usage:
35
+ #{b "soxer [action] [parameters]"}
36
+
37
+ Actions:
38
+
39
+ #{b 'create'}
40
+ Creates a new soxer project directory with default sinatra/soxer layout.
41
+ All aspects can be later customized to suite project's needs.
42
+
43
+ First parameter:
44
+ #{b 'empty'} - Creates an empty project
45
+ More project templates are in the making
46
+
47
+ Other parameters:
48
+ #{b '[name]'} - The name of the project directory
49
+
50
+ #{b 'test'}
51
+ Runs the developement server (in the foreground) on your computer.
52
+ Point your browser to #{b 'http://localhost:9394'} to view the result.
53
+ You can exit with standard [ctrl]+c.
54
+
55
+ Parameters:
56
+ #{b '[int]'} - Port number you wish to run developement on
57
+
58
+ #{b 'help'}
59
+ Displays this help.
60
+
61
+ Examples:
62
+
63
+ #{b '$ soxer create blog myblog'}
64
+ This command would create a new project directory 'myblog' with a mockup blog
65
+ soxer/sinatra application in it. You can tweak the design and parameters to
66
+ acheve the desired experience.
67
+
68
+ #{b '$ soxer test 8907'}
69
+ This command (when executed within the soxer project directory root) will
70
+ run the developement server on local machine on port 8907.
71
+
72
+ END
73
+
74
+ def create
75
+ template = $*[1]
76
+ # Define skeleton parent directory
77
+ skel = File.dirname(__FILE__)+"/../lib/soxer/skel"
78
+ # Define destination or default
79
+ dir = $*[2] ? $*[2] : 'soxer-app'
80
+ # Copy skeleton to destination or fail if nonexistent
81
+ if template!=nil and File.exist?(skel+'/'+template) and !File.exist?(dir)
82
+ src = skel+'/'+template
83
+ # Check for destination existance
84
+ if !File.exist?(dir)
85
+ FileUtils.mkdir(dir)
86
+ FileUtils.cp_r(src+"/.", dir)
87
+ return notice "Successfuly created '"+dir+"' Directory."
88
+ #return Dir.glob(src+"/**/*").to_s
89
+ else
90
+ return err 'The destination directory exists.'
91
+ end
92
+ else
93
+ return err 'The project skeleton directory does not exist.'
94
+ end
95
+ end
96
+
97
+ def test
98
+ port = $*[1]!=nil ? $*[1] : '9394'
99
+ server = false
100
+ servers = %w[webrick mongrel thin]
101
+ servers.each do |s|
102
+ ENV['PATH'].split(':').each {|folder| server = s if File.exists?(folder+'/'+s)}
103
+ end
104
+ if server!=false
105
+ system("rackup -s #{server} -p #{port}")
106
+ return notice "End of developement mode."
107
+ else
108
+ return err "Please install a sinatra compatible web server (thin, mongrel or webrick.)"
109
+ end
110
+ end
111
+
112
+ case $*[0]
113
+ when 'create' then printf create
114
+ when 'test' then printf test
115
+ when 'help' then printf @help
116
+ else printf err 'You did not specify an action!'
117
+ end
118
+
119
+
120
+ x = <<END
121
+ #{b 'corporate'} - Creates a corporate web page mockup
122
+ #{b 'blog'} - Creates a blog mockup
123
+ #{b 'gallery'} - Creates an image gallery mockup
124
+ END
data/lib/soxer/main.rb CHANGED
@@ -165,7 +165,6 @@ module Sinatra
165
165
  out << haml( template, :layout => false, :locals => { :page=>get_page, :feed=>output, :author=>author } )
166
166
  end
167
167
 
168
-
169
168
  def google_ads options={}
170
169
  template = File.read File.join( File.dirname(__FILE__), 'views', 'google_ads.haml' )
171
170
  pattern = File.join( settings.root, settings.origin, "**", "*.yaml" )
@@ -182,11 +181,6 @@ module Sinatra
182
181
  haml( template, options.merge!( :layout => false ) )
183
182
  end
184
183
 
185
- def recaptcha options={}
186
- template = File.read File.join( File.dirname(__FILE__), 'views', 'recaptcha.haml' )
187
- haml( template, options.merge!( :layout => false ) )
188
- end
189
-
190
184
  #=== "partial" rails like partial generator
191
185
  #
192
186
  # This funnction accepts a string and matches it to a haml layout (with a
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ require "rubygems"
3
+ require "sinatra"
4
+ require "soxer"
5
+
6
+ not_found { 'The document does not exist' }
7
+
8
+ get("/sitemap.xml") { sitemap }
9
+
10
+ get "/css/:sheet.css" do
11
+ content_type "text/css", :charset => "utf-8"
12
+ sass params[:sheet].to_sym
13
+ end
14
+
15
+ get '*.*' do
16
+ file = File.join( settings.root, settings.origin, params[:splat].join('.') )
17
+ case params[:splat][1]
18
+ when /[jpg|png|pdf|doc|xls|pdf]/ then send_file(file, :disposition => nil)
19
+ end
20
+ end
21
+
22
+ post '*/?' do
23
+ content_type "text/html", :charset => "utf-8"
24
+ page = get_page
25
+ page['layout'] ||= 'layout'
26
+ haml page['content'], :layout => page['layout'].to_sym, :locals => { :page => page }
27
+ end
28
+
29
+ get '*/?' do
30
+ content_type "text/html", :charset => "utf-8"
31
+
32
+ if params[:splat][0] =~ /-atom$/ then
33
+ set :haml, { :format => :xhtml }
34
+ content_type "application/atom+xml", :charset => "utf-8"
35
+ end
36
+
37
+ page = get_page
38
+ page['layout'] ||= 'layout'
39
+ haml page['content'], :layout => page['layout'].to_sym, :locals => { :page => page }
40
+ end
@@ -0,0 +1,22 @@
1
+ require "rubygems"
2
+ require "sinatra/base"
3
+ require "app"
4
+
5
+ disable :run
6
+ set :server, %w[thin mongrel webrick]
7
+ set :origin, "content"
8
+ set :haml, {:encoding => 'utf-8',
9
+ :format => :html5,
10
+ :attr_wrapper => '"' }
11
+
12
+ configure :development do
13
+ require 'sinatra/reloader'
14
+ set :port, 9394
15
+ end
16
+
17
+ configure :production do
18
+ set :port, 55500
19
+ end
20
+
21
+ set :environment, :production
22
+ run Sinatra::Application
@@ -0,0 +1,14 @@
1
+ ---
2
+ environment: production
3
+ chdir: /path/to/your/application/home/dir
4
+ address: 0.0.0.0
5
+ user: toni
6
+ group: toni
7
+ port: 55500
8
+ pid: /path/to/your/application/home/dir/log/thin.pid
9
+ log: /path/to/your/application/home/dir/log/thin.log
10
+ rackup: /path/to/your/application/home/dir/config.ru
11
+ max_conns: 1024
12
+ timeout: 30
13
+ max_persistent_conns: 512
14
+ daemonize: true
@@ -0,0 +1,6 @@
1
+ uuid: 151af640-c35a-012d-f6b7-001e378a2988
2
+ date: 2010-10-26T20:03:43+02:00
3
+ title: Congratulations!
4
+ content: |
5
+ %h1= page['title']
6
+ %p You have just created your first #{link_to 'soxer', 'http://soxer.mutsu.org'} application.
@@ -0,0 +1,7 @@
1
+ $white = #ffffff
2
+ body
3
+ color: $white
4
+ background: #800000
5
+
6
+ a
7
+ color: $white
@@ -0,0 +1,8 @@
1
+ !!! 5
2
+ %html( lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" )
3
+ %head
4
+ %title= "Title page: "+page['title']
5
+ %meta(charset="utf-8")
6
+ %link( href="/css/css.css" media="screen" rel="stylesheet" type="text/css" )
7
+ %body
8
+ = yield
data/soxer.gemspec CHANGED
@@ -4,12 +4,12 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.7'
5
5
 
6
6
  s.name = 'soxer'
7
- s.version = '0.9.0'
8
- s.date = '2010-10-25'
7
+ s.version = '0.9.4'
8
+ s.date = '2010-10-27'
9
9
  s.rubyforge_project = 'soxer'
10
10
 
11
- s.summary = "Dynamic web site engine"
12
- s.description = "Soxer is a file based dynamic web creation tool for Sinatra."
11
+ s.summary = "Dynamic web site generator engine"
12
+ s.description = "Soxer is a file based dynamic web site creation tool for Sinatra."
13
13
 
14
14
  s.authors = ["Toni Anzlovar"]
15
15
  s.email = 'toni@formalibre.si'
@@ -27,16 +27,13 @@ Gem::Specification.new do |s|
27
27
  # = MANIFEST =
28
28
  s.files = %w[
29
29
  soxer.gemspec
30
+ bin/soxer
30
31
  lib/soxer.rb
31
32
  lib/soxer/main.rb
32
- lib/soxer/views/sitemap.haml
33
- lib/soxer/views/recaptcha.haml
34
- lib/soxer/views/google_analytics.haml
35
- lib/soxer/views/google_ads.haml
36
- lib/soxer/views/disqus.haml
37
- lib/soxer/views/atom.haml
38
- ]
33
+ ] + Dir.glob("{lib/soxer/views,lib/soxer/skel}/**/*")
39
34
  # = MANIFEST =
35
+
36
+ s.executables = ['soxer']
40
37
 
41
38
  s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
42
39
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soxer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 0
10
- version: 0.9.0
9
+ - 4
10
+ version: 0.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Toni Anzlovar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-25 00:00:00 +02:00
18
+ date: 2010-10-27 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -60,24 +60,30 @@ dependencies:
60
60
  version: "2"
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
- description: Soxer is a file based dynamic web creation tool for Sinatra.
63
+ description: Soxer is a file based dynamic web site creation tool for Sinatra.
64
64
  email: toni@formalibre.si
65
- executables: []
66
-
65
+ executables:
66
+ - soxer
67
67
  extensions: []
68
68
 
69
69
  extra_rdoc_files: []
70
70
 
71
71
  files:
72
72
  - soxer.gemspec
73
+ - bin/soxer
73
74
  - lib/soxer.rb
74
75
  - lib/soxer/main.rb
76
+ - lib/soxer/views/atom.haml
75
77
  - lib/soxer/views/sitemap.haml
76
- - lib/soxer/views/recaptcha.haml
78
+ - lib/soxer/views/disqus.haml
77
79
  - lib/soxer/views/google_analytics.haml
78
80
  - lib/soxer/views/google_ads.haml
79
- - lib/soxer/views/disqus.haml
80
- - lib/soxer/views/atom.haml
81
+ - lib/soxer/skel/empty/content/index.yaml
82
+ - lib/soxer/skel/empty/config.yml
83
+ - lib/soxer/skel/empty/config.ru
84
+ - lib/soxer/skel/empty/views/layout.haml
85
+ - lib/soxer/skel/empty/views/css.sass
86
+ - lib/soxer/skel/empty/app.rb
81
87
  has_rdoc: true
82
88
  homepage: http://soxer.mutsu.org
83
89
  licenses: []
@@ -111,6 +117,6 @@ rubyforge_project: soxer
111
117
  rubygems_version: 1.3.7
112
118
  signing_key:
113
119
  specification_version: 2
114
- summary: Dynamic web site engine
120
+ summary: Dynamic web site generator engine
115
121
  test_files: []
116
122
 
@@ -1,19 +0,0 @@
1
- :ruby
2
- width ||= 500;
3
- height ||= 300;
4
- theme ||= 'white'
5
- lang ||= 'en'
6
-
7
- %script(type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js")
8
- :javascript
9
- Recaptcha.create("#{key}", "recaptcha", {
10
- theme: "#{theme}",
11
- callback: Recaptcha.focus_response_field }
12
- );
13
- %noscript
14
- %iframe(src="http://www.google.com/recaptcha/api/noscript?k=#{key}" height="#{height}" width="#{width}" frameborder="0")
15
- %br
16
- %textarea(name="recaptcha_challenge_field" rows="3" cols="40")
17
- %input(type="hidden" name="recaptcha_response_field" value="manual_challenge")
18
-
19
- #recaptcha