Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
fixed a bug in the page metadata stuff I did
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Nov 14, 2008
1 parent a5d8585 commit 43a12b0
Show file tree
Hide file tree
Showing 16 changed files with 416 additions and 340 deletions.
345 changes: 10 additions & 335 deletions COPYING

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README
Expand Up @@ -6,7 +6,7 @@ out of the box than any other Rails CMS we’re aware of.

By combining the CMSes of Isshen Solutions and Isotope 11, we plan to create
a best-of-breed technology suitable for production use on a myriad of sites.
Ansuz will be licensed initially via GPLv2.
Ansuz is licensed via the BSD license.

== Gem Dependencies
- mislav-will_paginate
Expand All @@ -28,7 +28,7 @@ Ansuz will be licensed initially via GPLv2.

NOTE: SQLite has problems with ansuz, please don't use it for now.

== This software is GPLv2
== This software is BSD licensed

Copyright (C) 2008 Josh Adams and James Cook, Isotope 11, Inc. and Adam Dill, Isshen Solutions, Inc.

Expand Down
3 changes: 3 additions & 0 deletions app/controllers/application.rb
@@ -1,8 +1,11 @@
class ApplicationController < ActionController::Base
include AuthenticatedSystem
include SiteSettingsHelper

before_filter :login_from_cookie, :setup_plugin_nav, :set_layout_variables, :load_menu

helper :all, :testimonials, :site_settings

theme :get_theme_setting

def set_layout_variables
Expand Down
2 changes: 1 addition & 1 deletion app/models/page.rb
Expand Up @@ -168,7 +168,7 @@ def check_page_order
self.page_order = self.last_page + 1
end

def create_page_metadata
def ensure_page_metadata
unless self.page_metadata
self.page_metadata = PageMetadata.new
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/account/index.html.erb
@@ -1,4 +1,4 @@
<h1>Powered by Ansuz</h1>
Ansuz CMS is published under GPLV2<br/>
Ansuz CMS is published under the BSD license<br/>
Written using the Rails framework and various other components, copyright held by original authors.<br/>
Content of this website is held by content owners.
Content of this website is held by content owners.
1 change: 1 addition & 0 deletions config/initializers/mime_types.rb
Expand Up @@ -3,3 +3,4 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
Mime::Type.register_alias "text/html", :mobile
3 changes: 3 additions & 0 deletions public/stylesheets/admin_mobilewebkit.css
@@ -0,0 +1,3 @@
body{
background-color: red;
}
95 changes: 95 additions & 0 deletions vendor/plugins/mobile-fu/CHANGELOG
@@ -0,0 +1,95 @@
commit 0aac5bd7f0d2f71e6af7b144a04a18dad9f5aca5
Author: Brendan G. Lim <brendan@intridea.com>
Date: Wed Sep 10 12:50:50 2008 -0400

Styling overrides for iPods

commit f30c97c794ba74e737856aa9226328469c8395b6
Author: Brendan G. Lim <brendan@intridea.com>
Date: Mon Sep 8 00:07:27 2008 -0400

Adding in some comments to the latest changes

commit 78dae861e46d383356d7e4d6dfdaefbf60072e27
Author: Brendan G. Lim <brendan@intridea.com>
Date: Mon Sep 8 00:06:16 2008 -0400

Updating README

commit 1a66ccd2142e387f6d3138acb688a58df4687fcd
Author: Brendan G. Lim <brendan@intridea.com>
Date: Mon Sep 8 00:05:48 2008 -0400

Adding in a helper method to check for a specific mobile device and adding in 'ipod' to the list of mobile user agents

commit cbb26fff3287e16a757ee2aed2dcc8e98cbfb369
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Aug 22 22:16:19 2008 -0400

Updating the CHANGELOG

commit ee49945b593b1c55bf546da1d595a0941d071f94
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Aug 22 22:16:00 2008 -0400

Updating README

