Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffolding #88

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
80b4139
Update BlueForm to HTML5 and add 'arrangements'.
mjwelchphd May 12, 2016
25952e1
Update ramaze/lib/ramaze/gestalt.rb to add some tags that had to be r…
mjwelchphd May 12, 2016
58eea23
Update spec/ramaze/helper/blue_form.rb to add additional tests for ne…
mjwelchphd May 12, 2016
39f3276
Changed BlueForm to also encapsulate button controls with the arrange…
mjwelchphd May 16, 2016
f3bdaae
This is the proto directory to add MySQL database to the created proj…
mjwelchphd May 17, 2016
5f54c4f
Fixed a problem where 'ramaze create -h' wouldn't work.
mjwelchphd May 17, 2016
09e202e
Added the capability of creating a database connection at the same ti…
mjwelchphd May 17, 2016
f04de60
Modified the controller init to load all controllers.
mjwelchphd May 17, 2016
a9ba634
Updated the version date for testing.
mjwelchphd May 17, 2016
3093b86
This is the proto-sqlite for using the Sqlite3 database with Ramaze.
mjwelchphd May 18, 2016
4fd4147
Merging manveru's changes with local.
mjwelchphd Jun 3, 2016
05a9cfc
Added 'to_html' to gestalt. By being here, it can be used for both ge…
mjwelchphd Jul 4, 2016
1bb5dae
Removed 'to_html' and put it into gestalt where it an be available fo…
mjwelchphd Jul 4, 2016
ca5376a
Added back a stub for 'to_html'.
mjwelchphd Jul 4, 2016
e9981bd
If you try to use BlueForm and Gestalt in the same controller, 'form_…
mjwelchphd Jul 4, 2016
1ad2033
The 'to_html' added to Gestalt was modifying the @out array causing a…
mjwelchphd Jul 6, 2016
a8fe1b3
Scaffolding is an 'on-the-fly' scaffold generator for use during deve…
mjwelchphd Jul 12, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/proto-mysql2/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file contains your application, it requires dependencies and necessary
# parts of the application.
require 'rubygems'
require 'ramaze'

# Make sure that Ramaze knows where you are
Ramaze.options.roots = [__DIR__]

require __DIR__('model/init')
require __DIR__('controller/init')
30 changes: 30 additions & 0 deletions lib/proto-mysql2/controller/main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Default url mappings are:
#
# * a controller called Main is mapped on the root of the site: /
# * a controller called Something is mapped on: /something
#
# If you want to override this, add a line like this inside the class:
#
# map '/otherurl'
#
# this will force the controller to be mounted on: /otherurl.
class MainController < Controller
# the index action is called automatically when no other action is specified
def index
@title = 'Welcome to Ramaze!'
begin
@database = DB["select database() as db"].first
rescue => e
@database = {:db => nil, :error => e.to_s}
end
end

# the string returned at the end of the function is used as the html body
# if there is no template for the action. if there is a template, the string
# is silently ignored
def notemplate
@title = 'Welcome to Ramaze!'

return 'There is no \'notemplate.xhtml\' associated with this action.'
end
end
34 changes: 34 additions & 0 deletions lib/proto-mysql2/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
dev:
adapter: {adapter}
host: {server}
database: {dbname}
username: {username}
password: {password}
encoding: utf8
reconnect: false
port: 3306

# Other Options (See https://github.com/brianmario/mysql2/blob/master/README.md)
# socket: '/path/to/mysql.sock'
# flags: REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION | MULTI_STATEMENTS
# encoding: 'utf8'
# read_timeout: seconds
# write_timeout: seconds
# connect_timeout: seconds
# reconnect: true/false
# local_infile: true/false
# secure_auth: true/false
# default_file: '/path/to/my.cfg'
# default_group: 'my.cfg section'
# init_command => sql

live:
adapter: {adapter}
host: {server}
database: {dbname}
username: {username}
password: {password}
encoding: utf8
reconnect: false
port: 3306

15 changes: 15 additions & 0 deletions lib/proto-mysql2/model/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Open the database
require 'ramaze'
require 'mysql2'
require 'sequel'
require 'yaml'

# open up the appropriate database and log it
Host = YAML.load_file("#{Ramaze.options.roots[0]}/database.yml")[ENV['MODE']]
DB = Sequel.connect(Host)
Ramaze::Log.info "Database \"#{Host['database']}\" opened"

# Require all models in the models folder
Dir.glob('model/*.rb').each do |model|
require("#{Ramaze.options.roots[0]}/#{model}")
end
55 changes: 55 additions & 0 deletions lib/proto-mysql2/view/index.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<p>
<?r if @database[:db] ?>
Congratulations, Ramaze is running fine and your database "#{@database[:db]}" is open on MySQL.<br/>
You can start working on your application.
<?r else ?>
Sorry, but your database isn't working properly.<br/>
The error message MySQL returned was:<br/>
&nbsp;&nbsp;#{@database[:error]}.
<?r end ?>
</p>

<p>
You can play around with this prototype by changing the following:
</p>

<ul>
<li>
<code>view/index.xhtml</code>: the content of this page.
</li>
<li>
<code>layout/default.xhtml</code>: the layout for this page.
</li>
<li>
<code>controller/main.rb</code>: the controller responsible for server this page.
</li>
<li>
<code>database.yml</code>: the database settings.
</li>
</ul>

