07 Sep
Just a quick note about the Open Flash Chart II plugin for Rails and Rails 3. Rails 3 did a 180 with regards to ERB tags and security. Everything is now considered unsafe HTML. So where we used to be able to do <%= @graph %>, we have to now do <%= @graph.html_safe %>.
Thanks go to kendagriff.
05 Jan
I was asked how to display date and time for the x axis as seen in this teethgrinder example - So here it goes.
Here is the graph we are after in this example:
More Open Flash Chart II examples.
And here is the code (the controller):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
class TestItController < ApplicationController
def index
@graph = open_flash_chart_object(550,300,"/test_it/chart")
end
def chart
data1 = []
data2 = []
year = Time.now.year
31.times do |i|
x = "#{year}-1-#{i+1}".to_time.to_i
y = (Math.sin(i+1) * 2.5) + 10
data1 << ScatterValue.new(x,y)
data2 << (Math.cos(i+1) * 1.9) + 4
end
dot = HollowDot.new
dot.size = 3
dot.halo_size = 2
dot.tooltip = "#date:d M y#<br>Value: #val#"
line = ScatterLine.new("#DB1750", 3)
line.values = data1
line.default_dot_style = dot
x = XAxis.new
x.set_range("#{year}-1-1".to_time.to_i, "#{year}-1-31".to_time.to_i)
x.steps = 86400
labels = XAxisLabels.new
labels.text = "#date: l jS, M Y#"
labels.steps = 86400
labels.visible_steps = 2
labels.rotate = 90
x.labels = labels
y = YAxis.new
y.set_range(0,15,5)
chart = OpenFlashChart.new
title = Title.new(data2.size)
chart.title = title
chart.add_element(line)
chart.x_axis = x
chart.y_axis = y
render :text => chart, :layout => false
end
end
|
And in your view (index.html.erb):
1
2
3
4
|
<script type="text/javascript" src="/javascripts/swfobject.js"></script>
<%= @graph %>
|
Good Luck!
04 Jan
A long time overdue, but I've managed to get everything updated to the new version of Teethgrinder's open flash chart.
I've also started tagging everything, so if you notice any problems trying to do anything from Teethgrinder's examples, then first check that you are using the latest (as of now, that is Lug Wyrm Charmer) - http://github.com/pullmonkey/open_flash_chart/tree/LugWyrmCharmer.
Make sure you are using the latest swf either from the plugin assets directory or from Teethgrinder's downloads.
28 Feb
You can also view the tutorial. Or you can check out the demo.
We are continuously adding to and changing the Simple CMS Plugin so here is a little rundown of what has been changed so far:
Major Changes:
Minor Changes:
- When you click on a revision you are taken back up to the top of the page instead of having to scroll all the way down a list of 100 revisions, clicking on one, and then manually scrolling all the way back up to the top to see if you even picked the right revision
- I have added code highlighting and this requires the coderay plugin, which has been added to the rake simple_cms:install_dependencies, and a coderay stylesheet so you need to add that to your application layout. I have included it in the rake simple_cms:install
1
2
3
|
<%= stylesheet_link_tag "coderay" %>
|
- I have also changed many things in the javascripts inside the tiny_mce editor so it would be safest just to use the rake tasks that are built in:
1
2
3
4
|
rake simple_cms:uninstall
rake simple_cms:install
|
I have updated the tutorial with all the changes as well.
There is also a demo that you can use to play around with it and ask questions.
02 Feb
Well, we have been working on SimpleCMS a little and just for kicks we added revisions.
Check out the Simple CMS Plugin Demo
On this page you will see the "Show all revisions" link at the bottom of the "edit" page.
So feel free to add or delete or change revisions at will.
Also, if you are new to SimpleCMS, check out the sort of rough getting stared page.
Well, enjoy and please leave comments/feedback/requests here in the comments or preferably in the list of requests we have started on the demo page 🙂
30 Dec
I have placed a nice little demo of this plugin under Pullmonkey Projects - http://pullmonkey.com/projects/simple_cms.
Please let us know what works, what does not work.
Thank you.
23 Dec
The SimpleCMS Plugin
Created by Slaive and PullMonkey (December 2007)
Check out the demo - http://pullmonkey.com/projects/simple_cms
This is still a work in progress so feel free to notify me of any bugs, problems, or suggestions of how to make it better.
This plugin is built for rails 2.0.2. So if you are using an older version of rails then you will need to edit each of the controllers
1
2
3
4
5
6
7
|
From:
self.view_paths << File.join(File.dirname(__FILE__), '..', 'views')
To:
self.template_root = File.join(File.dirname(__FILE__), '..', 'views')
|
Imaging Processor
For this plugin to be fully functional you will need to install one of the following Image Processing gems:
- ImageScience - A light inline-Ruby library that only resizes images.
- RMagick - The grand-daddy, both in terms of advanced image processing features and memory usage.
- minimagick - It's much easier on memory than RMagick because it runs the ImageMagick command in a shell.
Any one of these gems will work.
Install SimpleCMS and Dependencies
1
2
3
|
ruby script/plugin install http://svn.pullmonkey.com/plugins/trunk/simple_cms/
|
The simple_cms plugin requires the attachment_fu, responds_to_parent, acts_as_versioned, and coderay plugins as well. To make this easier I there is a built-in rake process
1
2
3
|
rake simple_cms:install_dependencies
|
However if this doesn't work then you can do it the normal way:
1
2
3
4
5
6
|
ruby script/plugin install http://svn.pullmonkey.com/plugins/trunk/attachment_fu/
ruby script/plugin install http://svn.pullmonkey.com/plugins/trunk/responds_to_parent/
ruby script/plugin install http://svn.pullmonkey.com/plugins/trunk/acts_as_versioned/
ruby script/plugin install http://svn.pullmonkey.com/plugins/trunk/coderay/
|
The Javascript/css Files
This plugin requires a great deal of javascript and css files that will need to be copied to the corresponding folder in your public/ directory. These files are located in the simple_cms/assets/ directory.
These files should have been copied over when you install the plugin. However, I built in a couple rake task commands to help you out installing and uninstalling these files if you need to.
1
2
3
4
|
rake simple_cms:install
rake simple_cms:uninstall
|
Creating the Tables
You will need to create 3 tables in your database.
- simple_cms_items
- simple_cms_images
- simple_cms_media
To have the migration tables generated for you use this command:
1
2
3
|
ruby script/generate simple_cms_migrations
|
The tables should look like this:
create_simple_cms_items.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
class CreateSimpleCmsItems < ActiveRecord::Migration
def self.up
create_table :simple_cms_items do |t|
t.column :params, :string
t.column :data, :text
t.column :position, :integer
t.column :created_at, :datetime
t.column :updated_at, :datetime
t.column :created_by, :string
t.column :updated_by, :string
end
SimpleCmsItem.create_versioned_table
end
def self.down
SimpleCmsItem.drop_versioned_table
drop_table :simple_cms_items
end
end
|
create_simple_cms_images.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class CreateSimpleCmsImages < ActiveRecord::Migration
def self.up
create_table :simple_cms_images do |t|
t.column :parent_id, :integer
t.column :content_type, :string
t.column :filename, :string
t.column :thumbnail, :string
t.column :size, :integer
t.column :width, :integer
t.column :height, :integer
end
end
def self.down
drop_table :simple_cms_images
end
end
|
create_simple_cms_medias.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class CreateSimpleCmsMedias < ActiveRecord::Migration
def self.up
create_table :simple_cms_medias do |t|
t.column :parent_id, :integer
t.column :content_type, :string
t.column :filename, :string
t.column :thumbnail, :string
t.column :size, :integer
t.column :width, :integer
t.column :height, :integer
end
end
def self.down
drop_table :simple_cms_medias
end
end
|
There is one more migration file you should have. It's called change_items_data_colmn and it looks like this:
1
2
3
4
5
6
7
8
9
10
11
|
class ChangeItemsDataColumn < ActiveRecord::Migration
def self.up
change_column :simple_cms_items, :data, :text, :limit => 10000000
end
def self.down
change_column :simple_cms_items, :data, :text
end
end
|
This is a change to the simple_cms_items table data column. This allows you to store up to 10 megabytes of text instead of the 65 kilobytes it defaulted to.
Remember to rake your tables into your databases once you have generated them.
Javascript and css Include Tags
You will need to make sure you have javascript include tags for your defaults and simple_cms and stylesheet link tags for the simple_cms and coderay stylesheets. Your app/views/layouts/application.rhtml should look something like this:
1
2
3
4
5
6
7
8
9
10
11
|
<html>
<head>
<%= javascript_include_tag :defaults, "simple_cms" %>
<%= stylesheet_link_tag "simple_cms", "coderay" %>
</head>
<body>
<%= yield %>
</body>
</html>
|
In Your View
Having the simple_cms plugin show up is really pretty simple. Anywhere you want to have the simple_cms to show up you put one line as simple as this:
1
2
3
|
<%= render :simpleCMS => "YourLabel", :admin => true %>
|
Here is another example with more options:
1
2
3
4
5
6
|
<%= render :simpleCMS => "label", :admin => true,
:user => "UserName",
:prefix => "/whatever/your/prefix/is",
:reusable => true %>
|
- :simpleCMS takes a label. Changing this label means losing all your current content and creating a new one. However, you can always change it back.
- :admin takes true or false. The default is false. If you pass true then when you run your mouse over the content a blue highlight box will appear and you will be able to click on the box and edit the content. If you pass false then you will only be able to see the content but not edit any of it.
- :user is optional and it takes any string you pass it.
- :prefix is optional. This is where you pass your prefix if you have one.
- :reusable takes true or false. Default is false. Set this true if you want to use this same content on multiple pages. The label must be the same on all pages you are using this content. *NOTE* you will lose all current data for this content if you change this as it gives the content a different id and changes the params of how it is called.