commit 02c12a8563466f7cef6aba8e53915dc2efec908c
Author: Brendan G. Lim <brendan@intridea.com>
Date: Mon Aug 18 16:08:51 2008 -0400

Adding in support for Android

commit 2dffa5958905c0419288d03a0650127a0734b41a
Author: Brendan G. Lim <brendan@intridea.com>
Date: Sat Jul 26 14:08:56 2008 -0400

Adding in other phone user agents, including some Japanese and French manufacturers

commit e8f9f1a9c2e668d639690f4f1beb4f701f742cfa
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 11:15:52 2008 -0400

Adding in CHANGELOG

commit a3122b40c0c722b2942e9cb5341614d0e0d834a5
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 11:14:35 2008 -0400

Changes to README

commit 64a24e36b6a770757963eb2d961262fb8a14ec1b
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 11:10:40 2008 -0400

Quick fix

commit 116fa5b7c1168471cf56cb9961b98f0b73fc3308
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 10:04:41 2008 -0400

Fixed issue with mobile view session variable getting set incorrectly, when forcing mobile format

commit d172665c9d0458801fd672076e269a3c0ee9d80d
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 01:04:19 2008 -0400

Adding in more MIT license goodness

commit a6c947d684d2d9abdbe354dc1ea757f23cd5a633
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 01:00:55 2008 -0400

Change to the README

commit dad4f4db1f3cb816283069a91c01982c953ff8a5
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 01:00:16 2008 -0400

Change to the README

commit c5ec9de6ef19e48a66917d8f6f3a59771295765b
Author: Brendan G. Lim <brendan@intridea.com>
Date: Fri Jul 18 00:59:36 2008 -0400

Releasing Mobile Fu to the world
20 changes: 20 additions & 0 deletions vendor/plugins/mobile-fu/MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2008 Brendan G. Lim, Intridea, Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
81 changes: 81 additions & 0 deletions vendor/plugins/mobile-fu/README.rdoc
@@ -0,0 +1,81 @@
= Mobile Fu

Want to automatically detect mobile devices that access your Rails application?
Mobile Fu allows you to do just that. People can access your site from a Palm,
Blackberry, iPhone, Nokia, etc. and it will automatically adjust the format of
the request from :html to :mobile.

== Usage

Add this this one line to the controller.

class ApplicationController < ActionController::Base
has_mobile_fu
end

Once this is in place, any request that comes from a mobile device will be be
set as :mobile format. It is up to you to determine how you want to handle
these requests. It is also up to you to create the .mobile.erb versions of
your views that are to be requested.

Then add the line below to config/initializers/mime_types.rb

Mime::Type.register_alias "text/html", :mobile

I recommend that you setup a before_filter that will redirect to a specific page
depending on whether or not it is a mobile request. How can you check this?

is_mobile_device? # => Returns true or false depending on the device

You can also determine which format is currently set in by calling the following:

is_mobile_view? # => Returns true or false depending on current req. format

Also, if you want the ability to allow a user to switch between 'mobile' and
'standard' format (:html), you can just adjust the mobile_view session variable
in a custom controller action.

session[:mobile_view] # => Set to true if request format is :mobile and false
if set to :html

So, different devices need different styling. Don't worry, we've got this
baked in to Mobile Fu.

If you are including a css or sass file via stylesheet_link_tag, all you have
to do is add _device to the name of one of your files to override your styling
for a certain device. The stylesheet that is loaded is dependant on which device
is making the request.

e.g., Accessing a page from a Blackberry.

... stylesheet_link_tag 'mobile.css' ...

This loads mobile.css, and mobile_blackberry.css if the file exists.

Supported stylesheet override device extensions at the moment are:

blackberry
iphone
mobileexplorer
nokia
palm

The stylesheet awesomeness was derived from Michael Bleigh's browserized styles:
http://www.intridea.com/2007/12/9/announcing-browserized-styles

Inspiration for Mobile Fu came from Noel Rappin's rails_iui:
http://blogs.pathf.com/agileajax/2008/05/rails-developme.html