<p>
For more information, check out <a href="http://ramaze.net">ramaze.net</a> and
<a href="http://ramaze.net/documentation/index.html">the documentation</a>.
<br />
You can also read the
<a href="http://doc.rubyists.com/ramaze%2binnate/">YARD documentation</a>
or browse around the <a href="https://github.com/ramaze/ramaze">Ramaze source code</a>.
</p>

<p>
For help with Ramaze, visit
<a href="irc://chat.freenode.net/ramaze">#ramaze on irc.freenode.net</a>.
<br />
You can use <a href="http://embed.mibbit.com/?server=irc.freenode.net&amp;channel=%23ramaze,%23ruby-lang&amp;forcePrompt=true">Mibbit</a>,
an AJAX based IRC client or
<a href="http://java.freenode.net/?channel=ramaze">
the official freenode irc java applet
</a>.
</p>

<p>
Feel free to post to the
<a href="https://groups.google.com/forum/#!forum/ramaze">Ramaze Google Group</a>, your
first mail has to go through moderation, so please be patient.
</p>
10 changes: 10 additions & 0 deletions lib/proto-sqlite/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file contains your application, it requires dependencies and necessary
# parts of the application.
require 'rubygems'
require 'ramaze'

# Make sure that Ramaze knows where you are
Ramaze.options.roots = [__DIR__]

require __DIR__('model/init')
require __DIR__('controller/init')
30 changes: 30 additions & 0 deletions lib/proto-sqlite/controller/main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Default url mappings are:
#
# * a controller called Main is mapped on the root of the site: /
# * a controller called Something is mapped on: /something
#
# If you want to override this, add a line like this inside the class:
#
# map '/otherurl'
#
# this will force the controller to be mounted on: /otherurl.
class MainController < Controller
# the index action is called automatically when no other action is specified
def index
@title = 'Welcome to Ramaze!'
begin
@database = DB["select random() as db"].first
rescue => e
@database = {:db => nil, :error => e.to_s}
end
end

# the string returned at the end of the function is used as the html body
# if there is no template for the action. if there is a template, the string
# is silently ignored
def notemplate
@title = 'Welcome to Ramaze!'

return 'There is no \'notemplate.xhtml\' associated with this action.'
end
end
8 changes: 8 additions & 0 deletions lib/proto-sqlite/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dev:
adapter: {adapter}
database: {dbname}

live:
adapter: {adapter}
database: {dbname}

15 changes: 15 additions & 0 deletions lib/proto-sqlite/model/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Open the database
require 'ramaze'
require 'sqlite3'
require 'sequel'
require 'yaml'

# open up the appropriate database and log it
Host = YAML.load_file("#{Ramaze.options.roots[0]}/database.yml")[ENV['MODE']]
DB = Sequel.connect("#{Host['adapter']}://#{Host['database']}")
Ramaze::Log.info "Database \"#{Host['database']}\" opened"

# Require all models in the models folder
Dir.glob('model/*.rb').each do |model|
require("#{Ramaze.options.roots[0]}/#{model}")
end
55 changes: 55 additions & 0 deletions lib/proto-sqlite/view/index.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<p>
<?r if @database[:db] ?>
Congratulations, Ramaze is running fine and your database is open on MySQL.<br/>
You can start working on your application.
<?r else ?>
Sorry, but your database isn't working properly.<br/>
The error message MySQL returned was:<br/>
&nbsp;&nbsp;#{@database[:error]}.
<?r end ?>
</p>

<p>
You can play around with this prototype by changing the following:
</p>

<ul>
<li>
<code>view/index.xhtml</code>: the content of this page.
</li>
<li>
<code>layout/default.xhtml</code>: the layout for this page.
</li>
<li>
<code>controller/main.rb</code>: the controller responsible for server this page.
</li>
<li>
<code>database.yml</code>: the database settings.
</li>
</ul>

<p>
For more information, check out <a href="http://ramaze.net">ramaze.net</a> and
<a href="http://ramaze.net/documentation/index.html">the documentation</a>.
<br />
You can also read the
<a href="http://doc.rubyists.com/ramaze%2binnate/">YARD documentation</a>
or browse around the <a href="https://github.com/ramaze/ramaze">Ramaze source code</a>.
</p>

<p>
For help with Ramaze, visit
<a href="irc://chat.freenode.net/ramaze">#ramaze on irc.freenode.net</a>.
<br />
You can use <a href="http://embed.mibbit.com/?server=irc.freenode.net&amp;channel=%23ramaze,%23ruby-lang&amp;forcePrompt=true">Mibbit</a>,
an AJAX based IRC client or
<a href="http://java.freenode.net/?channel=ramaze">
the official freenode irc java applet
</a>.
</p>

<p>
Feel free to post to the
<a href="https://groups.google.com/forum/#!forum/ramaze">Ramaze Google Group</a>, your
first mail has to go through moderation, so please be patient.
</p>
12 changes: 4 additions & 8 deletions lib/proto/controller/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ class Controller < Ramaze::Controller
engine :etanni
end

# Here you can require all your other controllers. Note that if you have multiple
# controllers you might want to do something like the following:
#
# Dir.glob('controller/*.rb').each do |controller|
# require(controller)
# end
#
require __DIR__('main')
# Require all controllers in the controllers folder
Dir.glob('controller/*.rb').each do |controller|
require("#{Ramaze.options.roots[0]}/#{controller}")
end
Loading