Hopefully this should help you create some awesome mobile applications.

== Testing Mobile Interface

If you want to force the mobile interface for testing, you can either use a
mobile device emulator, or you can pass 'true' to has_mobile_fu.

class ApplicationController < ActionController::Base
has_mobile_fu(true)
end


Copyright (c) 2008 Brendan G. Lim, Intridea, Inc., released under the MIT license
22 changes: 22 additions & 0 deletions vendor/plugins/mobile-fu/Rakefile
@@ -0,0 +1,22 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the sms_fu plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the sms_fu plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'SmsFu'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
5 changes: 5 additions & 0 deletions vendor/plugins/mobile-fu/init.rb
@@ -0,0 +1,5 @@
require File.dirname(__FILE__) + '/lib/mobilized_styles'
require File.dirname(__FILE__) + '/lib/mobile_fu'

ActionView::Base.send(:include, MobilizedStyles)
ActionView::Base.send(:alias_method_chain, :stylesheet_link_tag, :mobilization)
Empty file.
105 changes: 105 additions & 0 deletions vendor/plugins/mobile-fu/lib/mobile_fu.rb
@@ -0,0 +1,105 @@
module ActionController
module MobileFu

# These are various strings that can be found in mobile devices. Please feel free
# to add on to this list.


MOBILE_USER_AGENTS = 'palm|palmos|palmsource|iphone|blackberry|nokia|phone|midp|mobi|pda|' +
'wap|java|nokia|hand|symbian|chtml|wml|ericsson|lg|audiovox|motorola|' +
'samsung|sanyo|sharp|telit|tsm|mobile|mini|windows ce|smartphone|' +
'240x320|320x320|mobileexplorer|j2me|sgh|portable|sprint|vodafone|' +
'docomo|kddi|softbank|pdxgw|j-phone|astel|minimo|plucker|netfront|' +
'xiino|mot-v|mot-e|portalmmm|sagem|sie-s|sie-m|android|ipod'

def self.included(base)
base.extend(ClassMethods)
end

module ClassMethods

# Add this to one of your controllers to use MobileFu.
#
# class ApplicationController < ActionController::Base
# has_mobile_fu
# end
#
# You can also force mobile mode by passing in 'true'
#
# class ApplicationController < ActionController::Base
# has_mobile_fu(true)
# end

def has_mobile_fu(test_mode = false)
include ActionController::MobileFu::InstanceMethods

if test_mode
before_filter :force_mobile_format
else
before_filter :set_mobile_format
end

helper_method :is_mobile_device?
helper_method :in_mobile_view?
helper_method :is_device?
end

def is_mobile_device?
@@is_mobile_device
end

def in_mobile_view?
@@in_mobile_view
end

def is_device?(type)
@@is_device
end
end

module InstanceMethods

# Forces the request format to be :mobile

def force_mobile_format
request.format = :mobile
session[:mobile_view] = true if session[:mobile_view].nil?
end

# Determines the request format based on whether the device is mobile or if
# the user has opted to use either the 'Standard' view or 'Mobile' view.

def set_mobile_format
if is_mobile_device?
request.format = session[:mobile_view] == false ? :html : :mobile
session[:mobile_view] = true if session[:mobile_view].nil?
end
end

# Returns either true or false depending on whether or not the format of the
# request is either :mobile or not.

def in_mobile_view?
request.format.to_sym == :mobile
end

# Returns either true or false depending on whether or not the user agent of
# the device making the request is matched to a device in our regex.

def is_mobile_device?
request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::MOBILE_USER_AGENTS)
end

# Can check for a specific user agent
# e.g., is_device?('iphone') or is_device?('mobileexplorer')

def is_device?(type)
request.user_agent.to_s.downcase.include?(type.to_s.downcase)
end
end

end

end

ActionController::Base.send(:include, ActionController::MobileFu)

0 comments on commit 43a12b0

Please sign in to comment.