repo
string | commit
string | message
string | diff
string |
---|---|---|---|
infonium/scriptty
|
64a23824098e222b60d5e95b0796d99b2f39639e
|
Rakefile: Add Jeweler::GemCutterTasks
|
diff --git a/Rakefile b/Rakefile
index 4cc8949..4b14719 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,43 +1,44 @@
begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "scriptty"
gemspec.summary = "write expect-like script to control full-screen terminal-based applications"
gemspec.description = <<EOF
ScripTTY is a JRuby application and library that lets you control full-screen
terminal applications using an expect-like scripting language and a full-screen
matching engine.
EOF
gemspec.platform = "java"
gemspec.email = "[email protected]"
gemspec.homepage = "http://github.com/infonium/scriptty"
gemspec.authors = ["Dwayne Litzenberger"]
gemspec.add_dependency "treetop"
gemspec.add_dependency "multibyte"
end
+ Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end
require 'rake/rdoctask'
Rake::RDocTask.new do |t|
t.rdoc_files = Dir.glob(%w( README* COPYING* lib/**/*.rb *.rdoc )).uniq
t.main = "README.rdoc"
t.title = "ScripTTY - RDoc Documentation"
t.options = %w( --charset -UTF-8 --line-numbers )
end
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.pattern = 'test/**/*_test.rb'
end
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.pattern = 'test/**/*_test.rb'
t.rcov_opts = ['--text-report', '--exclude', 'gems,rcov,jruby.*,\(eval\)']
end
rescue LoadError
$stderr.puts "warning: rcov not installed; coverage testing not available."
end
|
infonium/scriptty
|
3c8836a186a36f12ed61d17891acaa0c83222ce5
|
ScreenPattern::Parser - Fix off-by-one error when specifying fields explicitly
|
diff --git a/lib/scriptty/screen_pattern/parser.rb b/lib/scriptty/screen_pattern/parser.rb
index 2eef1f6..878f2bf 100644
--- a/lib/scriptty/screen_pattern/parser.rb
+++ b/lib/scriptty/screen_pattern/parser.rb
@@ -1,555 +1,558 @@
# = Parser for screen pattern files
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'multibyte'
require 'iconv'
require 'strscan'
require 'scriptty/screen_pattern'
module ScripTTY
class ScreenPattern # reopen
# Parser for screen pattern files
#
# Parses a file containing screen patterns, yielding hashes.
class Parser
# NOTE: Ruby Regexp matching depends on the value of $KCODE, which gets
# changed by the 'multibyte' library (and Rails) from the default of "NONE" to "UTF8".
# The regexps here are designed to work exclusively with individual BYTES
# in UTF-8 strings, so we need to use the //n flag in all regexps here so
# that $KCODE is ignored.
# NOTE: The //n flag is not preserved by Regexp#to_s; you need the //n
# flag on the regexp object that is actually being matched.
COMMENT = /\s*#.*$/no
OPTIONAL_COMMENT = /#{COMMENT}|\s*$/no
IDENTIFIER = /[a-zA-Z0-9_]+/n
NIL = /nil/n
RECTANGLE = /\(\s*\d+\s*,\s*\d+\s*\)\s*-\s*\(\s*\d+\s*,\s*\d+\s*\)/n
STR_UNESCAPED = /[^"\\\t\r\n]/n
STR_OCTAL = /\\[0-7]{3}/n
STR_HEX = /\\x[0-9A-Fa-f]{2}/n
STR_SINGLE = /\\[enrt\\]|\\[^a-zA-Z0-9]/n
STRING = /"(?:#{STR_UNESCAPED}|#{STR_OCTAL}|#{STR_HEX}|#{STR_SINGLE})*"/no
INTEGER = /-?\d+/no
TWO_INTEGER_TUPLE = /\(\s*#{INTEGER}\s*,\s*#{INTEGER}\s*\)/no
TUPLE_ELEMENT = /#{INTEGER}|#{STRING}|#{NIL}|#{TWO_INTEGER_TUPLE}/no # XXX HACK: We actually want nested tuples, but we can't use regexp matching for that
TUPLE = /\(\s*#{TUPLE_ELEMENT}(?:\s*,\s*#{TUPLE_ELEMENT})*\s*\)/no
HEREDOCSTART = /<<#{IDENTIFIER}/no
SCREENNAME_LINE = /^\[(#{IDENTIFIER})\]\s*$/no
BLANK_LINE = /^\s*$/no
COMMENT_LINE = /^#{OPTIONAL_COMMENT}$/no
SINGLE_CHAR_PROPERTIES = %w( char_cursor char_ignore char_field )
TWO_TUPLE_PROPERTIES = %w( position size cursor_pos )
RECOGNIZED_PROPERTIES = SINGLE_CHAR_PROPERTIES + TWO_TUPLE_PROPERTIES + %w( rectangle fields text )
class <<self
def parse(s, &block)
new(s, &block).parse
nil
end
protected :new # Users should not instantiate this object directly
end
def initialize(s, &block)
raise ArgumentError.new("no block given") unless block
@block = block
@lines = preprocess(s).split("\n").map{|line| "#{line}\n"}
@line = nil
@lineno = 0
@state = :start
end
def parse
until @lines.empty?
@line = @lines.shift
@lineno += 1
send("handle_#{@state}_state")
end
handle_eof
end
private
# Top level of the configuration file
def handle_start_state
return if @line =~ BLANK_LINE
return if @line =~ COMMENT_LINE
@screen_name = nil
if @line =~ SCREENNAME_LINE # start of screen "[screen_name]"
@screen_name = $1
@screen_properties = {}
@state = :screen
return
end
parse_fail("expected [identifier]")
end
def handle_screen_state
return if @line =~ BLANK_LINE
return if @line =~ COMMENT_LINE
if @line =~ SCREENNAME_LINE
handle_done_screen
return handle_start_state
end
if @line =~ /^(#{IDENTIFIER})\s*:\s*(?:(#{STRING})|(#{RECTANGLE})|(#{HEREDOCSTART}|(#{TUPLE})))#{OPTIONAL_COMMENT}$/no
k, v_str, v_rect, v_heredoc, v_tuple = [$1, parse_string($2), parse_rectangle($3), parse_heredocstart($4), parse_tuple($5)]
if v_str
set_screen_property(k, v_str)
elsif v_rect
set_screen_property(k, v_rect)
elsif v_tuple
set_screen_property(k, v_tuple)
elsif v_heredoc
@heredoc = {
:propname => k,
:delimiter => v_heredoc,
:content => "",
:lineno => @lineno,
}
@state = :heredoc
else
raise "BUG"
end
else
parse_fail("expected: key:value or [identifier]")
end
end
def handle_eof
if @state == :start
# Do nothing
elsif @state == :screen
handle_done_screen
elsif @state == :heredoc
parse_fail("expected: #{@heredoc[:delimiter].inspect}, got EOF")
else
raise "BUG: unhandled EOF on state #{@state}"
end
end
def handle_heredoc_state
if @line =~ /^#{Regexp.escape(@heredoc[:delimiter])}\s*$/n
# End of here-document
set_screen_property(@heredoc[:propname], @heredoc[:content])
@heredoc = nil
@state = :screen
else
@heredoc[:content] << @line
end
end
def handle_done_screen
# Remove stuff that's irrelevant once the screen is parsed
@screen_properties.delete("char_field")
@screen_properties.delete("char_cursor")
@screen_properties.delete("char_ignore")
# Invoke the passed-in block with the parsed screen information
@block.call({ :name => @screen_name, :properties => @screen_properties })
# Reset to the initial state
@screen_name = @screen_properties = nil
@state = :start
end
def validate_single_char_property(k, v)
c = v.chars.to_a # Split field into array of single-character (but possibly multi-byte) strings
unless c.length == 1
parse_fail("#{k} must be a single character or Unicode code point", property_lineno)
end
end
def validate_tuple_property(k, v, length=2)
parse_fail("#{k} must be a #{length}-tuple", property_lineno) unless v.length == length
parse_fail("#{k} must contain positive integers", property_lineno) unless v[0] >=0 and v[1] >= 0
end
def set_screen_text(k, v, lineno=nil)
lineno ||= property_lineno
text = v.split("\n").map{|line| line.rstrip} # Split on newlines and strip trailing whitespace
# Get the implicit size of the screen from the text
parse_fail("#{k} must be surrounded by identical +-----+ lines", lineno) unless text[0] =~ /^\+(-+)\+$/
width = $1.length
height = text.length-2
parse_fail("#{k} must be surrounded by identical +-----+ lines", lineno + text.length) unless text[-1] == text[0] # TODO - test if this is the correct offset
text = text[1..-2] # strip top and bottom +------+ lines
lineno += 1 # Increment line number to compensate
# If there is an explicitly-specified size of the screen, compare against it.
# If there is no explicitly-specified size of the screen, use the implicit size.
explicit_height, explicit_width = @screen_properties['size']
explicit_height ||= height ; explicit_width ||= width # Default to the implicit size
if (explicit_height != height) or (explicit_width != width)
parse_fail("#{k} dimensions (#{height}x#{width}) conflict with explicit size (#{explicit_height}x#{explicit_width})", lineno)
else
set_screen_property("size", [height, width]) # in case it wasn't set explicitly
end
match_list = set_properties_from_grid(text,
:property_name => k,
:start_lineno => lineno+1,
:width => width,
:char_cursor => @screen_properties['char_cursor'],
:char_field => @screen_properties['char_field'],
:char_ignore => @screen_properties['char_ignore'])
if match_list and !match_list.empty?
@screen_properties['matches'] = match_list # XXX TODO - This will probably need to change
end
end
# If no position has been specified for this pattern, default to the top-left corner of the window.
def ensure_position
set_screen_property('position', [0,0]) unless @screen_properties['position']
end
# Convert a relative [row,column] or [row, col1..col2] into an absolute position or range.
def abs_pos(relative_pos)
screen_pos = @screen_properties['position']
if relative_pos[1].is_a?(Range)
[relative_pos[0]+screen_pos[0], relative_pos[1].first+screen_pos[1]..relative_pos[1].last+screen_pos[1]]
else
[relative_pos[0]+screen_pos[0], relative_pos[1]+screen_pos[1]]
end
end
# Walk through all the characters in the pattern, building up the
# pattern-matching data structures.
def set_properties_from_grid(lines, options={})
# Get options
height = lines.length
k = options[:property_name]
width = options[:width]
start_lineno = options[:start_lineno] || 1
char_cursor = options[:char_cursor]
char_field = options[:char_field]
char_ignore = options[:char_ignore]
# Convert each row into an array of single-character (possibly multi-byte) strings
lines_chars = lines.map{|line| line.chars.to_a}
# Each row consists of a grid bordered by vertical bars,
# followed by field names, e.g.:
# |.......| ("foo", "bar")
# Separate the grid from the field names
grid = []
row_field_names = []
(0..height-1).each do |row|
start_border = lines_chars[row][0]
end_border = lines_chars[row][width+1]
parse_fail("column 1: expected '|', got #{start_border.inspect}", start_lineno + row) unless start_border == "|"
parse_fail("column #{width+2}: expected '|', got #{end_border.inspect}", start_lineno + row) unless end_border == "|"
grid << lines_chars[row][1..width]
row_field_names << (parse_string_or_null_tuple(lines_chars[row][width+2..-1].join, start_lineno + row, width+3) || [])
end
match_positions = []
field_positions = []
cursor_pos = nil
(0..height-1).each do |row|
(0..width-1).each do |column|
pos = [row, column]
c = grid[row][column]
if c.nil? or c == char_ignore
# do nothing; ignore this character cell
elsif c == char_field
field_positions << pos
elsif c == char_cursor
parse_fail("column #{column+2}: multiple cursors", start_lineno + row) if cursor_pos
cursor_pos = pos
else
match_positions << pos
end
end
end
match_ranges_by_row = consolidate_positions(match_positions)
field_ranges_by_row = consolidate_positions(field_positions)
# Set the cursor position
set_screen_property('cursor_pos', cursor_pos, start_lineno + cursor_pos[0]) if cursor_pos
# Add fields to the screen. Complain if there's a mismatch between
# the number of fields found and the number identified.
(0..height-1).each do |row|
col_ranges = field_ranges_by_row[row] || []
unless row_field_names[row].length == col_ranges.length
parse_fail("field count mismatch: #{col_ranges.length} fields found, #{row_field_names[row].length} fields named or ignored", start_lineno + row)
end
row_field_names[row].zip(col_ranges) do |field_name, col_range|
next unless field_name # skip nil field names
add_field_to_screen(field_name, abs_pos([row, col_range]), start_lineno + row)
end
end
# Return the match list
# i.e. a list of [[row, start_col], string]
match_list = []
match_ranges_by_row.keys.sort.each do |row|
col_ranges = match_ranges_by_row[row]
col_ranges.each do |col_range|
s = grid[row][col_range].join
# Ensure that all remaining characters are printable ASCII. We
# don't support Unicode matching right now. (But we can probably
# just remove this check when adding support later.)
if (c = (s =~ /([^\x20-\x7e])/u))
parse_fail("column #{c+2}: non-ASCII-printable character #{$1.inspect}", start_lineno + row)
end
match_list << [abs_pos([row, col_range.first]), s]
end
end
match_list
end
# Consolidate adjacent positions and group them by row
#
# Example input:
# [[0,0], [0,1], [0,2], [1,1], [1,2], [1,4]]
# Example output:
# {0: [0..2], 1: [1..2, 4..4]]
def consolidate_positions(positions)
results = []
positions.each do |row, col|
if results[-1] and results[-1][0] == row and results[-1][1].last == col-1
results[-1][1] = results[-1][1].first..col
else
results << [row, col..col]
end
end
# Collect ranges by row
results_by_row = {}
results.each do |row, col_range|
results_by_row[row] ||= []
results_by_row[row] << col_range
end
results_by_row
end
# Return the line number of the current property.
#
# This will be either @lineno, or @heredoc[:lineno] (if the latter is present)
def property_lineno
@heredoc ? @heredoc[:lineno] : @lineno
end
# Add a field to the 'fields' property.
#
# Raise an exception if the field already exists.
def add_field_to_screen(name, row_and_col_range, lineno=nil)
lineno ||= property_lineno
row, col_range = row_and_col_range
@screen_properties['fields'] ||= {}
if @screen_properties['fields'].include?(name) and @screen_properties['fields'][name] != [row, col_range]
parse_fail("field #{format_field(name, row, col_range)} conflicts with previous definition #{format_field(name, *@screen_properties['fields'][name])}", lineno)
end
@screen_properties['fields'][name] = [row, col_range]
nil
end
def set_screen_property(k,v, lineno=nil)
lineno ||= property_lineno
parse_fail("Unrecognized property name #{k}", lineno) unless RECOGNIZED_PROPERTIES.include?(k)
validate_single_char_property(k, v) if SINGLE_CHAR_PROPERTIES.include?(k)
validate_tuple_property(k, v, 2) if TWO_TUPLE_PROPERTIES.include?(k)
if k == "rectangle"
set_screen_property("position", v[0,2], lineno)
set_screen_property("size", [v[2]-v[0]+1, v[3]-v[1]+1], lineno)
elsif k == "text"
ensure_position # "position", if set, must be set before this field is set
set_screen_text(k,v, lineno)
elsif k == "fields"
ensure_position # "position", if set, must be set before this field is set
v.split("\n", -1).each_with_index do |raw_tuple, i|
next if raw_tuple.nil? or raw_tuple.empty?
t = parse_tuple(raw_tuple.strip, lineno+i)
field_name, rel_pos, length = t
unless (field_name.is_a?(String) and rel_pos.is_a?(Array) and
rel_pos[0].is_a?(Integer) and rel_pos[1].is_a?(Integer) and length.is_a?(Integer))
parse_fail("incorrect field format: should be (name, (row, col), length)", lineno+i)
end
- rel_range = [rel_pos[0], rel_pos[1]..rel_pos[1]+length]
+ unless length > 0
+ parse_fail("field length must be positive", lineno+i)
+ end
+ rel_range = [rel_pos[0], rel_pos[1]..rel_pos[1]+length-1]
add_field_to_screen(field_name, abs_pos(rel_range), lineno+i)
end
else
v = abs_pos(v) if k == "cursor_pos"
# Don't allow setting a screen property more than once to different values.
old_value = @screen_properties[k]
unless old_value.nil? or old_value == v
if k == "position"
extra_note = " NOTE: 'position' should occur before other properties in the screen definition"
else
extra_note = ""
end
parse_fail("property #{k} value #{v.inspect} conflicts with already-set value #{old_value.inspect}#{extra_note}", lineno)
end
@screen_properties[k] = v
end
end
def parse_string(str, lineno=nil)
return nil unless str
retval = []
s = StringScanner.new(str)
unless s.scan /"/n
parse_fail("unable to parse string #{str.inspect}", lineno)
end
until s.eos?
if (m = s.scan STR_UNESCAPED)
retval << m
elsif (m = s.scan STR_OCTAL)
retval << [m[1..-1].to_i(8)].pack("C*")
elsif (m = s.scan STR_HEX)
retval << [m[2..-1].to_i(16)].pack("C*")
elsif (m = s.scan STR_SINGLE)
c = m[1..-1]
retval << case c
when 'e'
"\e"
when 'n'
"\n"
when 'r'
"\r"
when 't'
"\t"
when /[^a-zA-Z]/n
c
else
raise "BUG"
end
elsif (m = s.scan /"/) # End of string
parse_fail("unable to parse string #{str.inspect}", lineno) unless s.eos?
else
parse_fail("unable to parse string #{str.inspect}", lineno)
end
end
retval.join
end
# Parse (row1,col1)-(row2,col2) into [row1, col1, row2, col2]
def parse_rectangle(str)
return nil unless str
str.split(/[(,)\-\s]+/n, -1)[1..-2].map{|n| n.to_i}
end
def parse_heredocstart(str)
return nil unless str
str[2..-1]
end
# Parse (a, b, ...) into [a, b, ...]
def parse_tuple(str, line=nil, column=nil)
return nil unless str
column ||= 1
retval = []
s = StringScanner.new(str)
# Leading parenthesis
done = false
expect_comma = false
if s.scan /\s*\(/n
# start of tuple
elsif s.scan COMMENT_LINE
# Comment or blank line
return nil
else
parse_fail("column #{column+s.pos}: expected '(', got #{s.rest.chars.to_a[0].inspect}", line)
end
until s.eos?
if s.scan /\)/n # final parenthesis
done = true
break
end
next if s.scan /\s+/n # strip whitespace
if expect_comma
if s.scan /,/n
expect_comma = false
else
parse_fail("column #{column+s.pos}: expected ',', got #{s.rest.chars.to_a[0].inspect}", line)
end
else
if (m = s.scan STRING)
retval << parse_string(m)
elsif (m = s.scan INTEGER)
retval << m.to_i
elsif (m = s.scan NIL)
retval << nil
elsif (m = s.scan TWO_INTEGER_TUPLE)
retval << parse_rectangle(m) # parse_rectangle is dumb, so it will work here
else
parse_fail("column #{column+s.pos}: expected STRING, INTEGER, TWO_INTEGER_TUPLE, or NIL, got #{s.rest.chars.to_a[0].inspect}", line)
end
expect_comma = true
end
end
parse_fail("column #{column+s.pos}: tuple truncated", line) unless done
s.scan OPTIONAL_COMMENT
parse_fail("column #{column+s.pos}: extra junk found: #{s.rest.inspect}", line) unless s.eos?
retval
end
def parse_string_or_null_tuple(str, line=nil, column=nil)
t = parse_tuple(str, line, column)
return nil unless t
t.each_with_index do |v, i|
parse_fail("element #{i+1} of tuple is #{v.class.name}, but a string or null is required", line) unless v.nil? or v.is_a?(String)
end
t
end
# Return the display form of a field
def format_field(name, row, col_range)
"(#{name.inspect}, (#{row}, #{col_range.first}), #{col_range.count})"
end
def parse_fail(message=nil, line=nil)
line ||= @lineno
raise ArgumentError.new("error:line #{line}: #{message || 'parse error'}")
end
# Pre-process an input string.
#
# This converts the string into UTF-8, and replaces platform-specific newlines with "\n"
def preprocess(s, source_encoding=nil)
unless source_encoding
# Text files on Windows can be saved in a few different "Unicode"
# encodings. Decode the common ones into UTF-8.
source_encoding =
if s =~ /\A\xef\xbb\xbf/ # UTF-8+BOM
"UTF-8"
elsif s =~ /\A(\xfe\xff|\xff\xfe)/ # UTF-16 BOM (big or little endian)
"UTF-16"
else
"UTF-8" # assume UTF-8
end
end
# XXX TODO FIXME: There's a bug in JRuby's Iconv that prevents
# Iconv::IllegalSequence from being raised. Instead, the source string
# is returned. We should handle this somehow.
(s,) = Iconv.iconv("UTF-8", source_encoding, s)
s = s.gsub(/\xef\xbb\xbf/, "") # Strip the UTF-8 BYTE ORDER MARK (U+FEFF)
s = s.gsub(/\r\n/, "\n").gsub(/\r/, "\n") # Replace CR and CRLF with LF (Unix newline)
s = Multibyte::Chars.new(s).normalize(:c).to_a.join # Unicode Normalization Form C
end
end
end
end
diff --git a/test/screen_pattern/parser_test.rb b/test/screen_pattern/parser_test.rb
index af06452..bb7c9c4 100644
--- a/test/screen_pattern/parser_test.rb
+++ b/test/screen_pattern/parser_test.rb
@@ -1,241 +1,266 @@
# = Tests for ScripTTY::ScreenPattern::Parser
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require File.dirname(__FILE__) + "/../test_helper.rb"
require 'scriptty/screen_pattern/parser'
class ParserTest < Test::Unit::TestCase
# Test a simple pattern
def test_simple_pattern
result = []
ScripTTY::ScreenPattern::Parser.parse(read_file("simple_pattern.txt")) do |screen|
result << screen
end
offset = [3,4]
expected = [{
:name => "simple_pattern",
:properties => {
"position" => [0,0],
"size" => [4,5],
"cursor_pos" => [0,0],
"matches" => [
[[3,2], "X"],
],
"fields" => {
"field1" => [0,2..4],
"apple" => [1, 0..0],
"orange" => [1, 2..2],
"banana" => [1, 4..4],
"foo" => [2,0..1],
"bar" => [3,3..4],
},
},
}]
assert_equal add_pos(offset, expected), result
end
def test_explicit_cursor_position
result = []
ScripTTY::ScreenPattern::Parser.parse(read_file("explicit_cursor_pattern.txt")) do |screen|
result << screen
end
offset = [3,4]
expected = [{
:name => "simple_pattern",
:properties => {
"position" => [0,0],
"size" => [4,5],
"cursor_pos" => [1,1],
"fields" => {
"field1" => [0,2..4],
"apple" => [1, 0..0],
"orange" => [1, 2..2],
"banana" => [1, 4..4],
"foo" => [2,0..1],
"bar" => [3,3..4],
},
},
}]
assert_equal add_pos(offset, expected), result
end
+ def test_explicit_fields
+ result = []
+ ScripTTY::ScreenPattern::Parser.parse(read_file("explicit_fields.txt")) do |screen|
+ result << screen
+ end
+ offset = [3,4]
+ expected = [{
+ :name => "explicit_fields",
+ :properties => {
+ "position" => [0,0],
+ "size" => [4,5],
+ "cursor_pos" => [0,0],
+ "fields" => {
+ "field1" => [0,2..4],
+ "apple" => [1, 0..0],
+ "orange" => [1, 2..2],
+ "banana" => [1, 4..4],
+ "foo" => [2,0..1],
+ "bar" => [3,3..4],
+ },
+ },
+ }]
+ assert_equal add_pos(offset, expected), result
+ end
+
# Multiple patterns can be specified in a single file
def test_multiple_patterns
result = []
ScripTTY::ScreenPattern::Parser.parse(read_file("multiple_patterns.txt")) do |screen|
result << screen
end
expected = [
add_pos([3,4], {
:name => "simple_pattern_1",
:properties => { # NB: [3,4] added to these properties
"position" => [0,0],
"size" => [4,5],
"cursor_pos" => [0,0],
"fields" => {
"field1" => [0,2..4],
"apple" => [1, 0..0],
"orange" => [1, 2..2],
"banana" => [1, 4..4],
"foo" => [2,0..1],
"bar" => [3,3..4],
},
},
}),
{
:name => "simple_pattern_2",
:properties => {
"position" => [0,0],
"size" => [4,5],
"cursor_pos" => [0,0],
"matches" => [
[[0,1], ":"],
[[2,0], "Hello"],
[[3,0], "World"],
],
"fields" => {
"field1" => [0, 2..4],
},
},
},
{
:name => "simple_pattern_3",
:properties => {
"position" => [0,0],
"size" => [4,5],
"cursor_pos" => [0,0],
"matches" => [
[[0,1], ":"],
[[2,0], "Hello"],
[[3,0], "World"],
],
"fields" => {
"field1" => [0, 2..4],
},
},
},
]
assert_equal expected.length, result.length, "lengths do not match"
expected.zip(result).each do |e, r|
assert_equal e, r
end
end
# A here-document that's truncated should result in a parse error.
def test_truncated_heredoc
result = []
pattern = read_file("truncated_heredoc.txt")
e = nil
assert_raise(ArgumentError, "truncated here-document should result in parse error") do
begin
ScripTTY::ScreenPattern::Parser.parse(pattern) do |screen|
result << screen
end
rescue ArgumentError => e # save exception for assertion below
raise
end
end
assert_match /^error:line 12: expected: "END", got EOF/, e.message
end
# UTF-16 and UTF-8 should parse correctly
def test_unicode
expected = [
add_pos([3,4], {
:name => "unicode_pattern",
:properties => {
"position" => [0,0],
"size" => [4,5],
"cursor_pos" => [0,0],
"fields" => {
"field1" => [0,2..4],
"apple" => [1, 0..0],
"orange" => [1, 2..2],
"banana" => [1, 4..4],
"foo" => [2,0..1],
"bar" => [3,3..4],
},
},
}),
]
for filename in %w( utf16bebom_pattern.bin utf16lebom_pattern.bin utf8_pattern.bin utf8_unix_pattern.bin utf8bom_pattern.bin )
result = []
assert_nothing_raised("#{filename} should parse ok") do
ScripTTY::ScreenPattern::Parser.parse(read_file(filename)) do |screen|
result << screen
end
end
assert_equal expected, result, "#{filename} should parse correctly"
end
end
# Unicode NFC normalization should be performed. This avoids user confusion if they enter two different representations of the same character.
def test_nfd_to_nfc_normalization
expected = [{
:name => "test",
:properties => {
"position" => [0,0],
"size" => [1,2],
"cursor_pos" => [0,1],
}
}]
input = <<EOF
[test]
char_cursor: "c\xcc\xa7" # ASCII "c" followed by U+0327 COMBINING CEDILLA
char_ignore: "."
text: <<END
+--+
|.\xc3\xa7| # U+00E7 LATIN SMALL LETTER C WITH CEDILLA
+--+
END
EOF
result = []
ScripTTY::ScreenPattern::Parser.parse(input) do |screen|
result << screen
end
assert_equal expected, result, "NFC unicode normalization should work correctly"
end
private
def read_file(basename)
File.read(File.join(File.dirname(__FILE__), "parser_test", basename))
end
def add_pos(offset, arg)
if arg.is_a?(Array) and arg[0].is_a?(Integer) and arg[1].is_a?(Integer)
[offset[0]+arg[0], offset[1]+arg[1]]
elsif arg.is_a?(Array) and arg[0].is_a?(Integer) and arg[1].is_a?(Range)
[offset[0]+arg[0], offset[1]+arg[1].first..offset[1]+arg[1].last]
elsif arg.is_a?(Array)
arg.map{|a| add_pos(offset, a)}
elsif arg.is_a?(Hash)
retval = {}
arg.each_pair do |k,v|
if k == "size"
retval[k] = v
else
retval[k] = add_pos(offset, v)
end
end
retval
else
arg # raise ArgumentError.new("Don't know how to handle #{arg.inspect}")
end
end
end
diff --git a/test/screen_pattern/parser_test/explicit_fields.txt b/test/screen_pattern/parser_test/explicit_fields.txt
new file mode 100644
index 0000000..0617c5a
--- /dev/null
+++ b/test/screen_pattern/parser_test/explicit_fields.txt
@@ -0,0 +1,22 @@
+# Screen pattern with explicit fields
+[explicit_fields]
+position: (3,4)
+size: (4,5)
+char_cursor: "@"
+char_ignore: "."
+char_field: "#"
+fields: <<END
+ ("field1", (0,2), 3)
+ ("apple", (1,0), 1)
+ ("orange", (1,2), 1)
+ ("banana", (1,4), 1)
+ ("foo", (2,0), 2)
+END
+text: <<END
++-----+
+|@....|
+|.....|
+|.....|
+|...##| ("bar") # Mixing explicit and implicit fields is allowed.
++-----+
+END
|
infonium/scriptty
|
323d193661d570528023dbe63a9180c26aaeb8cd
|
ScripTTY::Expect - Screen matching support & related changes
|
diff --git a/lib/scriptty/expect.rb b/lib/scriptty/expect.rb
index 0b95bdd..143ace4 100644
--- a/lib/scriptty/expect.rb
+++ b/lib/scriptty/expect.rb
@@ -1,389 +1,392 @@
# = Expect object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/exception'
require 'scriptty/net/event_loop'
require 'scriptty/term'
require 'scriptty/screen_pattern'
require 'scriptty/util/transcript/writer'
require 'set'
module ScripTTY
class Expect
# Methods to export to Evaluator
- EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout, :load_screens ]
+ EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :match, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout, :load_screens ]
attr_reader :term # The terminal emulation object
+ attr_reader :match # The last non-background expect match. For a ScreenPattern match, this is a Hash of fields. For a String or Regexp match, this is a MatchData object.
+
attr_accessor :transcript_writer # Set this to an instance of ScripTTY::Util::Transcript::Writer
# Initialize the Expect object.
def initialize(options={})
@net = ScripTTY::Net::EventLoop.new
@suspended = false
@effective_patterns = nil
@term_name = nil
@effective_patterns = [] # Array of PatternHandle objects
@pattern_stack = []
@wait_finished = false
@evaluator = Evaluator.new(self)
@match_buffer = ""
@timeout = nil
@timeout_timer = nil
@transcript_writer = options[:transcript_writer]
@screen_patterns = {}
end
def set_timeout(seconds)
raise ArgumentError.new("argument to set_timeout must be Numeric or nil") unless seconds.is_a?(Numeric) or seconds.nil?
if seconds
@timeout = seconds.to_f
else
@timeout = nil
end
refresh_timeout
nil
end
# Load and evaluate a script from a file.
def eval_script_file(path)
eval_script_inline(File.read(path), path)
end
# Evaluate a script specified as a string.
def eval_script_inline(str, filename=nil, lineno=nil)
@evaluator.instance_eval(str, filename || "(inline)", lineno || 1)
end
# Initialize a terminal emulator.
#
# If a name is specified, use that terminal type. Otherwise, use the
# previous terminal type.
def init_term(name=nil)
@transcript_writer.info("Script executing command", "init_term", name || "") if @transcript_writer
name ||= @term_name
@term_name = name
raise ArgumentError.new("No previous terminal specified") unless name
without_timeout {
@term = ScripTTY::Term.new(name)
@term.on_unknown_sequence do |seq|
@transcript_writer.info("Unknown escape sequence", seq) if @transcript_writer
end
}
nil
end
# Connect to the specified address. Return true if the connection was
# successful. Otherwise, raise an exception.
def connect(remote_address)
@transcript_writer.info("Script executing command", "connect", *remote_address.map{|a| a.inspect}) if @transcript_writer
connected = false
connect_error = nil
@conn = @net.connect(remote_address) do |c|
c.on_connect { connected = true; handle_connect; @net.suspend }
c.on_connect_error { |e| connect_error = e; @net.suspend }
c.on_receive_bytes { |bytes| handle_receive_bytes(bytes) }
c.on_close { @conn = nil; handle_connection_close }
end
dispatch until connected or connect_error or @net.done?
if connect_error
transcribe_connect_error(connect_error)
raise ScripTTY::Exception::ConnectError.new(connect_error)
end
refresh_timeout
connected
end
# Add the specified pattern to the effective pattern list.
#
# Return the PatternHandle for the pattern.
#
# Options:
# [:continue]
# If true, matching this pattern will not cause the wait method to
# return.
def on(pattern, opts={}, &block)
case pattern
when String
@transcript_writer.info("Script executing command", "on", "String", pattern.inspect) if @transcript_writer
ph = PatternHandle.new(/#{Regexp.escape(pattern)}/n, block, opts[:background])
when Regexp
@transcript_writer.info("Script executing command", "on", "Regexp", pattern.inspect) if @transcript_writer
if pattern.kcode == "none"
ph = PatternHandle.new(pattern, block, opts[:background])
else
ph = PatternHandle.new(/#{pattern}/n, block, opts[:background])
end
when ScreenPattern
@transcript_writer.info("Script executing command", "on", "ScreenPattern", pattern.name, opts[:background] ? "BACKGROUND" : "") if @transcript_writer
- ph = PatternHandle(pattern, block, opts[:background])
+ ph = PatternHandle.new(pattern, block, opts[:background])
else
raise TypeError.new("Unsupported pattern type: #{pattern.class.inspect}")
end
@effective_patterns << ph
ph
end
# Sleep for the specified number of seconds
def sleep(seconds)
@transcript_writer.info("Script executing command", "sleep", seconds.inspect) if @transcript_writer
sleep_done = false
@net.timer(seconds) { sleep_done = true ; @net.suspend }
dispatch until sleep_done
refresh_timeout
nil
end
# Return the named ScreenPattern (or nil if no such pattern exists)
def screen(name)
@screen_patterns[name.to_sym]
end
# Load screens from the specified filenames
def load_screens(filenames_or_glob)
if filenames_or_glob.is_a?(String)
filenames = Dir.glob(filenames_or_glob)
elsif filenames_or_glob.is_a?(Array)
filenames = filenames_or_glob
else
raise ArgumentError.new("load_screens takes a string(glob) or an array, not #{filenames.class.name}")
end
filenames.each do |filename|
ScreenPattern.parse(File.read(filename)).each do |pattern|
@screen_patterns[pattern.name.to_sym] = pattern
end
end
nil
end
# Convenience function.
#
# == Examples
# # Wait for a single pattern to match.
# expect("login: ")
#
# # Wait for one of several patterns to match.
# expect {
# on("login successful") { ... }
# on("login incorrect") { ... }
# }
def expect(pattern=nil)
raise ArgumentError.new("no pattern and no block given") if !pattern and !block_given?
@transcript_writer.info("Script expect block BEGIN") if @transcript_writer and block_given?
push_patterns
begin
on(pattern) if pattern
yield if block_given?
wait
ensure
pop_patterns
@transcript_writer.info("Script expect block END") if @transcript_writer and block_given?
end
end
# Push a copy of the effective pattern list to an internal stack.
def push_patterns
@pattern_stack << @effective_patterns.dup
end
# Pop the effective pattern list from the stack.
def pop_patterns
raise ArgumentError.new("pattern stack empty") if @pattern_stack.empty?
@effective_patterns = @pattern_stack.pop
end
# Wait for an effective pattern to match.
#
# Clears the character-match buffer on return.
def wait
@transcript_writer.info("Script executing command", "wait") if @transcript_writer
check_expect_match unless @wait_finished
dispatch until @wait_finished
refresh_timeout
@wait_finished = false
nil
end
# Send bytes to the remote application.
#
# NOTE: This method returns immediately, even if not all the bytes are
# finished being sent. Remaining bytes will be sent during an expect,
# wait, or sleep call.
def send(bytes)
@transcript_writer.from_client(bytes) if @transcript_writer
@conn.write(bytes)
true
end
# Close the connection and exit.
def exit
@transcript_writer.info("Script executing command", "exit") if @transcript_writer
@net.exit
dispatch until @net.done?
@transcript_writer.close if @transcript_writer
end
private
# Kick the watchdog timer
def refresh_timeout
disable_timeout
enable_timeout
end
def without_timeout
raise ArgumentError.new("no block given") unless block_given?
disable_timeout
begin
yield
ensure
enable_timeout
end
end
# Disable timeout handling
def disable_timeout
if @timeout_timer
@timeout_timer.cancel
@timeout_timer = nil
end
nil
end
# Enable timeout handling (if @timeout is set)
def enable_timeout
if @timeout
@timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
end
nil
end
# Re-enter the dispatch loop
def dispatch
if @suspended
@suspended = @net.resume
else
@suspended = @net.main
end
end
def handle_connection_close # XXX - we should raise an error when disconnected prematurely
@transcript_writer.server_close("connection closed") if @transcript_writer
self.exit
end
def handle_connect
@transcript_writer.server_open(*@conn.remote_address) if @transcript_writer
init_term
end
def transcribe_connect_error(e)
if @transcript_writer
@transcript_writer.info("Connect error", e.class.name, e.to_s, e.backtrace.join("\n"))
# Write the backtrace out as separate records, for the convenience of people reading the logs without a parser.
e.backtrace.each do |line|
@transcript_writer.info("Connect error backtrace", line)
end
end
end
def handle_receive_bytes(bytes)
@transcript_writer.from_server(bytes) if @transcript_writer
@match_buffer << bytes
@term.feed_bytes(bytes)
check_expect_match
end
# Check for a match.
#
# If there is a (non-background) match, set @wait_finished and return true. Otherwise, return false.
def check_expect_match
found = true
while found
found = false
@effective_patterns.each { |ph|
case ph.pattern
when Regexp
m = ph.pattern.match(@match_buffer)
@match_buffer = @match_buffer[m.end(0)..-1] if m # truncate match buffer
when ScreenPattern
m = ph.pattern.match_term(@term)
@match_buffer = "" if m # truncate match buffer if a screen matches
else
raise "BUG: pattern is #{ph.pattern.inspect}"
end
next unless m
# Matched - Invoke the callback
ph.callback.call(m) if ph.callback
# Make the next wait() call return
unless ph.background?
+ @match = m
@wait_finished = true
@net.suspend
return true
else
found = true
end
}
end
false
end
class Evaluator
def initialize(expect_object)
@_expect_object = expect_object
end
# Define proxy methods
EXPORTED_METHODS.each do |m|
# We would use define_method, but JRuby 1.4 doesn't support defining
# a block that takes a block. http://jira.codehaus.org/browse/JRUBY-4180
class_eval("def #{m}(*args, &block) @_expect_object.__send__(#{m.inspect}, *args, &block); end")
end
end
class PatternHandle
attr_reader :pattern
attr_reader :callback
def initialize(pattern, callback, background)
@pattern = pattern
@callback = callback
@background = background
end
def background?
@background
end
end
class Match
attr_reader :pattern_handle
attr_reader :result
def initialize(pattern_handle, result)
@pattern_handle = pattern_handle
@result = result
end
end
end
end
diff --git a/lib/scriptty/screen_pattern.rb b/lib/scriptty/screen_pattern.rb
index c65a29b..aab09f6 100644
--- a/lib/scriptty/screen_pattern.rb
+++ b/lib/scriptty/screen_pattern.rb
@@ -1,102 +1,104 @@
# = Screen pattern object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
module ScripTTY
class ScreenPattern
class <<self
# Parse a pattern file and return an array of ScreenPattern objects
def parse(s)
retval = []
Parser.parse(s) do |spec|
retval << new(spec[:name], spec[:properties])
end
retval
end
def from_term(term, name=nil)
from_text(term.text, :name => name, :cursor_pos => term.cursor_pos)
end
def from_text(text, opts={})
text = text.split(/\r?\n/n) if text.is_a?(String)
name ||= opts[:name] || "untitled"
width = text.map{|line| line.chars.to_a.length}.max
height = text.length
properties = {}
properties['cursor_pos'] = opts[:cursor_pos]
properties['size'] = [height, width]
properties['matches'] = []
text.each_with_index{|line, i|
properties['matches'] << [[i, 0], line]
}
new(name, properties)
end
protected :new # Users should not instantiate this object directly
end
# The name given to this pattern
attr_accessor :name
# The [row, column] of the cursor position (or nil if unspecified)
attr_accessor :cursor_pos
def initialize(name, properties) # :nodoc:
@name = name
@position = properties["position"]
@size = properties["size"]
@cursor_pos = properties["cursor_pos"]
@field_ranges = properties["fields"] # Hash of "field_name" => [row, col1..col2] ranges
@matches = properties["matches"] # Array of [[row,col], string] records to match
end
def inspect
"#<#{self.class.name}:#{sprintf("0x%x", object_id)} name=#{@name}>"
end
# Match this pattern against a Term object. If the match succeeds, return
# the Hash of fields extracted from the screen. Otherwise, return nil.
def match_term(term)
return nil if @cursor_pos and @cursor_pos != term.cursor_pos
# XXX UNICODE
if @matches
text = term.text
@matches.each do |pos, str|
row, col = pos
- col_range = col..col + str.length
+ col_range = col..col+str.length-1
return nil unless text[row][col_range] == str
end
end
fields = {}
- @field_ranges.each_pair do |k, range|
- row, col_range = range
- fields[k] = text[row][col_range]
+ if @field_ranges
+ @field_ranges.each_pair do |k, range|
+ row, col_range = range
+ fields[k] = text[row][col_range]
+ end
end
fields
end
def generate(name=nil)
Generator.generate(name || "untitled", :cursor_pos => @cursor_pos, :matches => @matches, :fields => @field_ranges, :position => @position, :size => @size)
end
end
end
require 'scriptty/screen_pattern/parser'
require 'scriptty/screen_pattern/generator'
|
infonium/scriptty
|
36fa0374fcc86c7ccef68d68bd6f944bc7f6aa8e
|
ScripTTY::Expect - Make load_screens take a glob or an array of filenames
|
diff --git a/lib/scriptty/expect.rb b/lib/scriptty/expect.rb
index f8c1357..0b95bdd 100644
--- a/lib/scriptty/expect.rb
+++ b/lib/scriptty/expect.rb
@@ -1,382 +1,389 @@
# = Expect object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/exception'
require 'scriptty/net/event_loop'
require 'scriptty/term'
require 'scriptty/screen_pattern'
require 'scriptty/util/transcript/writer'
require 'set'
module ScripTTY
class Expect
# Methods to export to Evaluator
EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout, :load_screens ]
attr_reader :term # The terminal emulation object
attr_accessor :transcript_writer # Set this to an instance of ScripTTY::Util::Transcript::Writer
# Initialize the Expect object.
def initialize(options={})
@net = ScripTTY::Net::EventLoop.new
@suspended = false
@effective_patterns = nil
@term_name = nil
@effective_patterns = [] # Array of PatternHandle objects
@pattern_stack = []
@wait_finished = false
@evaluator = Evaluator.new(self)
@match_buffer = ""
@timeout = nil
@timeout_timer = nil
@transcript_writer = options[:transcript_writer]
@screen_patterns = {}
end
def set_timeout(seconds)
raise ArgumentError.new("argument to set_timeout must be Numeric or nil") unless seconds.is_a?(Numeric) or seconds.nil?
if seconds
@timeout = seconds.to_f
else
@timeout = nil
end
refresh_timeout
nil
end
# Load and evaluate a script from a file.
def eval_script_file(path)
eval_script_inline(File.read(path), path)
end
# Evaluate a script specified as a string.
def eval_script_inline(str, filename=nil, lineno=nil)
@evaluator.instance_eval(str, filename || "(inline)", lineno || 1)
end
# Initialize a terminal emulator.
#
# If a name is specified, use that terminal type. Otherwise, use the
# previous terminal type.
def init_term(name=nil)
@transcript_writer.info("Script executing command", "init_term", name || "") if @transcript_writer
name ||= @term_name
@term_name = name
raise ArgumentError.new("No previous terminal specified") unless name
without_timeout {
@term = ScripTTY::Term.new(name)
@term.on_unknown_sequence do |seq|
@transcript_writer.info("Unknown escape sequence", seq) if @transcript_writer
end
}
nil
end
# Connect to the specified address. Return true if the connection was
# successful. Otherwise, raise an exception.
def connect(remote_address)
@transcript_writer.info("Script executing command", "connect", *remote_address.map{|a| a.inspect}) if @transcript_writer
connected = false
connect_error = nil
@conn = @net.connect(remote_address) do |c|
c.on_connect { connected = true; handle_connect; @net.suspend }
c.on_connect_error { |e| connect_error = e; @net.suspend }
c.on_receive_bytes { |bytes| handle_receive_bytes(bytes) }
c.on_close { @conn = nil; handle_connection_close }
end
dispatch until connected or connect_error or @net.done?
if connect_error
transcribe_connect_error(connect_error)
raise ScripTTY::Exception::ConnectError.new(connect_error)
end
refresh_timeout
connected
end
# Add the specified pattern to the effective pattern list.
#
# Return the PatternHandle for the pattern.
#
# Options:
# [:continue]
# If true, matching this pattern will not cause the wait method to
# return.
def on(pattern, opts={}, &block)
case pattern
when String
@transcript_writer.info("Script executing command", "on", "String", pattern.inspect) if @transcript_writer
ph = PatternHandle.new(/#{Regexp.escape(pattern)}/n, block, opts[:background])
when Regexp
@transcript_writer.info("Script executing command", "on", "Regexp", pattern.inspect) if @transcript_writer
if pattern.kcode == "none"
ph = PatternHandle.new(pattern, block, opts[:background])
else
ph = PatternHandle.new(/#{pattern}/n, block, opts[:background])
end
when ScreenPattern
@transcript_writer.info("Script executing command", "on", "ScreenPattern", pattern.name, opts[:background] ? "BACKGROUND" : "") if @transcript_writer
ph = PatternHandle(pattern, block, opts[:background])
else
raise TypeError.new("Unsupported pattern type: #{pattern.class.inspect}")
end
@effective_patterns << ph
ph
end
# Sleep for the specified number of seconds
def sleep(seconds)
@transcript_writer.info("Script executing command", "sleep", seconds.inspect) if @transcript_writer
sleep_done = false
@net.timer(seconds) { sleep_done = true ; @net.suspend }
dispatch until sleep_done
refresh_timeout
nil
end
# Return the named ScreenPattern (or nil if no such pattern exists)
def screen(name)
@screen_patterns[name.to_sym]
end
# Load screens from the specified filenames
- def load_screens(filenames)
+ def load_screens(filenames_or_glob)
+ if filenames_or_glob.is_a?(String)
+ filenames = Dir.glob(filenames_or_glob)
+ elsif filenames_or_glob.is_a?(Array)
+ filenames = filenames_or_glob
+ else
+ raise ArgumentError.new("load_screens takes a string(glob) or an array, not #{filenames.class.name}")
+ end
filenames.each do |filename|
ScreenPattern.parse(File.read(filename)).each do |pattern|
@screen_patterns[pattern.name.to_sym] = pattern
end
end
nil
end
# Convenience function.
#
# == Examples
# # Wait for a single pattern to match.
# expect("login: ")
#
# # Wait for one of several patterns to match.
# expect {
# on("login successful") { ... }
# on("login incorrect") { ... }
# }
def expect(pattern=nil)
raise ArgumentError.new("no pattern and no block given") if !pattern and !block_given?
@transcript_writer.info("Script expect block BEGIN") if @transcript_writer and block_given?
push_patterns
begin
on(pattern) if pattern
yield if block_given?
wait
ensure
pop_patterns
@transcript_writer.info("Script expect block END") if @transcript_writer and block_given?
end
end
# Push a copy of the effective pattern list to an internal stack.
def push_patterns
@pattern_stack << @effective_patterns.dup
end
# Pop the effective pattern list from the stack.
def pop_patterns
raise ArgumentError.new("pattern stack empty") if @pattern_stack.empty?
@effective_patterns = @pattern_stack.pop
end
# Wait for an effective pattern to match.
#
# Clears the character-match buffer on return.
def wait
@transcript_writer.info("Script executing command", "wait") if @transcript_writer
check_expect_match unless @wait_finished
dispatch until @wait_finished
refresh_timeout
@wait_finished = false
nil
end
# Send bytes to the remote application.
#
# NOTE: This method returns immediately, even if not all the bytes are
# finished being sent. Remaining bytes will be sent during an expect,
# wait, or sleep call.
def send(bytes)
@transcript_writer.from_client(bytes) if @transcript_writer
@conn.write(bytes)
true
end
# Close the connection and exit.
def exit
@transcript_writer.info("Script executing command", "exit") if @transcript_writer
@net.exit
dispatch until @net.done?
@transcript_writer.close if @transcript_writer
end
private
# Kick the watchdog timer
def refresh_timeout
disable_timeout
enable_timeout
end
def without_timeout
raise ArgumentError.new("no block given") unless block_given?
disable_timeout
begin
yield
ensure
enable_timeout
end
end
# Disable timeout handling
def disable_timeout
if @timeout_timer
@timeout_timer.cancel
@timeout_timer = nil
end
nil
end
# Enable timeout handling (if @timeout is set)
def enable_timeout
if @timeout
@timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
end
nil
end
# Re-enter the dispatch loop
def dispatch
if @suspended
@suspended = @net.resume
else
@suspended = @net.main
end
end
def handle_connection_close # XXX - we should raise an error when disconnected prematurely
@transcript_writer.server_close("connection closed") if @transcript_writer
self.exit
end
def handle_connect
@transcript_writer.server_open(*@conn.remote_address) if @transcript_writer
init_term
end
def transcribe_connect_error(e)
if @transcript_writer
@transcript_writer.info("Connect error", e.class.name, e.to_s, e.backtrace.join("\n"))
# Write the backtrace out as separate records, for the convenience of people reading the logs without a parser.
e.backtrace.each do |line|
@transcript_writer.info("Connect error backtrace", line)
end
end
end
def handle_receive_bytes(bytes)
@transcript_writer.from_server(bytes) if @transcript_writer
@match_buffer << bytes
@term.feed_bytes(bytes)
check_expect_match
end
# Check for a match.
#
# If there is a (non-background) match, set @wait_finished and return true. Otherwise, return false.
def check_expect_match
found = true
while found
found = false
@effective_patterns.each { |ph|
case ph.pattern
when Regexp
m = ph.pattern.match(@match_buffer)
@match_buffer = @match_buffer[m.end(0)..-1] if m # truncate match buffer
when ScreenPattern
m = ph.pattern.match_term(@term)
@match_buffer = "" if m # truncate match buffer if a screen matches
else
raise "BUG: pattern is #{ph.pattern.inspect}"
end
next unless m
# Matched - Invoke the callback
ph.callback.call(m) if ph.callback
# Make the next wait() call return
unless ph.background?
@wait_finished = true
@net.suspend
return true
else
found = true
end
}
end
false
end
class Evaluator
def initialize(expect_object)
@_expect_object = expect_object
end
# Define proxy methods
EXPORTED_METHODS.each do |m|
# We would use define_method, but JRuby 1.4 doesn't support defining
# a block that takes a block. http://jira.codehaus.org/browse/JRUBY-4180
class_eval("def #{m}(*args, &block) @_expect_object.__send__(#{m.inspect}, *args, &block); end")
end
end
class PatternHandle
attr_reader :pattern
attr_reader :callback
def initialize(pattern, callback, background)
@pattern = pattern
@callback = callback
@background = background
end
def background?
@background
end
end
class Match
attr_reader :pattern_handle
attr_reader :result
def initialize(pattern_handle, result)
@pattern_handle = pattern_handle
@result = result
end
end
end
end
|
infonium/scriptty
|
26f6401ed41206605989e63c2b715d7e43158698
|
ScripTTY::Expect - Screen loading
|
diff --git a/lib/scriptty/expect.rb b/lib/scriptty/expect.rb
index 784dc15..f8c1357 100644
--- a/lib/scriptty/expect.rb
+++ b/lib/scriptty/expect.rb
@@ -1,372 +1,382 @@
# = Expect object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/exception'
require 'scriptty/net/event_loop'
require 'scriptty/term'
require 'scriptty/screen_pattern'
require 'scriptty/util/transcript/writer'
require 'set'
module ScripTTY
class Expect
# Methods to export to Evaluator
- EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout ]
+ EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout, :load_screens ]
attr_reader :term # The terminal emulation object
attr_accessor :transcript_writer # Set this to an instance of ScripTTY::Util::Transcript::Writer
# Initialize the Expect object.
def initialize(options={})
@net = ScripTTY::Net::EventLoop.new
@suspended = false
@effective_patterns = nil
@term_name = nil
@effective_patterns = [] # Array of PatternHandle objects
@pattern_stack = []
@wait_finished = false
@evaluator = Evaluator.new(self)
@match_buffer = ""
@timeout = nil
@timeout_timer = nil
@transcript_writer = options[:transcript_writer]
+ @screen_patterns = {}
end
def set_timeout(seconds)
raise ArgumentError.new("argument to set_timeout must be Numeric or nil") unless seconds.is_a?(Numeric) or seconds.nil?
if seconds
@timeout = seconds.to_f
else
@timeout = nil
end
refresh_timeout
nil
end
# Load and evaluate a script from a file.
def eval_script_file(path)
eval_script_inline(File.read(path), path)
end
# Evaluate a script specified as a string.
def eval_script_inline(str, filename=nil, lineno=nil)
@evaluator.instance_eval(str, filename || "(inline)", lineno || 1)
end
# Initialize a terminal emulator.
#
# If a name is specified, use that terminal type. Otherwise, use the
# previous terminal type.
def init_term(name=nil)
@transcript_writer.info("Script executing command", "init_term", name || "") if @transcript_writer
name ||= @term_name
@term_name = name
raise ArgumentError.new("No previous terminal specified") unless name
without_timeout {
@term = ScripTTY::Term.new(name)
@term.on_unknown_sequence do |seq|
@transcript_writer.info("Unknown escape sequence", seq) if @transcript_writer
end
}
nil
end
# Connect to the specified address. Return true if the connection was
# successful. Otherwise, raise an exception.
def connect(remote_address)
@transcript_writer.info("Script executing command", "connect", *remote_address.map{|a| a.inspect}) if @transcript_writer
connected = false
connect_error = nil
@conn = @net.connect(remote_address) do |c|
c.on_connect { connected = true; handle_connect; @net.suspend }
c.on_connect_error { |e| connect_error = e; @net.suspend }
c.on_receive_bytes { |bytes| handle_receive_bytes(bytes) }
c.on_close { @conn = nil; handle_connection_close }
end
dispatch until connected or connect_error or @net.done?
if connect_error
transcribe_connect_error(connect_error)
raise ScripTTY::Exception::ConnectError.new(connect_error)
end
refresh_timeout
connected
end
# Add the specified pattern to the effective pattern list.
#
# Return the PatternHandle for the pattern.
#
# Options:
# [:continue]
# If true, matching this pattern will not cause the wait method to
# return.
def on(pattern, opts={}, &block)
case pattern
when String
@transcript_writer.info("Script executing command", "on", "String", pattern.inspect) if @transcript_writer
ph = PatternHandle.new(/#{Regexp.escape(pattern)}/n, block, opts[:background])
when Regexp
@transcript_writer.info("Script executing command", "on", "Regexp", pattern.inspect) if @transcript_writer
if pattern.kcode == "none"
ph = PatternHandle.new(pattern, block, opts[:background])
else
ph = PatternHandle.new(/#{pattern}/n, block, opts[:background])
end
when ScreenPattern
@transcript_writer.info("Script executing command", "on", "ScreenPattern", pattern.name, opts[:background] ? "BACKGROUND" : "") if @transcript_writer
ph = PatternHandle(pattern, block, opts[:background])
else
raise TypeError.new("Unsupported pattern type: #{pattern.class.inspect}")
end
@effective_patterns << ph
ph
end
# Sleep for the specified number of seconds
def sleep(seconds)
@transcript_writer.info("Script executing command", "sleep", seconds.inspect) if @transcript_writer
sleep_done = false
@net.timer(seconds) { sleep_done = true ; @net.suspend }
dispatch until sleep_done
refresh_timeout
nil
end
- # Return the named ScreenPattern
- # XXX TODO
+ # Return the named ScreenPattern (or nil if no such pattern exists)
def screen(name)
-
+ @screen_patterns[name.to_sym]
+ end
+
+ # Load screens from the specified filenames
+ def load_screens(filenames)
+ filenames.each do |filename|
+ ScreenPattern.parse(File.read(filename)).each do |pattern|
+ @screen_patterns[pattern.name.to_sym] = pattern
+ end
+ end
+ nil
end
# Convenience function.
#
# == Examples
# # Wait for a single pattern to match.
# expect("login: ")
#
# # Wait for one of several patterns to match.
# expect {
# on("login successful") { ... }
# on("login incorrect") { ... }
# }
def expect(pattern=nil)
raise ArgumentError.new("no pattern and no block given") if !pattern and !block_given?
@transcript_writer.info("Script expect block BEGIN") if @transcript_writer and block_given?
push_patterns
begin
on(pattern) if pattern
yield if block_given?
wait
ensure
pop_patterns
@transcript_writer.info("Script expect block END") if @transcript_writer and block_given?
end
end
# Push a copy of the effective pattern list to an internal stack.
def push_patterns
@pattern_stack << @effective_patterns.dup
end
# Pop the effective pattern list from the stack.
def pop_patterns
raise ArgumentError.new("pattern stack empty") if @pattern_stack.empty?
@effective_patterns = @pattern_stack.pop
end
# Wait for an effective pattern to match.
#
# Clears the character-match buffer on return.
def wait
@transcript_writer.info("Script executing command", "wait") if @transcript_writer
check_expect_match unless @wait_finished
dispatch until @wait_finished
refresh_timeout
@wait_finished = false
nil
end
# Send bytes to the remote application.
#
# NOTE: This method returns immediately, even if not all the bytes are
# finished being sent. Remaining bytes will be sent during an expect,
# wait, or sleep call.
def send(bytes)
@transcript_writer.from_client(bytes) if @transcript_writer
@conn.write(bytes)
true
end
# Close the connection and exit.
def exit
@transcript_writer.info("Script executing command", "exit") if @transcript_writer
@net.exit
dispatch until @net.done?
@transcript_writer.close if @transcript_writer
end
private
# Kick the watchdog timer
def refresh_timeout
disable_timeout
enable_timeout
end
def without_timeout
raise ArgumentError.new("no block given") unless block_given?
disable_timeout
begin
yield
ensure
enable_timeout
end
end
# Disable timeout handling
def disable_timeout
if @timeout_timer
@timeout_timer.cancel
@timeout_timer = nil
end
nil
end
# Enable timeout handling (if @timeout is set)
def enable_timeout
if @timeout
@timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
end
nil
end
# Re-enter the dispatch loop
def dispatch
if @suspended
@suspended = @net.resume
else
@suspended = @net.main
end
end
def handle_connection_close # XXX - we should raise an error when disconnected prematurely
@transcript_writer.server_close("connection closed") if @transcript_writer
self.exit
end
def handle_connect
@transcript_writer.server_open(*@conn.remote_address) if @transcript_writer
init_term
end
def transcribe_connect_error(e)
if @transcript_writer
@transcript_writer.info("Connect error", e.class.name, e.to_s, e.backtrace.join("\n"))
# Write the backtrace out as separate records, for the convenience of people reading the logs without a parser.
e.backtrace.each do |line|
@transcript_writer.info("Connect error backtrace", line)
end
end
end
def handle_receive_bytes(bytes)
@transcript_writer.from_server(bytes) if @transcript_writer
@match_buffer << bytes
@term.feed_bytes(bytes)
check_expect_match
end
# Check for a match.
#
# If there is a (non-background) match, set @wait_finished and return true. Otherwise, return false.
def check_expect_match
found = true
while found
found = false
@effective_patterns.each { |ph|
case ph.pattern
when Regexp
m = ph.pattern.match(@match_buffer)
@match_buffer = @match_buffer[m.end(0)..-1] if m # truncate match buffer
when ScreenPattern
m = ph.pattern.match_term(@term)
@match_buffer = "" if m # truncate match buffer if a screen matches
else
raise "BUG: pattern is #{ph.pattern.inspect}"
end
next unless m
# Matched - Invoke the callback
ph.callback.call(m) if ph.callback
# Make the next wait() call return
unless ph.background?
@wait_finished = true
@net.suspend
return true
else
found = true
end
}
end
false
end
class Evaluator
def initialize(expect_object)
@_expect_object = expect_object
end
# Define proxy methods
EXPORTED_METHODS.each do |m|
# We would use define_method, but JRuby 1.4 doesn't support defining
# a block that takes a block. http://jira.codehaus.org/browse/JRUBY-4180
class_eval("def #{m}(*args, &block) @_expect_object.__send__(#{m.inspect}, *args, &block); end")
end
end
class PatternHandle
attr_reader :pattern
attr_reader :callback
def initialize(pattern, callback, background)
@pattern = pattern
@callback = callback
@background = background
end
def background?
@background
end
end
class Match
attr_reader :pattern_handle
attr_reader :result
def initialize(pattern_handle, result)
@pattern_handle = pattern_handle
@result = result
end
end
end
end
|
infonium/scriptty
|
09bdbe03cd0f493ee1382c534adbed842abf234c
|
Fix ScripTTY::ScreenPattern.parse return value
|
diff --git a/lib/scriptty/screen_pattern.rb b/lib/scriptty/screen_pattern.rb
index a5f780c..c65a29b 100644
--- a/lib/scriptty/screen_pattern.rb
+++ b/lib/scriptty/screen_pattern.rb
@@ -1,101 +1,102 @@
# = Screen pattern object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
module ScripTTY
class ScreenPattern
class <<self
# Parse a pattern file and return an array of ScreenPattern objects
def parse(s)
retval = []
Parser.parse(s) do |spec|
retval << new(spec[:name], spec[:properties])
end
+ retval
end
def from_term(term, name=nil)
from_text(term.text, :name => name, :cursor_pos => term.cursor_pos)
end
def from_text(text, opts={})
text = text.split(/\r?\n/n) if text.is_a?(String)
name ||= opts[:name] || "untitled"
width = text.map{|line| line.chars.to_a.length}.max
height = text.length
properties = {}
properties['cursor_pos'] = opts[:cursor_pos]
properties['size'] = [height, width]
properties['matches'] = []
text.each_with_index{|line, i|
properties['matches'] << [[i, 0], line]
}
new(name, properties)
end
protected :new # Users should not instantiate this object directly
end
# The name given to this pattern
attr_accessor :name
# The [row, column] of the cursor position (or nil if unspecified)
attr_accessor :cursor_pos
def initialize(name, properties) # :nodoc:
@name = name
@position = properties["position"]
@size = properties["size"]
@cursor_pos = properties["cursor_pos"]
@field_ranges = properties["fields"] # Hash of "field_name" => [row, col1..col2] ranges
@matches = properties["matches"] # Array of [[row,col], string] records to match
end
def inspect
"#<#{self.class.name}:#{sprintf("0x%x", object_id)} name=#{@name}>"
end
# Match this pattern against a Term object. If the match succeeds, return
# the Hash of fields extracted from the screen. Otherwise, return nil.
def match_term(term)
return nil if @cursor_pos and @cursor_pos != term.cursor_pos
# XXX UNICODE
if @matches
text = term.text
@matches.each do |pos, str|
row, col = pos
col_range = col..col + str.length
return nil unless text[row][col_range] == str
end
end
fields = {}
@field_ranges.each_pair do |k, range|
row, col_range = range
fields[k] = text[row][col_range]
end
fields
end
def generate(name=nil)
Generator.generate(name || "untitled", :cursor_pos => @cursor_pos, :matches => @matches, :fields => @field_ranges, :position => @position, :size => @size)
end
end
end
require 'scriptty/screen_pattern/parser'
require 'scriptty/screen_pattern/generator'
|
infonium/scriptty
|
f2775c39d321e9d5f0ed7e333a5b1eaa34381da4
|
ScripTTY::Term::DG410 - Fix t_proprietary_escape callback
|
diff --git a/lib/scriptty/term/dg410.rb b/lib/scriptty/term/dg410.rb
index 10ff5df..0ec4ed3 100644
--- a/lib/scriptty/term/dg410.rb
+++ b/lib/scriptty/term/dg410.rb
@@ -1,489 +1,489 @@
# = DG410 terminal emulation
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
# XXX TODO - deduplicate between this and xterm.rb
require 'scriptty/multiline_buffer'
require 'scriptty/cursor'
require 'scriptty/util/fsm'
require 'set'
module ScripTTY # :nodoc:
module Term
class DG410
require 'scriptty/term/dg410/parser' # we want to create the DG410 class here before parser.rb reopens it
DEFAULT_FLAGS = {
:insert_mode => false,
:wraparound_mode => false,
:roll_mode => true, # scroll up when the cursor moves beyond the bottom
}.freeze
# width and height of the display buffer
attr_reader :width, :height
# Return ScripTTY::Term::DG410::Parser
def self.parser_class
Parser
end
def initialize(height=24, width=80)
@parser = self.class.parser_class.new(:callback => self, :callback_method => :send)
@height = height
@width = width
@proprietary_escape_callback = nil
reset_to_initial_state!
end
def on_unknown_sequence(mode=nil, &block)
@parser.on_unknown_sequence(mode, &block)
end
def on_proprietary_escape(mode=nil, &block)
if mode == :ignore and !block
@proprietary_escape_callback = nil
elsif !mode and block
@proprietary_escape_callback = block
else
raise ArgumentError.new("mode and block are mutually exclusive")
end
nil
end
def feed_bytes(bytes)
@parser.feed_bytes(bytes)
end
def feed_byte(byte)
@parser.feed_byte(byte)
end
# Return an array of lines of text representing the state of the terminal.
# Used for debugging.
def debug_info
output = []
output << "state:#{@parser.fsm.state.inspect} seq:#{@parser.fsm.input_sequence && @parser.fsm.input_sequence.join.inspect}"
output << "scrolling_region: #{@scrolling_region.inspect}"
output << "flags: roll:#{@flags[:roll_mode]} wraparound:#{@flags[:wraparound_mode]} insert:#{@flags[:insert_mode]}"
output
end
def inspect # :nodoc:
# The default inspect method shows way too much information. Simplify it.
"#<#{self.class.name}:#{sprintf('0x%0x', object_id)} h=#{@height.inspect} w=#{@width.inspect} cursor=#{cursor_pos.inspect}>"
end
# Return an array of strings representing the lines of text on the screen
#
# NOTE: If passing copy=false, do not modify the return value or the strings inside it.
def text(copy=true)
if copy
@glyphs.content.map{|line| line.dup}
else
@glyphs.content
end
end
# Return the cursor position, as an array of [row, column].
#
# [0,0] represents the topmost, leftmost position.
def cursor_pos
[@cursor.row, @cursor.column]
end
# Set the cursor position to [row, column].
#
# [0,0] represents the topmost, leftmost position.
def cursor_pos=(v)
@cursor.pos = v
end
# Replace the text on the screen with the specified text.
#
# NOTE: This is API is very likely to change in the future.
def text=(a)
@glyphs.clear!
@glyphs.replace_at(0, 0, a)
a
end
protected
# Reset to the initial state. Return true.
def reset_to_initial_state!
@flags = DEFAULT_FLAGS.dup
# current cursor position
@cursor = Cursor.new
@cursor.row = @cursor.column = 0
@saved_cursor_position = [0,0]
# Screen buffer
@glyphs = MultilineBuffer.new(@height, @width) # the displayable characters (as bytes)
@attrs = MultilineBuffer.new(@height, @width) # character attributes (as bytes)
# Vertical scrolling region. An array of [start_row, end_row]. Defaults to [0, height-1].
@scrolling_region = [0, @height-1]
true
end
# Replace the character under the cursor with the specified character.
#
# If curfwd is true, the cursor is also moved forward.
#
# Returns true.
def put_char!(input, curfwd=false)
raise TypeError.new("input must be single-character string") unless input.is_a?(String) and input.length == 1
@glyphs.replace_at(@cursor.row, @cursor.column, input)
@attrs.replace_at(@cursor.row, @cursor.column, " ")
cursor_forward! if curfwd
true
end
# Move the cursor to the leftmost column in the current row, then return true.
def carriage_return!
@cursor.column = 0
true
end
# Move the cursor down one row and return true.
#
# If the cursor is on the bottom row of the vertical scrolling region,
# the region is scrolled. If bot, but the cursor is on the bottom of
# the screen, this command has no effect.
def line_feed!
if @cursor.row == @scrolling_region[1] # cursor is on the bottom row of the scrolling region
if @flags[:roll_enable]
scroll_up!
else
@cursor.row = @scrolling_region[0]
end
elsif @cursor.row >= @height-1
# do nothing
else
cursor_down!
end
true
end
# Save the cursor position. Return true.
def save_cursor!
@saved_cursor_position = [@cursor.row, @cursor.column]
true
end
# Restore the saved cursor position. If nothing has been saved, then go to the home position. Return true.
def restore_cursor!
@cursor.row, @cursor.column = @saved_cursor_position
true
end
# Move the cursor down one row and return true.
# If the cursor is on the bottom row, return false without moving the cursor.
def cursor_down!
if @cursor.row >= @height-1
false
else
@cursor.row += 1
true
end
end
# Move the cursor up one row and return true.
# If the cursor is on the top row, return false without moving the cursor.
def cursor_up!
if @cursor.row <= 0
false
else
@cursor.row -= 1
true
end
end
# Move the cursor right one column and return true.
# If the cursor is on the right-most column, return false without moving the cursor.
def cursor_right!
if @cursor.column >= @width-1
false
else
@cursor.column += 1
true
end
end
# Move the cursor to the right. Wrap around if we reach the end of the screen.
#
# Return true.
def cursor_forward!(options={})
if @cursor.column >= @width-1
line_feed!
carriage_return!
else
cursor_right!
end
end
# Move the cursor left one column and return true.
# If the cursor is on the left-most column, return false without moving the cursor.
def cursor_left!
if @cursor.column <= 0
false
else
@cursor.column -= 1
true
end
end
alias cursor_back! cursor_left! # In the future, this might not be an alias
# Scroll the contents of the screen up by one row and return true.
# The position of the cursor does not change.
def scroll_up!
@glyphs.scroll_up_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
@attrs.scroll_up_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
true
end
# Scroll the contents of the screen down by one row and return true.
# The position of the cursor does not change.
def scroll_down!
@glyphs.scroll_down_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
@attrs.scroll_down_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
true
end
# Erase, starting with the character under the cursor and extending to the end of the line.
# Return true.
def erase_to_end_of_line!
@glyphs.replace_at(@cursor.row, @cursor.column, " "*(@[email protected]))
@attrs.replace_at(@cursor.row, @cursor.column, " "*(@[email protected]))
true
end
# Erase, starting with the beginning of the line and extending to the character under the cursor.
# Return true.
def erase_to_start_of_line!
@glyphs.replace_at(@cursor.row, 0, " "*(@cursor.column+1))
@attrs.replace_at(@cursor.row, 0, " "*(@cursor.column+1))
true
end
# Erase the current (or specified) line. The cursor position is unchanged.
# Return true.
def erase_line!(row=nil)
row = @cursor.row unless row
@glyphs.replace_at(row, 0, " "*@width)
@attrs.replace_at(row, 0, " "*@width)
true
end
# Erase the window. Return true.
def erase_window!
empty_line = " "*@width
@height.times do |row|
@glyphs.replace_at(row, 0, empty_line)
@attrs.replace_at(row, 0, empty_line)
end
true
end
# Delete the specified number of lines, starting at the cursor position
# extending downwards. The lines below the deleted lines are scrolled up,
# and blank lines are inserted below them.
# Return true.
def delete_lines!(count=1)
@glyphs.scroll_up_region(@cursor.row, 0, @height-1, @width-1, count)
@attrs.scroll_up_region(@cursor.row, 0, @height-1, @width-1, count)
true
end
# Delete the specified number of characters, starting at the cursor position
# extending to the end of the line. The characters to the right of the
# cursor are scrolled left, and blanks are inserted after them.
# Return true.
def delete_characters!(count=1)
@glyphs.scroll_left_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
@attrs.scroll_left_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
true
end
# Insert the specified number of blank characters at the cursor position.
# The characters to the right of the cursor are scrolled right, and blanks
# are inserted in their place.
# Return true.
def insert_blank_characters!(count=1)
@glyphs.scroll_right_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
@attrs.scroll_right_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
true
end
# Insert the specified number of lines characters at the cursor position.
# The characters to the below the cursor are scrolled down, and blank
# lines are inserted in their place.
# Return true.
def insert_blank_lines!(count=1)
@glyphs.scroll_down_region(@cursor.row, 0, @height-1, @width-1, count)
@attrs.scroll_down_region(@cursor.row, 0, @height-1, @width-1, count)
true
end
private
# Set the vertical scrolling region.
#
# Values will be clipped.
def set_scrolling_region!(top, bottom)
@scrolling_region[0] = [0, [@height-1, top].min].max
@scrolling_region[1] = [0, [@width-1, bottom].min].max
nil
end
def error(message) # XXX - This sucks
raise ArgumentError.new(message)
#puts message # DEBUG FIXME
end
def t_reset(fsm)
reset_to_initial_state!
end
# Printable character
def t_printable(fsm) # :nodoc:
insert_blank_characters! if @flags[:insert_mode] # TODO
put_char!(fsm.input)
cursor_forward!
end
# Move the cursor to the left margin on the current row.
def t_carriage_return(fsm)
carriage_return!
end
# Move the cursor to the left margin on the next row.
def t_new_line(fsm)
carriage_return!
line_feed!
end
# Move cursor to the top-left cell of the window.
def t_window_home(fsm)
@cursor.pos = [0,0]
end
# Erase all characters starting at the cursor and extending to the end of the window.
def t_erase_unprotected(fsm)
# Erase to the end of the current line
erase_to_end_of_line!
# Erase subsequent lines to the end of the window.
(@cursor.row+1..@height-1).each do |row|
erase_line!(row)
end
end
# Erase all characters starting at the cursor and extending to the end of the line.
def t_erase_end_of_line(fsm)
erase_to_end_of_line!
end
# Move the cursor to the specified position within the window.
# <020> <column> <row>
def t_write_window_address(fsm)
column, row = fsm.input_sequence[1,2].join.unpack("C*")
row = @cursor.row if row == 0177 # 0177 == special case: do not change the row
column = @cursor.column if column == 0177 # 0177 == special case: do not change the column
column = @width-1 if column > @width-1
row = @height-1 if row > @height-1
@cursor.pos = [row, column]
end
# Erase all characters in the current window, and move the cursor to
# the top-left cell of the window.
def t_erase_window(fsm)
erase_window!
@cursor.pos = [0,0]
end
def t_cursor_up(fsm)
cursor_up!
end
def t_cursor_down(fsm)
cursor_down!
end
def t_cursor_right(fsm)
cursor_right!
end
def t_cursor_left(fsm)
cursor_left!
end
# ESC ] ... M
# XXX - What is this?
def t_osc_m(fsm) end # TODO
def t_osc_k(fsm) end # TODO
def t_roll_enable(fsm)
@flags[:roll_mode] = true
end
def t_roll_disable(fsm)
@flags[:roll_mode] = false
end
def t_print_window(fsm) end # TODO
def t_bell(fsm) end # TODO
def t_blink_enable(fsm) end # TODO
def t_blink_disable(fsm) end # TODO
def t_underscore_on(fsm) end # TODO
def t_underscore_off(fsm) end # TODO
def t_blink_on(fsm) end # TODO
def t_blink_off(fsm) end # TODO
def t_reverse_video_on(fsm) end # TODO
def t_reverse_video_off(fsm) end # TODO
def t_dim_on(fsm) end # TODO
def t_dim_off(fsm) end # TODO
def t_set_cursor_type(fsm) end # TODO
def t_telnet_will(fsm) end # TODO
def t_telnet_wont(fsm) end # TODO
def t_telnet_do(fsm) end # TODO
def t_telnet_dont(fsm) end # TODO
def t_telnet_subnegotiation(fsm) end # TODO
# Proprietary escape code
# <036> ~ <2-byte-command> <n> <n*bytes>
def t_proprietary_escape(fsm)
- command = fsm.input_sequence[3,2].join
+ command = fsm.input_sequence[2,2].join
payload = fsm.input_sequence[5..-1].join
@proprietary_escape_callback.call(command, payload) if @proprietary_escape_callback
end
# Acknowledgement of proprietary escape sequence.
# From the server to the client, this is just a single-character ACK
def t_proprietary_ack(fsm) end # TODO
end
end
end
|
infonium/scriptty
|
0120775130dac6758e8d86c13fabc149e2d40985
|
ScripTTY::ScreenPattern add generate method, and from_term/from_text class methods
|
diff --git a/lib/scriptty/screen_pattern.rb b/lib/scriptty/screen_pattern.rb
index 5299d2b..a5f780c 100644
--- a/lib/scriptty/screen_pattern.rb
+++ b/lib/scriptty/screen_pattern.rb
@@ -1,78 +1,101 @@
# = Screen pattern object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
module ScripTTY
class ScreenPattern
class <<self
# Parse a pattern file and return an array of ScreenPattern objects
def parse(s)
retval = []
Parser.parse(s) do |spec|
retval << new(spec[:name], spec[:properties])
end
end
+
+ def from_term(term, name=nil)
+ from_text(term.text, :name => name, :cursor_pos => term.cursor_pos)
+ end
+
+ def from_text(text, opts={})
+ text = text.split(/\r?\n/n) if text.is_a?(String)
+ name ||= opts[:name] || "untitled"
+
+ width = text.map{|line| line.chars.to_a.length}.max
+ height = text.length
+ properties = {}
+ properties['cursor_pos'] = opts[:cursor_pos]
+ properties['size'] = [height, width]
+ properties['matches'] = []
+ text.each_with_index{|line, i|
+ properties['matches'] << [[i, 0], line]
+ }
+ new(name, properties)
+ end
protected :new # Users should not instantiate this object directly
end
# The name given to this pattern
attr_accessor :name
# The [row, column] of the cursor position (or nil if unspecified)
attr_accessor :cursor_pos
def initialize(name, properties) # :nodoc:
@name = name
- #@position = properties["position"]
- #@size = properties["size"]
+ @position = properties["position"]
+ @size = properties["size"]
@cursor_pos = properties["cursor_pos"]
@field_ranges = properties["fields"] # Hash of "field_name" => [row, col1..col2] ranges
@matches = properties["matches"] # Array of [[row,col], string] records to match
end
def inspect
"#<#{self.class.name}:#{sprintf("0x%x", object_id)} name=#{@name}>"
end
# Match this pattern against a Term object. If the match succeeds, return
# the Hash of fields extracted from the screen. Otherwise, return nil.
def match_term(term)
return nil if @cursor_pos and @cursor_pos != term.cursor_pos
# XXX UNICODE
if @matches
text = term.text
@matches.each do |pos, str|
row, col = pos
col_range = col..col + str.length
return nil unless text[row][col_range] == str
end
end
fields = {}
@field_ranges.each_pair do |k, range|
row, col_range = range
fields[k] = text[row][col_range]
end
fields
end
+ def generate(name=nil)
+ Generator.generate(name || "untitled", :cursor_pos => @cursor_pos, :matches => @matches, :fields => @field_ranges, :position => @position, :size => @size)
+ end
end
end
require 'scriptty/screen_pattern/parser'
require 'scriptty/screen_pattern/generator'
diff --git a/lib/scriptty/screen_pattern/generator.rb b/lib/scriptty/screen_pattern/generator.rb
index b535d9e..d56fe28 100644
--- a/lib/scriptty/screen_pattern/generator.rb
+++ b/lib/scriptty/screen_pattern/generator.rb
@@ -1,394 +1,398 @@
# = Generator for screen pattern files
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'multibyte'
require 'set'
require 'scriptty/screen_pattern'
require 'scriptty/screen_pattern/parser'
module ScripTTY
class ScreenPattern # reopen
class Generator
class <<self
# Generate a screen pattern from a specification
#
# Options:
# [:force_fields]
# If true, the fields will be positioned in-line, even if there is
# matching text or cursor there. :force_fields takes precedence over :force_cursor.
# [:force_cursor]
# If true, the cursor will be positioned in-line, even if there is
# matching text or fields there. :force_cursor may also be a
# Regexp, in which case the regexp must match in order for the field
# to be replaced. :force_fields takes precedence over :force_cursor.
# [:ignore]
# If specified, this is an array of [row, col0..col1] ranges.
def generate(name, properties_and_options={})
new(name, properties_and_options).generate
end
protected :new # Users should not instantiate this object directly
end
IGNORE_CHAR_CHOICES = ['.', '~', "'", "^", "-", "?", " ", "â"]
CURSOR_CHAR_CHOICES = ["@", "+", "&", "â"]
FIELD_CHAR_CHOICES = ["#", "*", "%", "=", "_", "â"]
def initialize(name, properties={})
properties = properties.dup
@force_cursor = properties.delete(:force_cursor)
@force_fields = properties.delete(:force_fields)
@ignore = properties.delete(:ignore)
load_spec(name, properties)
make_grid
end
def generate
@out = []
@out << "[#{@name}]"
@out << "position: #{encode_tuple(@position)}" if @position and @position != [0,0]
@out << "size: #{encode_tuple(@size)}"
if @char_cursor
@out << "char_cursor: #{encode_string(@char_cursor)}"
elsif @cursor_pos
@out << "cursor_pos: #{encode_tuple(@cursor_pos)}"
end
@out << "char_ignore: #{encode_string(@char_ignore)}" if @char_ignore
@out << "char_field: #{encode_string(@char_field)}" if @char_field
if @explicit_fields
@out << "fields: <<END"
@explicit_fields.each { |f|
@out << " #{encode_tuple(f)}"
}
@out << "END"
end
if @text_lines
@out << "text: <<END"
@out += @text_lines
@out << "END"
end
@out.map{|line| "#{line}\n"}.join
end
private
def make_grid
# Initialize grid as 2D array of nils
height, width = @size
grid = (1..height).map { [nil] * width }
# Fill in matches
if @matches
@matches.each do |pos, string|
row, col = pos
string.chars.to_a.each do |char|
raise ArgumentError.new("overlapping match: #{[pos, string].inspect}") if grid[row][col]
grid[row][col] = char
col += 1
end
end
end
# Fill in ignore overrides
if @ignore
@ignore.each do |row, col_range|
row, col_range = rel_pos([row, col_range])
col_range.each do |col|
grid[row][col] = nil
end
end
end
# Fill in fields, possibly overwriting matches
if @fields
@explicit_fields = []
@implicit_fields_by_row = {}
@fields.each_with_index do |f, i|
name, row, col_range = f
first_col = col_range.first
explicit = false
if first_col > 0 and grid[row][first_col-1] == :field # adjacent fields
explicit = true
elsif !@force_fields
col_range.each do |col|
if grid[row][col]
explicit = true
break
end
end
end
if explicit
@explicit_fields << [name, [row, first_col], col_range.count] # [name, pos, length]
else
@implicit_fields_by_row[row] ||= []
@implicit_fields_by_row[row] << name
col_range.each do |col|
grid[row][col] = :field
end
end
end
@explicit_fields = nil if @explicit_fields.empty?
@implicit_fields_by_row = nil if @implicit_fields_by_row.empty?
end
# Fill in the cursor, possibly overwriting matches (but never fields)
if @cursor_pos
row, col = @cursor_pos
if !grid[row][col]
grid[row][col] = :cursor
elsif @force_cursor and grid[row][col] != :field and (!@force_cursor.is_a?(Regexp) or @force_cursor =~ grid[row][col])
grid[row][col] = :cursor
end
end
# Walk the grid, checking for nil, :field, and :cursor. We won't
# generate characters for ones that aren't present.
has_ignore = has_field = has_cursor = false
height.times do |row|
width.times do |col|
if grid[row][col].nil?
has_ignore = true
elsif grid[row][col] == :field
has_field = true
elsif grid[row][col] == :cursor
has_cursor = true
end
end
end
@char_ignore = nil unless has_ignore
@char_field = nil unless has_field
@char_cursor = nil unless has_cursor
# Determine which characters were already used
@used_chars = Set.new
@used_chars << @char_ignore if @char_ignore
@used_chars << @char_field if @char_field
@used_chars << @char_cursor if @char_cursor
height.times do |row|
width.times do |col|
if grid[row][col] and grid[row][col].is_a?(String)
@used_chars << grid[row][col]
end
end
end
# Choose a character to represent ignored positions
if has_ignore and !@char_ignore
IGNORE_CHAR_CHOICES.each do |char|
next if @used_chars.include?(char)
@char_ignore = char
break
end
raise ArgumentError.new("Could not auto-select char_ignore") unless @char_ignore
@used_chars << @char_ignore
end
# Choose a character to represent the cursor
if has_cursor and !@char_cursor
CURSOR_CHAR_CHOICES.each do |char|
next if @used_chars.include?(char)
@char_cursor = char
break
end
raise ArgumentError.new("Could not auto-select char_cursor") unless @char_cursor
@used_chars << @char_cursor
end
# Choose a character to represent fields
if has_field and !@char_field
FIELD_CHAR_CHOICES.each do |char|
next if @used_chars.include?(char)
@char_field = char
break
end
raise ArgumentError.new("Could not auto-select char_field") unless @char_field
@used_chars << @char_field
end
# Walk the grid and fill in the placeholders
height.times do |row|
width.times do |col|
if grid[row][col].nil?
grid[row][col] = @char_ignore
elsif grid[row][col] == :field
grid[row][col] = @char_field
elsif grid[row][col] == :cursor
grid[row][col] = @char_cursor
elsif !grid[row][col].is_a?(String)
raise "BUG: grid[#{row}][#{col}] #{grid[row][col].inspect}"
elsif [@char_cursor, @char_field].include?(grid[row][col])
grid[row][col] = @char_ignore
end
end
end
@text_lines = []
@text_lines << "+" + "-"*width + "+"
height.times do |row|
grid_row = "|" + grid[row].join + "|"
if @implicit_fields_by_row and @implicit_fields_by_row[row]
grid_row += " " + encode_tuple(@implicit_fields_by_row[row])
end
@text_lines << grid_row
end
@text_lines << "+" + "-"*width + "+"
end
def encode_tuple(t)
"(" + t.map{|v|
if v.is_a?(Integer)
v.to_s
elsif v.is_a?(String)
encode_string(v)
elsif v.is_a?(Array)
encode_tuple(v)
else
raise "BUG: encode_tuple(#{t.inspect}) on #{v.inspect}"
end
}.join(", ") + ")"
end
def encode_string(v)
r = ['"']
v.split("").each { |c|
if c =~ /\A#{Parser::STR_UNESCAPED}\Z/no
r << c
else
r << sprintf("\\%03o", c.unpack("C*")[0])
end
}
r << '"'
r.join
end
def load_spec(name, properties)
properties = properties.dup
- properties.keys.each do |k| # Replace symbol keys with strings
- properties[k.to_s] = properties.delete(k)
+ properties.keys.each do |k| # Replace symbol keys with strings, and remove false/nil properties.
+ if properties[k]
+ properties[k.to_s] = properties.delete(k)
+ else
+ properties.delete(k)
+ end
end
# Check name
raise ArgumentError.new("illegal name") unless name =~ /\A#{Parser::IDENTIFIER}\Z/no
@name = name
# position [row, column]
if properties["position"]
@position = properties.delete("position").dup
unless @position.is_a?(Array) and @position.length == 2 and @position.map{|v| v.is_a?(Integer) and v >= 0}.all?
raise ArgumentError.new("bad 'position' entry: #{@position.inspect}")
end
end
# size [rows, columns]
if properties["size"]
@size = properties.delete("size").dup
unless @size.is_a?(Array) and @size.length == 2 and @size.map{|v| v.is_a?(Integer) and v >= 0}.all?
raise ArgumentError.new("bad 'size' entry: #{@size.inspect}")
end
else
raise ArgumentError.new("'size' is required")
end
# cursor_pos [row, column]
if properties["cursor_pos"]
@cursor_pos = properties.delete("cursor_pos")
unless @cursor_pos.is_a?(Array) and @cursor_pos.length == 2 and @cursor_pos.map{|n| n.is_a?(Integer)}.all?
raise ArgumentError.new("Illegal cursor_pos")
end
@cursor_pos = rel_pos(@cursor_pos)
unless @cursor_pos[0] >= 0 and @cursor_pos[1] >= 0
raise ArgumentError.new("cursor_pos out of range")
end
end
# fields {"name" => [row, column_range]}
if properties["fields"]
fields = []
pfields = {}
properties.delete("fields").each_pair do |name, range|
pfields[name.to_s] = range # convert symbols to strings
end
pfields.each_pair do |name, range|
unless range.is_a?(Array) and range.length == 2 and range[0].is_a?(Integer) and range[1].is_a?(Range)
raise ArgumentError.new("field #{name.inspect} should be [row, col0..col1], not #{range.inspect}")
end
row, col_range = range
unless col_range.first >= 0 and col_range.last >= 0
raise ArgumentError.new("field #{name.inspect} should contain positive column range, not #{col_range.inspect}")
end
row, col_range = rel_pos([row, col_range])
fields << [name, row, col_range]
end
@fields = fields.sort{|a,b| [a[1], a[2].first] <=> [b[1], b[2].first]} # sort fields in screen order
@fields = nil if @fields.empty?
end
# matches [pos, string]
if properties["matches"]
@matches = []
properties.delete("matches").each do |m|
unless (m.is_a?(Array) and m.length == 2 and m[0].is_a?(Array) and
m[0].length == 2 and m[0].map{|v| v.is_a?(Integer)}.all? and
m[1].is_a?(String))
raise ArgumentError.new("bad 'matches' entry: #{m.inspect}")
end
pos, string = m
pos = rel_pos(pos)
unless pos[0] >= 0 and pos[1] >= 0
raise ArgumentError.new("'matches' entry out of range: #{m.inspect}")
end
@matches << [pos, string]
end
@matches.sort!{|a,b| a[0] <=> b[0]} # sort matches in screen order
end
if properties['char_cursor']
@char_cursor = properties.delete("char_cursor")
@char_cursor = Multibyte::Chars.new(@char_cursor).normalize(:c).to_a.join # Unicode Normalization Form C (NFC)
raise ArgumentError.new("char_cursor must be 1 character") unless @char_cursor.chars.to_a.length == 1
end
if properties['char_field']
@char_field = properties.delete("char_field")
@char_field = Multibyte::Chars.new(@char_field).normalize(:c).to_a.join # Unicode Normalization Form C (NFC)
raise ArgumentError.new("char_field must be 1 character") unless @char_field.chars.to_a.length == 1
raise ArgumentError.new("char_field conflicts with char_cursor") if @char_field == @char_cursor
end
if properties['char_ignore']
@char_ignore = properties.delete("char_ignore")
@char_ignore = Multibyte::Chars.new(@char_ignore).normalize(:c).to_a.join # Unicode Normalization Form C (NFC)
raise ArgumentError.new("char_ignore must be 1 character") unless @char_ignore.chars.to_a.length == 1
raise ArgumentError.new("char_ignore conflicts with char_cursor") if @char_ignore == @char_cursor
raise ArgumentError.new("char_ignore conflicts with char_field") if @char_ignore == @char_field
end
raise ArgumentError.new("extraneous properties: #{properties.keys.inspect}") unless properties.empty?
end
# Convert an absolute [row,column] or [row, col1..col2] into a relative position or range.
def rel_pos(absolute_pos)
screen_pos = @position || [0,0]
if absolute_pos[1].is_a?(Range)
[absolute_pos[0]-screen_pos[0], absolute_pos[1].first-screen_pos[1]..absolute_pos[1].last-screen_pos[1]]
else
[absolute_pos[0]-screen_pos[0], absolute_pos[1]-screen_pos[1]]
end
end
end
end
end
|
infonium/scriptty
|
507fb0d83eff936f13c4ea623e37c1fc6e1cca6e
|
Add telnet negotiation example
|
diff --git a/examples/telnet-nego.rb b/examples/telnet-nego.rb
new file mode 100644
index 0000000..b35590b
--- /dev/null
+++ b/examples/telnet-nego.rb
@@ -0,0 +1,55 @@
+# Telnet negotiation example
+#
+# NOTE: This would cause an infinite loop if two ends of the connection ran
+# this algorithm, but it appears to be safe on the client-side only with a
+# smarter server.
+
+# Options we WILL (in response to DO)
+supported_will_options = [
+ "\000", # Binary Transmission
+ "\003", # Suppress Go Ahead
+]
+
+# Options we DO (in response to WILL)
+supported_do_options = [
+ "\000", # Binary Transmission
+ "\001", # Echo
+ "\003", # Suppress Go Ahead
+]
+
+# Initial send
+supported_do_options.each do |opt|
+ send "\377\375#{opt}" # IAC DO <option>
+end
+supported_will_options.each do |opt|
+ send "\377\373#{opt}" # IAC WILL <option>
+end
+
+done_telnet_nego = false
+until done_telnet_nego
+ expect {
+ on(/\377([\373\374\375\376])(.)/n) { |m| # IAC WILL/WONT/DO/DONT <option>
+ cmd = {"\373" => :will, "\374" => :wont, "\375" => :do, "\376" => :dont}[m[1]]
+ opt = m[2]
+ puts "IAC #{cmd} #{opt.inspect}"
+ if cmd == :do
+ if supported_will_options.include?(opt)
+ send "\377\373#{opt}" # IAC WILL <option>
+ else
+ send "\377\374#{opt}" # IAC WONT <option>
+ end
+ elsif cmd == :will
+ if supported_do_options.include?(opt)
+ send "\377\375#{opt}" # IAC DO <option>
+ else
+ send "\377\376#{opt}" # IAC DONT <option>
+ end
+ elsif cmd == :dont
+ send "\377\374#{opt}" # IAC WONT <option>
+ elsif cmd == :wont
+ send "\377\376#{opt}" # IAC DONT <option>
+ end
+ }
+ on(/[^\377]/n) { puts "DONE"; done_telnet_nego = true } # We're done TELNET negotiation when we receive something that's not IAC
+ }
+end
|
infonium/scriptty
|
60c7a11488f009b4e88c1f6cab954499d30679af
|
ScripTTY::Expect - Don't clear the match buffer until a ScreenPattern matches
|
diff --git a/lib/scriptty/expect.rb b/lib/scriptty/expect.rb
index 043d1ba..784dc15 100644
--- a/lib/scriptty/expect.rb
+++ b/lib/scriptty/expect.rb
@@ -1,371 +1,372 @@
# = Expect object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/exception'
require 'scriptty/net/event_loop'
require 'scriptty/term'
require 'scriptty/screen_pattern'
require 'scriptty/util/transcript/writer'
require 'set'
module ScripTTY
class Expect
# Methods to export to Evaluator
EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout ]
attr_reader :term # The terminal emulation object
attr_accessor :transcript_writer # Set this to an instance of ScripTTY::Util::Transcript::Writer
# Initialize the Expect object.
def initialize(options={})
@net = ScripTTY::Net::EventLoop.new
@suspended = false
@effective_patterns = nil
@term_name = nil
@effective_patterns = [] # Array of PatternHandle objects
@pattern_stack = []
@wait_finished = false
@evaluator = Evaluator.new(self)
@match_buffer = ""
@timeout = nil
@timeout_timer = nil
@transcript_writer = options[:transcript_writer]
end
def set_timeout(seconds)
raise ArgumentError.new("argument to set_timeout must be Numeric or nil") unless seconds.is_a?(Numeric) or seconds.nil?
if seconds
@timeout = seconds.to_f
else
@timeout = nil
end
refresh_timeout
nil
end
# Load and evaluate a script from a file.
def eval_script_file(path)
eval_script_inline(File.read(path), path)
end
# Evaluate a script specified as a string.
def eval_script_inline(str, filename=nil, lineno=nil)
@evaluator.instance_eval(str, filename || "(inline)", lineno || 1)
end
# Initialize a terminal emulator.
#
# If a name is specified, use that terminal type. Otherwise, use the
# previous terminal type.
def init_term(name=nil)
@transcript_writer.info("Script executing command", "init_term", name || "") if @transcript_writer
name ||= @term_name
@term_name = name
raise ArgumentError.new("No previous terminal specified") unless name
without_timeout {
@term = ScripTTY::Term.new(name)
@term.on_unknown_sequence do |seq|
@transcript_writer.info("Unknown escape sequence", seq) if @transcript_writer
end
}
nil
end
# Connect to the specified address. Return true if the connection was
# successful. Otherwise, raise an exception.
def connect(remote_address)
@transcript_writer.info("Script executing command", "connect", *remote_address.map{|a| a.inspect}) if @transcript_writer
connected = false
connect_error = nil
@conn = @net.connect(remote_address) do |c|
c.on_connect { connected = true; handle_connect; @net.suspend }
c.on_connect_error { |e| connect_error = e; @net.suspend }
c.on_receive_bytes { |bytes| handle_receive_bytes(bytes) }
c.on_close { @conn = nil; handle_connection_close }
end
dispatch until connected or connect_error or @net.done?
if connect_error
transcribe_connect_error(connect_error)
raise ScripTTY::Exception::ConnectError.new(connect_error)
end
refresh_timeout
connected
end
# Add the specified pattern to the effective pattern list.
#
# Return the PatternHandle for the pattern.
#
# Options:
# [:continue]
# If true, matching this pattern will not cause the wait method to
# return.
def on(pattern, opts={}, &block)
case pattern
when String
@transcript_writer.info("Script executing command", "on", "String", pattern.inspect) if @transcript_writer
ph = PatternHandle.new(/#{Regexp.escape(pattern)}/n, block, opts[:background])
when Regexp
@transcript_writer.info("Script executing command", "on", "Regexp", pattern.inspect) if @transcript_writer
if pattern.kcode == "none"
ph = PatternHandle.new(pattern, block, opts[:background])
else
ph = PatternHandle.new(/#{pattern}/n, block, opts[:background])
end
when ScreenPattern
@transcript_writer.info("Script executing command", "on", "ScreenPattern", pattern.name, opts[:background] ? "BACKGROUND" : "") if @transcript_writer
ph = PatternHandle(pattern, block, opts[:background])
else
raise TypeError.new("Unsupported pattern type: #{pattern.class.inspect}")
end
@effective_patterns << ph
ph
end
# Sleep for the specified number of seconds
def sleep(seconds)
@transcript_writer.info("Script executing command", "sleep", seconds.inspect) if @transcript_writer
sleep_done = false
@net.timer(seconds) { sleep_done = true ; @net.suspend }
dispatch until sleep_done
refresh_timeout
nil
end
# Return the named ScreenPattern
# XXX TODO
def screen(name)
end
# Convenience function.
#
# == Examples
# # Wait for a single pattern to match.
# expect("login: ")
#
# # Wait for one of several patterns to match.
# expect {
# on("login successful") { ... }
# on("login incorrect") { ... }
# }
def expect(pattern=nil)
raise ArgumentError.new("no pattern and no block given") if !pattern and !block_given?
@transcript_writer.info("Script expect block BEGIN") if @transcript_writer and block_given?
push_patterns
begin
on(pattern) if pattern
yield if block_given?
wait
ensure
pop_patterns
@transcript_writer.info("Script expect block END") if @transcript_writer and block_given?
end
end
# Push a copy of the effective pattern list to an internal stack.
def push_patterns
@pattern_stack << @effective_patterns.dup
end
# Pop the effective pattern list from the stack.
def pop_patterns
raise ArgumentError.new("pattern stack empty") if @pattern_stack.empty?
@effective_patterns = @pattern_stack.pop
end
# Wait for an effective pattern to match.
#
# Clears the character-match buffer on return.
def wait
@transcript_writer.info("Script executing command", "wait") if @transcript_writer
+ check_expect_match unless @wait_finished
dispatch until @wait_finished
refresh_timeout
@wait_finished = false
- @match_buffer = ""
nil
end
# Send bytes to the remote application.
#
# NOTE: This method returns immediately, even if not all the bytes are
# finished being sent. Remaining bytes will be sent during an expect,
# wait, or sleep call.
def send(bytes)
@transcript_writer.from_client(bytes) if @transcript_writer
@conn.write(bytes)
true
end
# Close the connection and exit.
def exit
@transcript_writer.info("Script executing command", "exit") if @transcript_writer
@net.exit
dispatch until @net.done?
@transcript_writer.close if @transcript_writer
end
private
# Kick the watchdog timer
def refresh_timeout
disable_timeout
enable_timeout
end
def without_timeout
raise ArgumentError.new("no block given") unless block_given?
disable_timeout
begin
yield
ensure
enable_timeout
end
end
# Disable timeout handling
def disable_timeout
if @timeout_timer
@timeout_timer.cancel
@timeout_timer = nil
end
nil
end
# Enable timeout handling (if @timeout is set)
def enable_timeout
if @timeout
@timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
end
nil
end
# Re-enter the dispatch loop
def dispatch
if @suspended
@suspended = @net.resume
else
@suspended = @net.main
end
end
def handle_connection_close # XXX - we should raise an error when disconnected prematurely
@transcript_writer.server_close("connection closed") if @transcript_writer
self.exit
end
def handle_connect
@transcript_writer.server_open(*@conn.remote_address) if @transcript_writer
init_term
end
def transcribe_connect_error(e)
if @transcript_writer
@transcript_writer.info("Connect error", e.class.name, e.to_s, e.backtrace.join("\n"))
# Write the backtrace out as separate records, for the convenience of people reading the logs without a parser.
e.backtrace.each do |line|
@transcript_writer.info("Connect error backtrace", line)
end
end
end
def handle_receive_bytes(bytes)
@transcript_writer.from_server(bytes) if @transcript_writer
@match_buffer << bytes
@term.feed_bytes(bytes)
check_expect_match
end
# Check for a match.
#
# If there is a (non-background) match, set @wait_finished and return true. Otherwise, return false.
def check_expect_match
found = true
while found
found = false
@effective_patterns.each { |ph|
case ph.pattern
when Regexp
m = ph.pattern.match(@match_buffer)
@match_buffer = @match_buffer[m.end(0)..-1] if m # truncate match buffer
when ScreenPattern
m = ph.pattern.match_term(@term)
+ @match_buffer = "" if m # truncate match buffer if a screen matches
else
raise "BUG: pattern is #{ph.pattern.inspect}"
end
next unless m
# Matched - Invoke the callback
ph.callback.call(m) if ph.callback
# Make the next wait() call return
unless ph.background?
@wait_finished = true
@net.suspend
return true
else
found = true
end
}
end
false
end
class Evaluator
def initialize(expect_object)
@_expect_object = expect_object
end
# Define proxy methods
EXPORTED_METHODS.each do |m|
# We would use define_method, but JRuby 1.4 doesn't support defining
# a block that takes a block. http://jira.codehaus.org/browse/JRUBY-4180
class_eval("def #{m}(*args, &block) @_expect_object.__send__(#{m.inspect}, *args, &block); end")
end
end
class PatternHandle
attr_reader :pattern
attr_reader :callback
def initialize(pattern, callback, background)
@pattern = pattern
@callback = callback
@background = background
end
def background?
@background
end
end
class Match
attr_reader :pattern_handle
attr_reader :result
def initialize(pattern_handle, result)
@pattern_handle = pattern_handle
@result = result
end
end
end
end
|
infonium/scriptty
|
19306c0a28b555e08edc61c6e18f091da05e227b
|
TranscriptParseApp - Add --client option (this may be removed in the future)
|
diff --git a/lib/scriptty/apps/transcript_parse_app.rb b/lib/scriptty/apps/transcript_parse_app.rb
index 274c9e7..0b6e274 100644
--- a/lib/scriptty/apps/transcript_parse_app.rb
+++ b/lib/scriptty/apps/transcript_parse_app.rb
@@ -1,110 +1,143 @@
# = Transcript parsing app
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'optparse'
require 'scriptty/term'
require 'scriptty/util/transcript/reader'
require 'scriptty/util/transcript/writer'
module ScripTTY
module Apps
class TranscriptParseApp
def initialize(argv)
@options = parse_options(argv)
end
def main
File.open(@options[:output], "w") do |output_file|
@writer = ScripTTY::Util::Transcript::Writer.new(output_file)
@options[:input_files].each do |input_filename|
File.open(input_filename, "rb") do |input_file|
reader = ScripTTY::Util::Transcript::Reader.new
@last_printable = nil
parser_class = ScripTTY::Term.class_by_name(@options[:term]).parser_class
- @parser = parser_class.new :callback => Proc.new { |event_name, fsm|
+
+ # Set up server-side FSM
+ @server_parser = parser_class.new :callback => Proc.new { |event_name, fsm|
if event_name == :t_printable
# Merge printable character sequences together, rather than writing individual "t_printable" events.
- @last_printable ||= ""
- @last_printable += fsm.input_sequence.join
+ @last_server_printable ||= ""
+ @last_server_printable += fsm.input_sequence.join
else
- flush_printable
+ flush_server_printable
@writer.server_parsed(event_name, fsm.input_sequence.join)
end
}
- @parser.on_unknown_sequence { |seq| @writer.server_parsed("?", seq) }
+ @server_parser.on_unknown_sequence { |seq| @writer.server_parsed("?", seq) }
+
+ # Set up client-side FSM
+ if @options[:client]
+ @client_parser = parser_class.new :client => true, :callback => Proc.new { |event_name, fsm|
+ if event_name == :t_printable
+ # Merge printable character sequences together, rather than writing individual "t_printable" events.
+ @last_client_printable ||= ""
+ @last_client_printable += fsm.input_sequence.join
+ else
+ flush_client_printable
+ @writer.client_parsed(event_name, fsm.input_sequence.join)
+ end
+ }
+ @client_parser.on_unknown_sequence { |seq| @writer.client_parsed("?", seq) }
+ end
+
until input_file.eof?
timestamp, type, args = reader.parse_line(input_file.readline)
@writer.override_timestamp = timestamp
if type == :from_server
@writer.send(type, *args) if @options[:keep]
bytes = args[0]
- @parser.feed_bytes(bytes)
+ @server_parser.feed_bytes(bytes)
+ elsif type == :from_client and @client_parser
+ @writer.send(type, *args) if @options[:keep]
+ bytes = args[0]
+ @client_parser.feed_bytes(bytes)
else
@writer.send(type, *args)
end
end
- flush_printable
+ flush_server_printable
+ flush_client_printable if @client_parser
end
end
@writer.close
end
end
private
- def flush_printable
- if @last_printable
- @writer.server_parsed(".", @last_printable)
- @last_printable = nil
+ def flush_server_printable
+ if @last_server_printable
+ @writer.server_parsed(".", @last_server_printable)
+ @last_server_printable = nil
+ end
+ end
+
+ def flush_client_printable
+ if @last_client_printable
+ @writer.client_parsed(".", @last_client_printable)
+ @last_client_printable = nil
end
end
def parse_options(argv)
args = argv.dup
options = {:input_files => []}
opts = OptionParser.new do |opts|
opts.banner = "Usage: #{opts.program_name} [options] FILE..."
opts.separator "Parse transcript escape sequences according to a specified terminal emulation,"
opts.separator 'converting raw "S" transcript entries into parsed "Sp" entries.'
opts.on("-t", "--term NAME", "Terminal to emulate") do |optarg|
raise ArgumentError.new("Unsupported terminal #{optarg.inspect}") unless ScripTTY::Term::TERMINAL_TYPES.include?(optarg)
options[:term] = optarg
end
opts.on("-k", "--keep", 'Keep original "S" lines in the transcript') do |optarg|
options[:keep] = optarg
end
+ opts.on("-c", "--[no-]client", "Also parse client (\"C\") entries") do |optarg|
+ options[:client] = optarg
+ end
opts.on("-o", "--output FILE", "Write output to FILE") do |optarg|
options[:output] = optarg
end
end
opts.parse!(args)
if args.length < 1
$stderr.puts "error: No input file(s) specified."
exit 1
end
unless options[:output] and options[:term]
$stderr.puts "error: --output and --term are mandatory"
exit 1
end
options[:input_files] = args
options
end
end
end
end
diff --git a/lib/scriptty/term/dg410/dg410-client-escapes.txt b/lib/scriptty/term/dg410/dg410-client-escapes.txt
new file mode 100644
index 0000000..2b23342
--- /dev/null
+++ b/lib/scriptty/term/dg410/dg410-client-escapes.txt
@@ -0,0 +1,37 @@
+'\006' => t_client_ack
+'\012' => t_new_line
+'\015' => t_carriage_return
+'\036' => {
+ 'o' => {
+ '#' => {
+ '*' => {
+ * => {
+ * => t_client_response_read_model_id
+ }
+ }
+ }
+ }
+}
+'\037' => {
+ * => {
+ * => t_client_response_read_window_address
+ }
+}
+'\377' => {
+ '\372' => t_parse_telnet_sb => {
+ * => t_telnet_subnegotiation
+ }
+ '\373' => {
+ * => t_telnet_will
+ }
+ '\374' => {
+ * => t_telnet_wont
+ }
+ '\375' => {
+ * => t_telnet_do
+ }
+ '\376' => {
+ * => t_telnet_dont
+ }
+}
+[\x20-\x7e] => t_printable
diff --git a/lib/scriptty/term/dg410/parser.rb b/lib/scriptty/term/dg410/parser.rb
index 3ff0a1f..2de37ab 100644
--- a/lib/scriptty/term/dg410/parser.rb
+++ b/lib/scriptty/term/dg410/parser.rb
@@ -1,160 +1,162 @@
# = Parser for DG410 terminal
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/term/dg410'
module ScripTTY # :nodoc:
module Term
class DG410 # reopen
class Parser
- PARSER_DEFINITION = File.read(File.join(File.dirname(__FILE__), "dg410-escapes.txt"))
+ SERVER_PARSER_DEFINITION = File.read(File.join(File.dirname(__FILE__), "dg410-escapes.txt"))
+ CLIENT_PARSER_DEFINITION = File.read(File.join(File.dirname(__FILE__), "dg410-client-escapes.txt"))
# ScripTTY::Util::FSM object used by this parser. (Used for debugging.)
attr_reader :fsm
def initialize(options={})
- @fsm = Util::FSM.new(:definition => PARSER_DEFINITION,
+ @fsm = Util::FSM.new(
+ :definition => options[:client] ? CLIENT_PARSER_DEFINITION : SERVER_PARSER_DEFINITION,
:callback => self, :callback_method => :handle_event)
@callback = options[:callback]
@callback_method = options[:callback_method] || :call
on_unknown_sequence :error
end
# Set the behaviour of the terminal when an unknown escape sequence is
# found.
#
# This method takes either a symbol or a block.
#
# When a block is given, it is executed whenever an unknown escape
# sequence is received. The block is passed the escape sequence as a
# single string.
#
# When a symbol is given, it may be one of the following:
# [:error]
# (default) Raise a ScripTTY::Util::FSM::NoMatch exception.
# [:ignore]
# Ignore the unknown escape sequence.
def on_unknown_sequence(mode=nil, &block)
if !block and !mode
raise ArgumentError.new("No mode specified and no block given")
elsif block and mode
raise ArgumentError.new("Block and mode are mutually exclusive, but both were given")
elsif block
@on_unknown_sequence = block
elsif [:error, :ignore].include?(mode)
@on_unknown_sequence = mode
else
raise ArgumentError.new("Invalid mode #{mode.inspect}")
end
end
# Feed the specified byte to the terminal. Returns a string of
# bytes that should be transmitted (e.g. for TELNET negotiation).
def feed_byte(byte)
raise ArgumentError.new("input should be single byte") unless byte.is_a?(String) and byte.length == 1
begin
@fsm.process(byte)
rescue Util::FSM::NoMatch => e
@fsm.reset!
if @on_unknown_sequence == :error
raise
elsif @on_unknown_sequence == :ignore
# do nothing
elsif !@on_unknown_sequence.is_a?(Symbol) # @on_unknown_sequence is a Proc
@on_unknown_sequence.call(e.input_sequence.join)
else
raise "BUG"
end
end
""
end
# Convenience method: Feeds several bytes to the terminal. Returns a
# string of bytes that should be transmitted (e.g. for TELNET
# negotiation).
def feed_bytes(bytes)
retvals = []
bytes.split(//n).each do |byte|
retvals << feed_byte(byte)
end
retvals.join
end
private
def handle_event(event, fsm)
if respond_to?(event, true)
send(event, fsm)
else
@callback.__send__(@callback_method, event, fsm) if @callback
end
end
# Parse proprietary escape code, and fire the :t_proprietary_escape
# event when finished.
def t_parse_proprietary_escape(fsm)
state = 0
length = nil
header_length = 5
fsm.redirect = lambda {|fsm|
if fsm.input_sequence.length == header_length
length = fsm.input.unpack("C*")[0]
end
if length && fsm.input_sequence.length >= header_length + length
fsm.redirect = nil
fsm.fire_event(:t_proprietary_escape)
end
true
}
end
# IAC SB ... SE
def t_parse_telnet_sb(fsm)
# limit subnegotiation to 100 chars # FIXME - This is wrong
count = 0
fsm.redirect = lambda {|fsm| count += 1; count < 100 && fsm.input_sequence[-2..-1] != ["\377", "\360"]}
end
# Parse ANSI/DEC CSI escape sequence parameters. Pass in fsm.input_sequence
#
# Example:
# parse_csi_params("\e[H") # returns []
# parse_csi_params("\e[;H") # returns []
# parse_csi_params("\e[2J") # returns [2]
# parse_csi_params("\e[33;42;0m") # returns [33, 42, 0]
# parse_csi_params(["\e", "[", "3", "3", ";", "4" "2", ";" "0", "m"]) # same as above, but takes an array
#
# This also works with DEC escape sequences:
# parse_csi_params("\e[?1;2J") # returns [1,2]
def parse_csi_params(input_seq) # TODO - test this
seq = input_seq.join if input_seq.respond_to?(:join) # Convert array to string
unless seq =~ /\A\e\[\??([\d;]*)[^\d]\Z/n
raise "BUG"
end
$1.split(/;/n).map{|p|
if p.empty?
nil
else
p.to_i
end
}
end
end
end
end
end
|
infonium/scriptty
|
2852be9fef688908456c7d566c6160eefe77aabf
|
ScripTTY::Term::DG410 - Add on_proprietary_escape callback support
|
diff --git a/lib/scriptty/term/dg410.rb b/lib/scriptty/term/dg410.rb
index f994a46..10ff5df 100644
--- a/lib/scriptty/term/dg410.rb
+++ b/lib/scriptty/term/dg410.rb
@@ -1,476 +1,489 @@
# = DG410 terminal emulation
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
# XXX TODO - deduplicate between this and xterm.rb
require 'scriptty/multiline_buffer'
require 'scriptty/cursor'
require 'scriptty/util/fsm'
require 'set'
module ScripTTY # :nodoc:
module Term
class DG410
require 'scriptty/term/dg410/parser' # we want to create the DG410 class here before parser.rb reopens it
DEFAULT_FLAGS = {
:insert_mode => false,
:wraparound_mode => false,
:roll_mode => true, # scroll up when the cursor moves beyond the bottom
}.freeze
# width and height of the display buffer
attr_reader :width, :height
# Return ScripTTY::Term::DG410::Parser
def self.parser_class
Parser
end
def initialize(height=24, width=80)
@parser = self.class.parser_class.new(:callback => self, :callback_method => :send)
@height = height
@width = width
+ @proprietary_escape_callback = nil
+
reset_to_initial_state!
end
def on_unknown_sequence(mode=nil, &block)
@parser.on_unknown_sequence(mode, &block)
end
+ def on_proprietary_escape(mode=nil, &block)
+ if mode == :ignore and !block
+ @proprietary_escape_callback = nil
+ elsif !mode and block
+ @proprietary_escape_callback = block
+ else
+ raise ArgumentError.new("mode and block are mutually exclusive")
+ end
+ nil
+ end
+
def feed_bytes(bytes)
@parser.feed_bytes(bytes)
end
def feed_byte(byte)
@parser.feed_byte(byte)
end
# Return an array of lines of text representing the state of the terminal.
# Used for debugging.
def debug_info
output = []
output << "state:#{@parser.fsm.state.inspect} seq:#{@parser.fsm.input_sequence && @parser.fsm.input_sequence.join.inspect}"
output << "scrolling_region: #{@scrolling_region.inspect}"
output << "flags: roll:#{@flags[:roll_mode]} wraparound:#{@flags[:wraparound_mode]} insert:#{@flags[:insert_mode]}"
output
end
def inspect # :nodoc:
# The default inspect method shows way too much information. Simplify it.
"#<#{self.class.name}:#{sprintf('0x%0x', object_id)} h=#{@height.inspect} w=#{@width.inspect} cursor=#{cursor_pos.inspect}>"
end
# Return an array of strings representing the lines of text on the screen
#
# NOTE: If passing copy=false, do not modify the return value or the strings inside it.
def text(copy=true)
if copy
@glyphs.content.map{|line| line.dup}
else
@glyphs.content
end
end
# Return the cursor position, as an array of [row, column].
#
# [0,0] represents the topmost, leftmost position.
def cursor_pos
[@cursor.row, @cursor.column]
end
# Set the cursor position to [row, column].
#
# [0,0] represents the topmost, leftmost position.
def cursor_pos=(v)
@cursor.pos = v
end
# Replace the text on the screen with the specified text.
#
# NOTE: This is API is very likely to change in the future.
def text=(a)
@glyphs.clear!
@glyphs.replace_at(0, 0, a)
a
end
protected
# Reset to the initial state. Return true.
def reset_to_initial_state!
@flags = DEFAULT_FLAGS.dup
# current cursor position
@cursor = Cursor.new
@cursor.row = @cursor.column = 0
@saved_cursor_position = [0,0]
# Screen buffer
@glyphs = MultilineBuffer.new(@height, @width) # the displayable characters (as bytes)
@attrs = MultilineBuffer.new(@height, @width) # character attributes (as bytes)
# Vertical scrolling region. An array of [start_row, end_row]. Defaults to [0, height-1].
@scrolling_region = [0, @height-1]
true
end
# Replace the character under the cursor with the specified character.
#
# If curfwd is true, the cursor is also moved forward.
#
# Returns true.
def put_char!(input, curfwd=false)
raise TypeError.new("input must be single-character string") unless input.is_a?(String) and input.length == 1
@glyphs.replace_at(@cursor.row, @cursor.column, input)
@attrs.replace_at(@cursor.row, @cursor.column, " ")
cursor_forward! if curfwd
true
end
# Move the cursor to the leftmost column in the current row, then return true.
def carriage_return!
@cursor.column = 0
true
end
# Move the cursor down one row and return true.
#
# If the cursor is on the bottom row of the vertical scrolling region,
# the region is scrolled. If bot, but the cursor is on the bottom of
# the screen, this command has no effect.
def line_feed!
if @cursor.row == @scrolling_region[1] # cursor is on the bottom row of the scrolling region
if @flags[:roll_enable]
scroll_up!
else
@cursor.row = @scrolling_region[0]
end
elsif @cursor.row >= @height-1
# do nothing
else
cursor_down!
end
true
end
# Save the cursor position. Return true.
def save_cursor!
@saved_cursor_position = [@cursor.row, @cursor.column]
true
end
# Restore the saved cursor position. If nothing has been saved, then go to the home position. Return true.
def restore_cursor!
@cursor.row, @cursor.column = @saved_cursor_position
true
end
# Move the cursor down one row and return true.
# If the cursor is on the bottom row, return false without moving the cursor.
def cursor_down!
if @cursor.row >= @height-1
false
else
@cursor.row += 1
true
end
end
# Move the cursor up one row and return true.
# If the cursor is on the top row, return false without moving the cursor.
def cursor_up!
if @cursor.row <= 0
false
else
@cursor.row -= 1
true
end
end
# Move the cursor right one column and return true.
# If the cursor is on the right-most column, return false without moving the cursor.
def cursor_right!
if @cursor.column >= @width-1
false
else
@cursor.column += 1
true
end
end
# Move the cursor to the right. Wrap around if we reach the end of the screen.
#
# Return true.
def cursor_forward!(options={})
if @cursor.column >= @width-1
line_feed!
carriage_return!
else
cursor_right!
end
end
# Move the cursor left one column and return true.
# If the cursor is on the left-most column, return false without moving the cursor.
def cursor_left!
if @cursor.column <= 0
false
else
@cursor.column -= 1
true
end
end
alias cursor_back! cursor_left! # In the future, this might not be an alias
# Scroll the contents of the screen up by one row and return true.
# The position of the cursor does not change.
def scroll_up!
@glyphs.scroll_up_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
@attrs.scroll_up_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
true
end
# Scroll the contents of the screen down by one row and return true.
# The position of the cursor does not change.
def scroll_down!
@glyphs.scroll_down_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
@attrs.scroll_down_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
true
end
# Erase, starting with the character under the cursor and extending to the end of the line.
# Return true.
def erase_to_end_of_line!
@glyphs.replace_at(@cursor.row, @cursor.column, " "*(@[email protected]))
@attrs.replace_at(@cursor.row, @cursor.column, " "*(@[email protected]))
true
end
# Erase, starting with the beginning of the line and extending to the character under the cursor.
# Return true.
def erase_to_start_of_line!
@glyphs.replace_at(@cursor.row, 0, " "*(@cursor.column+1))
@attrs.replace_at(@cursor.row, 0, " "*(@cursor.column+1))
true
end
# Erase the current (or specified) line. The cursor position is unchanged.
# Return true.
def erase_line!(row=nil)
row = @cursor.row unless row
@glyphs.replace_at(row, 0, " "*@width)
@attrs.replace_at(row, 0, " "*@width)
true
end
# Erase the window. Return true.
def erase_window!
empty_line = " "*@width
@height.times do |row|
@glyphs.replace_at(row, 0, empty_line)
@attrs.replace_at(row, 0, empty_line)
end
true
end
# Delete the specified number of lines, starting at the cursor position
# extending downwards. The lines below the deleted lines are scrolled up,
# and blank lines are inserted below them.
# Return true.
def delete_lines!(count=1)
@glyphs.scroll_up_region(@cursor.row, 0, @height-1, @width-1, count)
@attrs.scroll_up_region(@cursor.row, 0, @height-1, @width-1, count)
true
end
# Delete the specified number of characters, starting at the cursor position
# extending to the end of the line. The characters to the right of the
# cursor are scrolled left, and blanks are inserted after them.
# Return true.
def delete_characters!(count=1)
@glyphs.scroll_left_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
@attrs.scroll_left_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
true
end
# Insert the specified number of blank characters at the cursor position.
# The characters to the right of the cursor are scrolled right, and blanks
# are inserted in their place.
# Return true.
def insert_blank_characters!(count=1)
@glyphs.scroll_right_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
@attrs.scroll_right_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
true
end
# Insert the specified number of lines characters at the cursor position.
# The characters to the below the cursor are scrolled down, and blank
# lines are inserted in their place.
# Return true.
def insert_blank_lines!(count=1)
@glyphs.scroll_down_region(@cursor.row, 0, @height-1, @width-1, count)
@attrs.scroll_down_region(@cursor.row, 0, @height-1, @width-1, count)
true
end
private
# Set the vertical scrolling region.
#
# Values will be clipped.
def set_scrolling_region!(top, bottom)
@scrolling_region[0] = [0, [@height-1, top].min].max
@scrolling_region[1] = [0, [@width-1, bottom].min].max
nil
end
def error(message) # XXX - This sucks
raise ArgumentError.new(message)
#puts message # DEBUG FIXME
end
def t_reset(fsm)
reset_to_initial_state!
end
# Printable character
def t_printable(fsm) # :nodoc:
insert_blank_characters! if @flags[:insert_mode] # TODO
put_char!(fsm.input)
cursor_forward!
end
# Move the cursor to the left margin on the current row.
def t_carriage_return(fsm)
carriage_return!
end
# Move the cursor to the left margin on the next row.
def t_new_line(fsm)
carriage_return!
line_feed!
end
# Move cursor to the top-left cell of the window.
def t_window_home(fsm)
@cursor.pos = [0,0]
end
# Erase all characters starting at the cursor and extending to the end of the window.
def t_erase_unprotected(fsm)
# Erase to the end of the current line
erase_to_end_of_line!
# Erase subsequent lines to the end of the window.
(@cursor.row+1..@height-1).each do |row|
erase_line!(row)
end
end
# Erase all characters starting at the cursor and extending to the end of the line.
def t_erase_end_of_line(fsm)
erase_to_end_of_line!
end
# Move the cursor to the specified position within the window.
# <020> <column> <row>
def t_write_window_address(fsm)
column, row = fsm.input_sequence[1,2].join.unpack("C*")
row = @cursor.row if row == 0177 # 0177 == special case: do not change the row
column = @cursor.column if column == 0177 # 0177 == special case: do not change the column
column = @width-1 if column > @width-1
row = @height-1 if row > @height-1
@cursor.pos = [row, column]
end
# Erase all characters in the current window, and move the cursor to
# the top-left cell of the window.
def t_erase_window(fsm)
erase_window!
@cursor.pos = [0,0]
end
def t_cursor_up(fsm)
cursor_up!
end
def t_cursor_down(fsm)
cursor_down!
end
def t_cursor_right(fsm)
cursor_right!
end
def t_cursor_left(fsm)
cursor_left!
end
# ESC ] ... M
# XXX - What is this?
def t_osc_m(fsm) end # TODO
def t_osc_k(fsm) end # TODO
def t_roll_enable(fsm)
@flags[:roll_mode] = true
end
def t_roll_disable(fsm)
@flags[:roll_mode] = false
end
def t_print_window(fsm) end # TODO
def t_bell(fsm) end # TODO
def t_blink_enable(fsm) end # TODO
def t_blink_disable(fsm) end # TODO
def t_underscore_on(fsm) end # TODO
def t_underscore_off(fsm) end # TODO
def t_blink_on(fsm) end # TODO
def t_blink_off(fsm) end # TODO
def t_reverse_video_on(fsm) end # TODO
def t_reverse_video_off(fsm) end # TODO
def t_dim_on(fsm) end # TODO
def t_dim_off(fsm) end # TODO
def t_set_cursor_type(fsm) end # TODO
def t_telnet_will(fsm) end # TODO
def t_telnet_wont(fsm) end # TODO
def t_telnet_do(fsm) end # TODO
def t_telnet_dont(fsm) end # TODO
def t_telnet_subnegotiation(fsm) end # TODO
# Proprietary escape code
# <036> ~ <2-byte-command> <n> <n*bytes>
def t_proprietary_escape(fsm)
command = fsm.input_sequence[3,2].join
payload = fsm.input_sequence[5..-1].join
- #puts "PROPRIETARY ESCAPE: command=#{command.inspect} payload=#{payload.inspect}" # DEBUG FIXME
+ @proprietary_escape_callback.call(command, payload) if @proprietary_escape_callback
end
# Acknowledgement of proprietary escape sequence.
# From the server to the client, this is just a single-character ACK
def t_proprietary_ack(fsm) end # TODO
end
end
end
|
infonium/scriptty
|
925dc7ad6a2dca1b70bb5057d3787879640d677c
|
ScripTTY::Expect - Handle connect errors
|
diff --git a/lib/scriptty/exception.rb b/lib/scriptty/exception.rb
index c22a915..41c1943 100644
--- a/lib/scriptty/exception.rb
+++ b/lib/scriptty/exception.rb
@@ -1,29 +1,38 @@
# = ScripTTY exceptions
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
module ScripTTY
module Exception
# Exception base class
class Base < StandardError
end
# Raised when a script times out.
class Timeout < Base
end
+
+ # Raised when a connection error occurs
+ class ConnectError < Base
+ attr_accessor :orig_exception
+ def initialize(exception)
+ @orig_exception = exception
+ super("Connect error (#{exception.class.name}): #{exception}")
+ end
+ end
end
end
diff --git a/lib/scriptty/expect.rb b/lib/scriptty/expect.rb
index d0ff88d..043d1ba 100644
--- a/lib/scriptty/expect.rb
+++ b/lib/scriptty/expect.rb
@@ -1,358 +1,371 @@
# = Expect object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/exception'
require 'scriptty/net/event_loop'
require 'scriptty/term'
require 'scriptty/screen_pattern'
require 'scriptty/util/transcript/writer'
require 'set'
module ScripTTY
class Expect
# Methods to export to Evaluator
EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout ]
attr_reader :term # The terminal emulation object
attr_accessor :transcript_writer # Set this to an instance of ScripTTY::Util::Transcript::Writer
# Initialize the Expect object.
def initialize(options={})
@net = ScripTTY::Net::EventLoop.new
@suspended = false
@effective_patterns = nil
@term_name = nil
@effective_patterns = [] # Array of PatternHandle objects
@pattern_stack = []
@wait_finished = false
@evaluator = Evaluator.new(self)
@match_buffer = ""
@timeout = nil
@timeout_timer = nil
@transcript_writer = options[:transcript_writer]
end
def set_timeout(seconds)
raise ArgumentError.new("argument to set_timeout must be Numeric or nil") unless seconds.is_a?(Numeric) or seconds.nil?
if seconds
@timeout = seconds.to_f
else
@timeout = nil
end
refresh_timeout
nil
end
# Load and evaluate a script from a file.
def eval_script_file(path)
eval_script_inline(File.read(path), path)
end
# Evaluate a script specified as a string.
def eval_script_inline(str, filename=nil, lineno=nil)
@evaluator.instance_eval(str, filename || "(inline)", lineno || 1)
end
# Initialize a terminal emulator.
#
# If a name is specified, use that terminal type. Otherwise, use the
# previous terminal type.
def init_term(name=nil)
@transcript_writer.info("Script executing command", "init_term", name || "") if @transcript_writer
name ||= @term_name
@term_name = name
raise ArgumentError.new("No previous terminal specified") unless name
without_timeout {
@term = ScripTTY::Term.new(name)
@term.on_unknown_sequence do |seq|
@transcript_writer.info("Unknown escape sequence", seq) if @transcript_writer
end
}
nil
end
# Connect to the specified address. Return true if the connection was
# successful. Otherwise, raise an exception.
def connect(remote_address)
@transcript_writer.info("Script executing command", "connect", *remote_address.map{|a| a.inspect}) if @transcript_writer
connected = false
connect_error = nil
@conn = @net.connect(remote_address) do |c|
c.on_connect { connected = true; handle_connect; @net.suspend }
- c.on_connect_error { |e| handle_connect_error(e) }
+ c.on_connect_error { |e| connect_error = e; @net.suspend }
c.on_receive_bytes { |bytes| handle_receive_bytes(bytes) }
c.on_close { @conn = nil; handle_connection_close }
end
dispatch until connected or connect_error or @net.done?
- raise connect_error if !connected or connect_error or @net.done? # XXX - this is sloppy
+ if connect_error
+ transcribe_connect_error(connect_error)
+ raise ScripTTY::Exception::ConnectError.new(connect_error)
+ end
refresh_timeout
connected
end
# Add the specified pattern to the effective pattern list.
#
# Return the PatternHandle for the pattern.
#
# Options:
# [:continue]
# If true, matching this pattern will not cause the wait method to
# return.
def on(pattern, opts={}, &block)
case pattern
when String
@transcript_writer.info("Script executing command", "on", "String", pattern.inspect) if @transcript_writer
ph = PatternHandle.new(/#{Regexp.escape(pattern)}/n, block, opts[:background])
when Regexp
@transcript_writer.info("Script executing command", "on", "Regexp", pattern.inspect) if @transcript_writer
if pattern.kcode == "none"
ph = PatternHandle.new(pattern, block, opts[:background])
else
ph = PatternHandle.new(/#{pattern}/n, block, opts[:background])
end
when ScreenPattern
@transcript_writer.info("Script executing command", "on", "ScreenPattern", pattern.name, opts[:background] ? "BACKGROUND" : "") if @transcript_writer
ph = PatternHandle(pattern, block, opts[:background])
else
raise TypeError.new("Unsupported pattern type: #{pattern.class.inspect}")
end
@effective_patterns << ph
ph
end
# Sleep for the specified number of seconds
def sleep(seconds)
@transcript_writer.info("Script executing command", "sleep", seconds.inspect) if @transcript_writer
sleep_done = false
@net.timer(seconds) { sleep_done = true ; @net.suspend }
dispatch until sleep_done
refresh_timeout
nil
end
# Return the named ScreenPattern
# XXX TODO
def screen(name)
end
# Convenience function.
#
# == Examples
# # Wait for a single pattern to match.
# expect("login: ")
#
# # Wait for one of several patterns to match.
# expect {
# on("login successful") { ... }
# on("login incorrect") { ... }
# }
def expect(pattern=nil)
raise ArgumentError.new("no pattern and no block given") if !pattern and !block_given?
@transcript_writer.info("Script expect block BEGIN") if @transcript_writer and block_given?
push_patterns
begin
on(pattern) if pattern
yield if block_given?
wait
ensure
pop_patterns
@transcript_writer.info("Script expect block END") if @transcript_writer and block_given?
end
end
# Push a copy of the effective pattern list to an internal stack.
def push_patterns
@pattern_stack << @effective_patterns.dup
end
# Pop the effective pattern list from the stack.
def pop_patterns
raise ArgumentError.new("pattern stack empty") if @pattern_stack.empty?
@effective_patterns = @pattern_stack.pop
end
# Wait for an effective pattern to match.
#
# Clears the character-match buffer on return.
def wait
@transcript_writer.info("Script executing command", "wait") if @transcript_writer
dispatch until @wait_finished
refresh_timeout
@wait_finished = false
@match_buffer = ""
nil
end
# Send bytes to the remote application.
#
# NOTE: This method returns immediately, even if not all the bytes are
# finished being sent. Remaining bytes will be sent during an expect,
# wait, or sleep call.
def send(bytes)
@transcript_writer.from_client(bytes) if @transcript_writer
@conn.write(bytes)
true
end
# Close the connection and exit.
def exit
@transcript_writer.info("Script executing command", "exit") if @transcript_writer
@net.exit
dispatch until @net.done?
@transcript_writer.close if @transcript_writer
end
private
# Kick the watchdog timer
def refresh_timeout
disable_timeout
enable_timeout
end
def without_timeout
raise ArgumentError.new("no block given") unless block_given?
disable_timeout
begin
yield
ensure
enable_timeout
end
end
# Disable timeout handling
def disable_timeout
if @timeout_timer
@timeout_timer.cancel
@timeout_timer = nil
end
nil
end
# Enable timeout handling (if @timeout is set)
def enable_timeout
if @timeout
@timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
end
nil
end
# Re-enter the dispatch loop
def dispatch
if @suspended
@suspended = @net.resume
else
@suspended = @net.main
end
end
def handle_connection_close # XXX - we should raise an error when disconnected prematurely
@transcript_writer.server_close("connection closed") if @transcript_writer
self.exit
end
def handle_connect
@transcript_writer.server_open(*@conn.remote_address) if @transcript_writer
init_term
end
+ def transcribe_connect_error(e)
+ if @transcript_writer
+ @transcript_writer.info("Connect error", e.class.name, e.to_s, e.backtrace.join("\n"))
+ # Write the backtrace out as separate records, for the convenience of people reading the logs without a parser.
+ e.backtrace.each do |line|
+ @transcript_writer.info("Connect error backtrace", line)
+ end
+ end
+ end
+
def handle_receive_bytes(bytes)
@transcript_writer.from_server(bytes) if @transcript_writer
@match_buffer << bytes
@term.feed_bytes(bytes)
check_expect_match
end
# Check for a match.
#
# If there is a (non-background) match, set @wait_finished and return true. Otherwise, return false.
def check_expect_match
found = true
while found
found = false
@effective_patterns.each { |ph|
case ph.pattern
when Regexp
m = ph.pattern.match(@match_buffer)
@match_buffer = @match_buffer[m.end(0)..-1] if m # truncate match buffer
when ScreenPattern
m = ph.pattern.match_term(@term)
else
raise "BUG: pattern is #{ph.pattern.inspect}"
end
next unless m
# Matched - Invoke the callback
ph.callback.call(m) if ph.callback
# Make the next wait() call return
unless ph.background?
@wait_finished = true
@net.suspend
return true
else
found = true
end
}
end
false
end
class Evaluator
def initialize(expect_object)
@_expect_object = expect_object
end
# Define proxy methods
EXPORTED_METHODS.each do |m|
# We would use define_method, but JRuby 1.4 doesn't support defining
# a block that takes a block. http://jira.codehaus.org/browse/JRUBY-4180
class_eval("def #{m}(*args, &block) @_expect_object.__send__(#{m.inspect}, *args, &block); end")
end
end
class PatternHandle
attr_reader :pattern
attr_reader :callback
def initialize(pattern, callback, background)
@pattern = pattern
@callback = callback
@background = background
end
def background?
@background
end
end
class Match
attr_reader :pattern_handle
attr_reader :result
def initialize(pattern_handle, result)
@pattern_handle = pattern_handle
@result = result
end
end
end
end
|
infonium/scriptty
|
7d42ca0c18048272577f2de800e7da3fb5fa2257
|
ScripTTY::Expect - Add support for writing transcripts
|
diff --git a/lib/scriptty/expect.rb b/lib/scriptty/expect.rb
index 4da1dc1..d0ff88d 100644
--- a/lib/scriptty/expect.rb
+++ b/lib/scriptty/expect.rb
@@ -1,337 +1,358 @@
# = Expect object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/exception'
require 'scriptty/net/event_loop'
require 'scriptty/term'
require 'scriptty/screen_pattern'
+require 'scriptty/util/transcript/writer'
require 'set'
module ScripTTY
class Expect
# Methods to export to Evaluator
EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout ]
attr_reader :term # The terminal emulation object
+ attr_accessor :transcript_writer # Set this to an instance of ScripTTY::Util::Transcript::Writer
+
# Initialize the Expect object.
- def initialize
+ def initialize(options={})
@net = ScripTTY::Net::EventLoop.new
@suspended = false
@effective_patterns = nil
@term_name = nil
@effective_patterns = [] # Array of PatternHandle objects
@pattern_stack = []
@wait_finished = false
@evaluator = Evaluator.new(self)
@match_buffer = ""
@timeout = nil
@timeout_timer = nil
+ @transcript_writer = options[:transcript_writer]
end
def set_timeout(seconds)
raise ArgumentError.new("argument to set_timeout must be Numeric or nil") unless seconds.is_a?(Numeric) or seconds.nil?
if seconds
@timeout = seconds.to_f
else
@timeout = nil
end
refresh_timeout
nil
end
# Load and evaluate a script from a file.
def eval_script_file(path)
eval_script_inline(File.read(path), path)
end
# Evaluate a script specified as a string.
def eval_script_inline(str, filename=nil, lineno=nil)
@evaluator.instance_eval(str, filename || "(inline)", lineno || 1)
end
# Initialize a terminal emulator.
#
# If a name is specified, use that terminal type. Otherwise, use the
# previous terminal type.
def init_term(name=nil)
+ @transcript_writer.info("Script executing command", "init_term", name || "") if @transcript_writer
name ||= @term_name
@term_name = name
raise ArgumentError.new("No previous terminal specified") unless name
without_timeout {
@term = ScripTTY::Term.new(name)
- @term.on_unknown_sequence :ignore # XXX - Is this what we want?
+ @term.on_unknown_sequence do |seq|
+ @transcript_writer.info("Unknown escape sequence", seq) if @transcript_writer
+ end
}
nil
end
# Connect to the specified address. Return true if the connection was
# successful. Otherwise, raise an exception.
def connect(remote_address)
+ @transcript_writer.info("Script executing command", "connect", *remote_address.map{|a| a.inspect}) if @transcript_writer
connected = false
connect_error = nil
@conn = @net.connect(remote_address) do |c|
c.on_connect { connected = true; handle_connect; @net.suspend }
c.on_connect_error { |e| handle_connect_error(e) }
c.on_receive_bytes { |bytes| handle_receive_bytes(bytes) }
c.on_close { @conn = nil; handle_connection_close }
end
dispatch until connected or connect_error or @net.done?
raise connect_error if !connected or connect_error or @net.done? # XXX - this is sloppy
refresh_timeout
connected
end
# Add the specified pattern to the effective pattern list.
#
# Return the PatternHandle for the pattern.
#
# Options:
# [:continue]
# If true, matching this pattern will not cause the wait method to
# return.
def on(pattern, opts={}, &block)
case pattern
when String
+ @transcript_writer.info("Script executing command", "on", "String", pattern.inspect) if @transcript_writer
ph = PatternHandle.new(/#{Regexp.escape(pattern)}/n, block, opts[:background])
when Regexp
+ @transcript_writer.info("Script executing command", "on", "Regexp", pattern.inspect) if @transcript_writer
if pattern.kcode == "none"
ph = PatternHandle.new(pattern, block, opts[:background])
else
ph = PatternHandle.new(/#{pattern}/n, block, opts[:background])
end
when ScreenPattern
+ @transcript_writer.info("Script executing command", "on", "ScreenPattern", pattern.name, opts[:background] ? "BACKGROUND" : "") if @transcript_writer
ph = PatternHandle(pattern, block, opts[:background])
else
raise TypeError.new("Unsupported pattern type: #{pattern.class.inspect}")
end
@effective_patterns << ph
ph
end
# Sleep for the specified number of seconds
def sleep(seconds)
+ @transcript_writer.info("Script executing command", "sleep", seconds.inspect) if @transcript_writer
sleep_done = false
@net.timer(seconds) { sleep_done = true ; @net.suspend }
dispatch until sleep_done
refresh_timeout
nil
end
# Return the named ScreenPattern
# XXX TODO
def screen(name)
end
# Convenience function.
#
# == Examples
# # Wait for a single pattern to match.
# expect("login: ")
#
# # Wait for one of several patterns to match.
# expect {
# on("login successful") { ... }
# on("login incorrect") { ... }
# }
def expect(pattern=nil)
raise ArgumentError.new("no pattern and no block given") if !pattern and !block_given?
+ @transcript_writer.info("Script expect block BEGIN") if @transcript_writer and block_given?
push_patterns
begin
on(pattern) if pattern
yield if block_given?
wait
ensure
pop_patterns
+ @transcript_writer.info("Script expect block END") if @transcript_writer and block_given?
end
end
# Push a copy of the effective pattern list to an internal stack.
def push_patterns
@pattern_stack << @effective_patterns.dup
end
# Pop the effective pattern list from the stack.
def pop_patterns
raise ArgumentError.new("pattern stack empty") if @pattern_stack.empty?
@effective_patterns = @pattern_stack.pop
end
# Wait for an effective pattern to match.
#
# Clears the character-match buffer on return.
def wait
+ @transcript_writer.info("Script executing command", "wait") if @transcript_writer
dispatch until @wait_finished
refresh_timeout
@wait_finished = false
@match_buffer = ""
nil
end
# Send bytes to the remote application.
#
# NOTE: This method returns immediately, even if not all the bytes are
# finished being sent. Remaining bytes will be sent during an expect,
# wait, or sleep call.
def send(bytes)
+ @transcript_writer.from_client(bytes) if @transcript_writer
@conn.write(bytes)
true
end
# Close the connection and exit.
def exit
+ @transcript_writer.info("Script executing command", "exit") if @transcript_writer
@net.exit
dispatch until @net.done?
+ @transcript_writer.close if @transcript_writer
end
private
# Kick the watchdog timer
def refresh_timeout
disable_timeout
enable_timeout
end
def without_timeout
raise ArgumentError.new("no block given") unless block_given?
disable_timeout
begin
yield
ensure
enable_timeout
end
end
# Disable timeout handling
def disable_timeout
if @timeout_timer
@timeout_timer.cancel
@timeout_timer = nil
end
nil
end
# Enable timeout handling (if @timeout is set)
def enable_timeout
if @timeout
@timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
end
nil
end
# Re-enter the dispatch loop
def dispatch
if @suspended
@suspended = @net.resume
else
@suspended = @net.main
end
end
def handle_connection_close # XXX - we should raise an error when disconnected prematurely
+ @transcript_writer.server_close("connection closed") if @transcript_writer
self.exit
end
def handle_connect
+ @transcript_writer.server_open(*@conn.remote_address) if @transcript_writer
init_term
end
def handle_receive_bytes(bytes)
+ @transcript_writer.from_server(bytes) if @transcript_writer
@match_buffer << bytes
@term.feed_bytes(bytes)
check_expect_match
end
# Check for a match.
#
# If there is a (non-background) match, set @wait_finished and return true. Otherwise, return false.
def check_expect_match
found = true
while found
found = false
@effective_patterns.each { |ph|
case ph.pattern
when Regexp
m = ph.pattern.match(@match_buffer)
@match_buffer = @match_buffer[m.end(0)..-1] if m # truncate match buffer
when ScreenPattern
m = ph.pattern.match_term(@term)
else
raise "BUG: pattern is #{ph.pattern.inspect}"
end
next unless m
# Matched - Invoke the callback
ph.callback.call(m) if ph.callback
# Make the next wait() call return
unless ph.background?
@wait_finished = true
@net.suspend
return true
else
found = true
end
}
end
false
end
class Evaluator
def initialize(expect_object)
@_expect_object = expect_object
end
# Define proxy methods
EXPORTED_METHODS.each do |m|
# We would use define_method, but JRuby 1.4 doesn't support defining
# a block that takes a block. http://jira.codehaus.org/browse/JRUBY-4180
class_eval("def #{m}(*args, &block) @_expect_object.__send__(#{m.inspect}, *args, &block); end")
end
end
class PatternHandle
attr_reader :pattern
attr_reader :callback
def initialize(pattern, callback, background)
@pattern = pattern
@callback = callback
@background = background
end
def background?
@background
end
end
class Match
attr_reader :pattern_handle
attr_reader :result
def initialize(pattern_handle, result)
@pattern_handle = pattern_handle
@result = result
end
end
end
end
|
infonium/scriptty
|
324e5f38f14fa79414aed4949eb7c2cdf40e87d1
|
Term::DG410 - Add parsing for TELNET negotiation
|
diff --git a/lib/scriptty/term/dg410.rb b/lib/scriptty/term/dg410.rb
index a2760fc..f994a46 100644
--- a/lib/scriptty/term/dg410.rb
+++ b/lib/scriptty/term/dg410.rb
@@ -1,470 +1,476 @@
# = DG410 terminal emulation
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
# XXX TODO - deduplicate between this and xterm.rb
require 'scriptty/multiline_buffer'
require 'scriptty/cursor'
require 'scriptty/util/fsm'
require 'set'
module ScripTTY # :nodoc:
module Term
class DG410
require 'scriptty/term/dg410/parser' # we want to create the DG410 class here before parser.rb reopens it
DEFAULT_FLAGS = {
:insert_mode => false,
:wraparound_mode => false,
:roll_mode => true, # scroll up when the cursor moves beyond the bottom
}.freeze
# width and height of the display buffer
attr_reader :width, :height
# Return ScripTTY::Term::DG410::Parser
def self.parser_class
Parser
end
def initialize(height=24, width=80)
@parser = self.class.parser_class.new(:callback => self, :callback_method => :send)
@height = height
@width = width
reset_to_initial_state!
end
def on_unknown_sequence(mode=nil, &block)
@parser.on_unknown_sequence(mode, &block)
end
def feed_bytes(bytes)
@parser.feed_bytes(bytes)
end
def feed_byte(byte)
@parser.feed_byte(byte)
end
# Return an array of lines of text representing the state of the terminal.
# Used for debugging.
def debug_info
output = []
output << "state:#{@parser.fsm.state.inspect} seq:#{@parser.fsm.input_sequence && @parser.fsm.input_sequence.join.inspect}"
output << "scrolling_region: #{@scrolling_region.inspect}"
output << "flags: roll:#{@flags[:roll_mode]} wraparound:#{@flags[:wraparound_mode]} insert:#{@flags[:insert_mode]}"
output
end
def inspect # :nodoc:
# The default inspect method shows way too much information. Simplify it.
"#<#{self.class.name}:#{sprintf('0x%0x', object_id)} h=#{@height.inspect} w=#{@width.inspect} cursor=#{cursor_pos.inspect}>"
end
# Return an array of strings representing the lines of text on the screen
#
# NOTE: If passing copy=false, do not modify the return value or the strings inside it.
def text(copy=true)
if copy
@glyphs.content.map{|line| line.dup}
else
@glyphs.content
end
end
# Return the cursor position, as an array of [row, column].
#
# [0,0] represents the topmost, leftmost position.
def cursor_pos
[@cursor.row, @cursor.column]
end
# Set the cursor position to [row, column].
#
# [0,0] represents the topmost, leftmost position.
def cursor_pos=(v)
@cursor.pos = v
end
# Replace the text on the screen with the specified text.
#
# NOTE: This is API is very likely to change in the future.
def text=(a)
@glyphs.clear!
@glyphs.replace_at(0, 0, a)
a
end
protected
# Reset to the initial state. Return true.
def reset_to_initial_state!
@flags = DEFAULT_FLAGS.dup
# current cursor position
@cursor = Cursor.new
@cursor.row = @cursor.column = 0
@saved_cursor_position = [0,0]
# Screen buffer
@glyphs = MultilineBuffer.new(@height, @width) # the displayable characters (as bytes)
@attrs = MultilineBuffer.new(@height, @width) # character attributes (as bytes)
# Vertical scrolling region. An array of [start_row, end_row]. Defaults to [0, height-1].
@scrolling_region = [0, @height-1]
true
end
# Replace the character under the cursor with the specified character.
#
# If curfwd is true, the cursor is also moved forward.
#
# Returns true.
def put_char!(input, curfwd=false)
raise TypeError.new("input must be single-character string") unless input.is_a?(String) and input.length == 1
@glyphs.replace_at(@cursor.row, @cursor.column, input)
@attrs.replace_at(@cursor.row, @cursor.column, " ")
cursor_forward! if curfwd
true
end
# Move the cursor to the leftmost column in the current row, then return true.
def carriage_return!
@cursor.column = 0
true
end
# Move the cursor down one row and return true.
#
# If the cursor is on the bottom row of the vertical scrolling region,
# the region is scrolled. If bot, but the cursor is on the bottom of
# the screen, this command has no effect.
def line_feed!
if @cursor.row == @scrolling_region[1] # cursor is on the bottom row of the scrolling region
if @flags[:roll_enable]
scroll_up!
else
@cursor.row = @scrolling_region[0]
end
elsif @cursor.row >= @height-1
# do nothing
else
cursor_down!
end
true
end
# Save the cursor position. Return true.
def save_cursor!
@saved_cursor_position = [@cursor.row, @cursor.column]
true
end
# Restore the saved cursor position. If nothing has been saved, then go to the home position. Return true.
def restore_cursor!
@cursor.row, @cursor.column = @saved_cursor_position
true
end
# Move the cursor down one row and return true.
# If the cursor is on the bottom row, return false without moving the cursor.
def cursor_down!
if @cursor.row >= @height-1
false
else
@cursor.row += 1
true
end
end
# Move the cursor up one row and return true.
# If the cursor is on the top row, return false without moving the cursor.
def cursor_up!
if @cursor.row <= 0
false
else
@cursor.row -= 1
true
end
end
# Move the cursor right one column and return true.
# If the cursor is on the right-most column, return false without moving the cursor.
def cursor_right!
if @cursor.column >= @width-1
false
else
@cursor.column += 1
true
end
end
# Move the cursor to the right. Wrap around if we reach the end of the screen.
#
# Return true.
def cursor_forward!(options={})
if @cursor.column >= @width-1
line_feed!
carriage_return!
else
cursor_right!
end
end
# Move the cursor left one column and return true.
# If the cursor is on the left-most column, return false without moving the cursor.
def cursor_left!
if @cursor.column <= 0
false
else
@cursor.column -= 1
true
end
end
alias cursor_back! cursor_left! # In the future, this might not be an alias
# Scroll the contents of the screen up by one row and return true.
# The position of the cursor does not change.
def scroll_up!
@glyphs.scroll_up_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
@attrs.scroll_up_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
true
end
# Scroll the contents of the screen down by one row and return true.
# The position of the cursor does not change.
def scroll_down!
@glyphs.scroll_down_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
@attrs.scroll_down_region(@scrolling_region[0], 0, @scrolling_region[1], @width-1, 1)
true
end
# Erase, starting with the character under the cursor and extending to the end of the line.
# Return true.
def erase_to_end_of_line!
@glyphs.replace_at(@cursor.row, @cursor.column, " "*(@[email protected]))
@attrs.replace_at(@cursor.row, @cursor.column, " "*(@[email protected]))
true
end
# Erase, starting with the beginning of the line and extending to the character under the cursor.
# Return true.
def erase_to_start_of_line!
@glyphs.replace_at(@cursor.row, 0, " "*(@cursor.column+1))
@attrs.replace_at(@cursor.row, 0, " "*(@cursor.column+1))
true
end
# Erase the current (or specified) line. The cursor position is unchanged.
# Return true.
def erase_line!(row=nil)
row = @cursor.row unless row
@glyphs.replace_at(row, 0, " "*@width)
@attrs.replace_at(row, 0, " "*@width)
true
end
# Erase the window. Return true.
def erase_window!
empty_line = " "*@width
@height.times do |row|
@glyphs.replace_at(row, 0, empty_line)
@attrs.replace_at(row, 0, empty_line)
end
true
end
# Delete the specified number of lines, starting at the cursor position
# extending downwards. The lines below the deleted lines are scrolled up,
# and blank lines are inserted below them.
# Return true.
def delete_lines!(count=1)
@glyphs.scroll_up_region(@cursor.row, 0, @height-1, @width-1, count)
@attrs.scroll_up_region(@cursor.row, 0, @height-1, @width-1, count)
true
end
# Delete the specified number of characters, starting at the cursor position
# extending to the end of the line. The characters to the right of the
# cursor are scrolled left, and blanks are inserted after them.
# Return true.
def delete_characters!(count=1)
@glyphs.scroll_left_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
@attrs.scroll_left_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
true
end
# Insert the specified number of blank characters at the cursor position.
# The characters to the right of the cursor are scrolled right, and blanks
# are inserted in their place.
# Return true.
def insert_blank_characters!(count=1)
@glyphs.scroll_right_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
@attrs.scroll_right_region(@cursor.row, @cursor.column, @cursor.row, @width-1, count)
true
end
# Insert the specified number of lines characters at the cursor position.
# The characters to the below the cursor are scrolled down, and blank
# lines are inserted in their place.
# Return true.
def insert_blank_lines!(count=1)
@glyphs.scroll_down_region(@cursor.row, 0, @height-1, @width-1, count)
@attrs.scroll_down_region(@cursor.row, 0, @height-1, @width-1, count)
true
end
private
# Set the vertical scrolling region.
#
# Values will be clipped.
def set_scrolling_region!(top, bottom)
@scrolling_region[0] = [0, [@height-1, top].min].max
@scrolling_region[1] = [0, [@width-1, bottom].min].max
nil
end
def error(message) # XXX - This sucks
raise ArgumentError.new(message)
#puts message # DEBUG FIXME
end
def t_reset(fsm)
reset_to_initial_state!
end
# Printable character
def t_printable(fsm) # :nodoc:
insert_blank_characters! if @flags[:insert_mode] # TODO
put_char!(fsm.input)
cursor_forward!
end
# Move the cursor to the left margin on the current row.
def t_carriage_return(fsm)
carriage_return!
end
# Move the cursor to the left margin on the next row.
def t_new_line(fsm)
carriage_return!
line_feed!
end
# Move cursor to the top-left cell of the window.
def t_window_home(fsm)
@cursor.pos = [0,0]
end
# Erase all characters starting at the cursor and extending to the end of the window.
def t_erase_unprotected(fsm)
# Erase to the end of the current line
erase_to_end_of_line!
# Erase subsequent lines to the end of the window.
(@cursor.row+1..@height-1).each do |row|
erase_line!(row)
end
end
# Erase all characters starting at the cursor and extending to the end of the line.
def t_erase_end_of_line(fsm)
erase_to_end_of_line!
end
# Move the cursor to the specified position within the window.
# <020> <column> <row>
def t_write_window_address(fsm)
column, row = fsm.input_sequence[1,2].join.unpack("C*")
row = @cursor.row if row == 0177 # 0177 == special case: do not change the row
column = @cursor.column if column == 0177 # 0177 == special case: do not change the column
column = @width-1 if column > @width-1
row = @height-1 if row > @height-1
@cursor.pos = [row, column]
end
# Erase all characters in the current window, and move the cursor to
# the top-left cell of the window.
def t_erase_window(fsm)
erase_window!
@cursor.pos = [0,0]
end
def t_cursor_up(fsm)
cursor_up!
end
def t_cursor_down(fsm)
cursor_down!
end
def t_cursor_right(fsm)
cursor_right!
end
def t_cursor_left(fsm)
cursor_left!
end
# ESC ] ... M
# XXX - What is this?
def t_osc_m(fsm) end # TODO
def t_osc_k(fsm) end # TODO
def t_roll_enable(fsm)
@flags[:roll_mode] = true
end
def t_roll_disable(fsm)
@flags[:roll_mode] = false
end
def t_print_window(fsm) end # TODO
def t_bell(fsm) end # TODO
def t_blink_enable(fsm) end # TODO
def t_blink_disable(fsm) end # TODO
def t_underscore_on(fsm) end # TODO
def t_underscore_off(fsm) end # TODO
def t_blink_on(fsm) end # TODO
def t_blink_off(fsm) end # TODO
def t_reverse_video_on(fsm) end # TODO
def t_reverse_video_off(fsm) end # TODO
def t_dim_on(fsm) end # TODO
def t_dim_off(fsm) end # TODO
def t_set_cursor_type(fsm) end # TODO
+ def t_telnet_will(fsm) end # TODO
+ def t_telnet_wont(fsm) end # TODO
+ def t_telnet_do(fsm) end # TODO
+ def t_telnet_dont(fsm) end # TODO
+ def t_telnet_subnegotiation(fsm) end # TODO
+
# Proprietary escape code
# <036> ~ <2-byte-command> <n> <n*bytes>
def t_proprietary_escape(fsm)
command = fsm.input_sequence[3,2].join
payload = fsm.input_sequence[5..-1].join
#puts "PROPRIETARY ESCAPE: command=#{command.inspect} payload=#{payload.inspect}" # DEBUG FIXME
end
# Acknowledgement of proprietary escape sequence.
# From the server to the client, this is just a single-character ACK
def t_proprietary_ack(fsm) end # TODO
end
end
end
diff --git a/lib/scriptty/term/dg410/dg410-escapes.txt b/lib/scriptty/term/dg410/dg410-escapes.txt
index edb6fe6..a485e00 100644
--- a/lib/scriptty/term/dg410/dg410-escapes.txt
+++ b/lib/scriptty/term/dg410/dg410-escapes.txt
@@ -1,82 +1,82 @@
# Terminal escapes for dg410
#'\001' => t_print_form
#'\002' => t_stx
'\003' => t_blink_enable
'\004' => t_blink_disable
#'\005' => t_read_window_address
'\006' => t_proprietary_ack
'\007' => t_bell
'\010' => t_window_home
#'\011' => t_tab
'\012' => t_new_line
'\013' => t_erase_end_of_line
'\014' => t_erase_window
'\015' => t_carriage_return
'\016' => t_blink_on
'\017' => t_blink_off
'\020' => {
* => {
* => t_write_window_address
}
}
'\021' => t_print_window
'\022' => t_roll_enable
'\023' => t_roll_disable
'\024' => t_underscore_on
'\025' => t_underscore_off
#'\026' => t_syn # seems to always be followed by some data, then \002 # XXX TODO
'\027' => t_cursor_up
'\030' => t_cursor_right
'\031' => t_cursor_left
'\032' => t_cursor_down
'\033' => {
# '\x20' => {
# 'i' => t_esc_sp_i
# }
# '*' => {
# 's' => t_esc_asterisk_s
# }
']' => { # OSC? -- Nope XXX TODO
[01] => {
'M' => t_osc_m # XXX TODO
'K' => t_osc_k # XXX TODO
}
}
}
'\034' => t_dim_on
'\035' => t_dim_off
'\036' => {
# 'C' => t_read_model_id
'D' => t_reverse_video_on
'E' => t_reverse_video_off
'F' => {
'A' => t_reset
'F' => t_erase_unprotected
# 'I' => t_delete_line
'Q' => {
* => t_set_cursor_type
}
# '\\' => t_delete_between_margins
# '@' => t_select_ansi_mode
}
# 'K' => t_delete_character
'~' => t_parse_proprietary_escape
}
-#'\377' => {
-# '\372' => t_parse_telnet_sb => {
-# * => t_telnet_subnegotiation
-# }
-# '\373' => {
-# * => t_telnet_will
-# }
-# '\374' => {
-# * => t_telnet_wont
-# }
-# '\375' => {
-# * => t_telnet_do
-# }
-# '\376' => {
-# * => t_telnet_dont
-# }
-#}
+'\377' => {
+ '\372' => t_parse_telnet_sb => {
+ * => t_telnet_subnegotiation
+ }
+ '\373' => {
+ * => t_telnet_will
+ }
+ '\374' => {
+ * => t_telnet_wont
+ }
+ '\375' => {
+ * => t_telnet_do
+ }
+ '\376' => {
+ * => t_telnet_dont
+ }
+}
[\x20-\x7e] => t_printable
diff --git a/lib/scriptty/term/dg410/parser.rb b/lib/scriptty/term/dg410/parser.rb
index 50ac421..3ff0a1f 100644
--- a/lib/scriptty/term/dg410/parser.rb
+++ b/lib/scriptty/term/dg410/parser.rb
@@ -1,153 +1,160 @@
# = Parser for DG410 terminal
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
require 'scriptty/term/dg410'
module ScripTTY # :nodoc:
module Term
class DG410 # reopen
class Parser
PARSER_DEFINITION = File.read(File.join(File.dirname(__FILE__), "dg410-escapes.txt"))
# ScripTTY::Util::FSM object used by this parser. (Used for debugging.)
attr_reader :fsm
def initialize(options={})
@fsm = Util::FSM.new(:definition => PARSER_DEFINITION,
:callback => self, :callback_method => :handle_event)
@callback = options[:callback]
@callback_method = options[:callback_method] || :call
on_unknown_sequence :error
end
# Set the behaviour of the terminal when an unknown escape sequence is
# found.
#
# This method takes either a symbol or a block.
#
# When a block is given, it is executed whenever an unknown escape
# sequence is received. The block is passed the escape sequence as a
# single string.
#
# When a symbol is given, it may be one of the following:
# [:error]
# (default) Raise a ScripTTY::Util::FSM::NoMatch exception.
# [:ignore]
# Ignore the unknown escape sequence.
def on_unknown_sequence(mode=nil, &block)
if !block and !mode
raise ArgumentError.new("No mode specified and no block given")
elsif block and mode
raise ArgumentError.new("Block and mode are mutually exclusive, but both were given")
elsif block
@on_unknown_sequence = block
elsif [:error, :ignore].include?(mode)
@on_unknown_sequence = mode
else
raise ArgumentError.new("Invalid mode #{mode.inspect}")
end
end
# Feed the specified byte to the terminal. Returns a string of
# bytes that should be transmitted (e.g. for TELNET negotiation).
def feed_byte(byte)
raise ArgumentError.new("input should be single byte") unless byte.is_a?(String) and byte.length == 1
begin
@fsm.process(byte)
rescue Util::FSM::NoMatch => e
@fsm.reset!
if @on_unknown_sequence == :error
raise
elsif @on_unknown_sequence == :ignore
# do nothing
elsif !@on_unknown_sequence.is_a?(Symbol) # @on_unknown_sequence is a Proc
@on_unknown_sequence.call(e.input_sequence.join)
else
raise "BUG"
end
end
""
end
# Convenience method: Feeds several bytes to the terminal. Returns a
# string of bytes that should be transmitted (e.g. for TELNET
# negotiation).
def feed_bytes(bytes)
retvals = []
bytes.split(//n).each do |byte|
retvals << feed_byte(byte)
end
retvals.join
end
private
def handle_event(event, fsm)
if respond_to?(event, true)
send(event, fsm)
else
@callback.__send__(@callback_method, event, fsm) if @callback
end
end
# Parse proprietary escape code, and fire the :t_proprietary_escape
# event when finished.
def t_parse_proprietary_escape(fsm)
state = 0
length = nil
header_length = 5
fsm.redirect = lambda {|fsm|
if fsm.input_sequence.length == header_length
length = fsm.input.unpack("C*")[0]
end
if length && fsm.input_sequence.length >= header_length + length
fsm.redirect = nil
fsm.fire_event(:t_proprietary_escape)
end
true
}
end
+ # IAC SB ... SE
+ def t_parse_telnet_sb(fsm)
+ # limit subnegotiation to 100 chars # FIXME - This is wrong
+ count = 0
+ fsm.redirect = lambda {|fsm| count += 1; count < 100 && fsm.input_sequence[-2..-1] != ["\377", "\360"]}
+ end
+
# Parse ANSI/DEC CSI escape sequence parameters. Pass in fsm.input_sequence
#
# Example:
# parse_csi_params("\e[H") # returns []
# parse_csi_params("\e[;H") # returns []
# parse_csi_params("\e[2J") # returns [2]
# parse_csi_params("\e[33;42;0m") # returns [33, 42, 0]
# parse_csi_params(["\e", "[", "3", "3", ";", "4" "2", ";" "0", "m"]) # same as above, but takes an array
#
# This also works with DEC escape sequences:
# parse_csi_params("\e[?1;2J") # returns [1,2]
def parse_csi_params(input_seq) # TODO - test this
seq = input_seq.join if input_seq.respond_to?(:join) # Convert array to string
unless seq =~ /\A\e\[\??([\d;]*)[^\d]\Z/n
raise "BUG"
end
$1.split(/;/n).map{|p|
if p.empty?
nil
else
p.to_i
end
}
end
end
end
end
end
|
infonium/scriptty
|
60c4fd5873618abe28d88b897d005d42ebcdedac
|
Transcript::Writer - Fix encode_string when $KCODE is not "none"
|
diff --git a/lib/scriptty/util/transcript/writer.rb b/lib/scriptty/util/transcript/writer.rb
index bf3ea2a..2da686b 100644
--- a/lib/scriptty/util/transcript/writer.rb
+++ b/lib/scriptty/util/transcript/writer.rb
@@ -1,111 +1,111 @@
# = Transcript writer
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
module ScripTTY
module Util
module Transcript
class Writer
# Set this to non-nil to force the next record to have a specific timestamp
attr_accessor :override_timestamp
def initialize(io)
@io = io
@start_time = Time.now
@override_timestamp = nil
if block_given?
begin
yield self
ensure
close
end
end
end
def close
@io.close
end
# Client connection opened
def client_open(host, port)
write_event("Copen", host, port.to_s)
end
# Server connection opened
def server_open(host, port)
write_event("Sopen", host, port.to_s)
end
# Log bytes from the client
def from_client(bytes)
write_event("C", bytes)
end
# Log bytes from the server
def from_server(bytes)
write_event("S", bytes)
end
# Log event from the client (i.e. bytes parsed into an escape sequence, with an event fired)
def client_parsed(event, bytes)
write_event("Cp", event.to_s, bytes)
end
# Log event from the server (i.e. bytes parsed into an escape sequence, with an event fired)
def server_parsed(event, bytes)
write_event("Sp", event.to_s, bytes)
end
# Log server connection close
def server_close(message)
write_event("Sx", message)
end
# Log client connection close
def client_close(message)
write_event("Cx", message)
end
# Log informational message
def info(*args)
write_event("*", *args)
end
private
def write_event(type, *args)
t = @override_timestamp ? @override_timestamp.to_f : (Time.now - @start_time)
encoded_args = args.map{|a| encode_string(a)}.join(" ")
@io.write sprintf("[%.03f] %s %s", t, type, encoded_args) + "\n"
@io.flush if @io.respond_to?(:flush)
nil
end
def encode_string(bytes)
- escaped = bytes.gsub(/\\|"|[^\x20-\x7e]*/m) { |m|
+ escaped = bytes.gsub(/\\|"|[^\x20-\x7e]*/mn) { |m|
m.unpack("C*").map{ |c|
sprintf("\\%03o", c)
}.join
}
'"' + escaped + '"'
end
end
end
end
end
|
infonium/scriptty
|
9e79ea40870f2c39de9db8845cef13992c0ff76d
|
ScripTTY::Expect - Add timeout support
|
diff --git a/lib/scriptty/exception.rb b/lib/scriptty/exception.rb
new file mode 100644
index 0000000..c22a915
--- /dev/null
+++ b/lib/scriptty/exception.rb
@@ -0,0 +1,29 @@
+# = ScripTTY exceptions
+# Copyright (C) 2010 Infonium Inc.
+#
+# This file is part of ScripTTY.
+#
+# ScripTTY is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# ScripTTY is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
+
+module ScripTTY
+ module Exception
+ # Exception base class
+ class Base < StandardError
+ end
+
+ # Raised when a script times out.
+ class Timeout < Base
+ end
+ end
+end
diff --git a/lib/scriptty/expect.rb b/lib/scriptty/expect.rb
index 07aaeeb..4da1dc1 100644
--- a/lib/scriptty/expect.rb
+++ b/lib/scriptty/expect.rb
@@ -1,283 +1,337 @@
# = Expect object
# Copyright (C) 2010 Infonium Inc.
#
# This file is part of ScripTTY.
#
# ScripTTY is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ScripTTY is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ScripTTY. If not, see <http://www.gnu.org/licenses/>.
+require 'scriptty/exception'
require 'scriptty/net/event_loop'
require 'scriptty/term'
require 'scriptty/screen_pattern'
require 'set'
module ScripTTY
class Expect
# Methods to export to Evaluator
- EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep ]
+ EXPORTED_METHODS = Set.new [:init_term, :term, :connect, :screen, :expect, :on, :wait, :send, :push_patterns, :pop_patterns, :exit, :eval_script_file, :eval_script_inline, :sleep, :set_timeout ]
attr_reader :term # The terminal emulation object
+ # Initialize the Expect object.
def initialize
@net = ScripTTY::Net::EventLoop.new
@suspended = false
@effective_patterns = nil
@term_name = nil
@effective_patterns = [] # Array of PatternHandle objects
@pattern_stack = []
@wait_finished = false
@evaluator = Evaluator.new(self)
@match_buffer = ""
+ @timeout = nil
+ @timeout_timer = nil
+ end
+
+ def set_timeout(seconds)
+ raise ArgumentError.new("argument to set_timeout must be Numeric or nil") unless seconds.is_a?(Numeric) or seconds.nil?
+ if seconds
+ @timeout = seconds.to_f
+ else
+ @timeout = nil
+ end
+ refresh_timeout
+ nil
end
# Load and evaluate a script from a file.
def eval_script_file(path)
eval_script_inline(File.read(path), path)
end
# Evaluate a script specified as a string.
def eval_script_inline(str, filename=nil, lineno=nil)
@evaluator.instance_eval(str, filename || "(inline)", lineno || 1)
end
# Initialize a terminal emulator.
#
# If a name is specified, use that terminal type. Otherwise, use the
# previous terminal type.
def init_term(name=nil)
name ||= @term_name
@term_name = name
raise ArgumentError.new("No previous terminal specified") unless name
- @term = ScripTTY::Term.new(name)
- @term.on_unknown_sequence :ignore # XXX - Is this what we want?
+ without_timeout {
+ @term = ScripTTY::Term.new(name)
+ @term.on_unknown_sequence :ignore # XXX - Is this what we want?
+ }
+ nil
end
# Connect to the specified address. Return true if the connection was
# successful. Otherwise, raise an exception.
def connect(remote_address)
connected = false
connect_error = nil
@conn = @net.connect(remote_address) do |c|
c.on_connect { connected = true; handle_connect; @net.suspend }
c.on_connect_error { |e| handle_connect_error(e) }
c.on_receive_bytes { |bytes| handle_receive_bytes(bytes) }
c.on_close { @conn = nil; handle_connection_close }
end
dispatch until connected or connect_error or @net.done?
raise connect_error if !connected or connect_error or @net.done? # XXX - this is sloppy
+ refresh_timeout
connected
end
# Add the specified pattern to the effective pattern list.
#
# Return the PatternHandle for the pattern.
#
# Options:
# [:continue]
# If true, matching this pattern will not cause the wait method to
# return.
def on(pattern, opts={}, &block)
case pattern
when String
ph = PatternHandle.new(/#{Regexp.escape(pattern)}/n, block, opts[:background])
when Regexp
if pattern.kcode == "none"
ph = PatternHandle.new(pattern, block, opts[:background])
else
ph = PatternHandle.new(/#{pattern}/n, block, opts[:background])
end
when ScreenPattern
ph = PatternHandle(pattern, block, opts[:background])
else
raise TypeError.new("Unsupported pattern type: #{pattern.class.inspect}")
end
@effective_patterns << ph
ph
end
# Sleep for the specified number of seconds
def sleep(seconds)
sleep_done = false
@net.timer(seconds) { sleep_done = true ; @net.suspend }
dispatch until sleep_done
+ refresh_timeout
nil
end
# Return the named ScreenPattern
# XXX TODO
def screen(name)
end
# Convenience function.
#
# == Examples
# # Wait for a single pattern to match.
# expect("login: ")
#
# # Wait for one of several patterns to match.
# expect {
# on("login successful") { ... }
# on("login incorrect") { ... }
# }
def expect(pattern=nil)
raise ArgumentError.new("no pattern and no block given") if !pattern and !block_given?
push_patterns
begin
on(pattern) if pattern
yield if block_given?
wait
ensure
pop_patterns
end
end
# Push a copy of the effective pattern list to an internal stack.
def push_patterns
@pattern_stack << @effective_patterns.dup
end
# Pop the effective pattern list from the stack.
def pop_patterns
raise ArgumentError.new("pattern stack empty") if @pattern_stack.empty?
@effective_patterns = @pattern_stack.pop
end
# Wait for an effective pattern to match.
#
# Clears the character-match buffer on return.
def wait
dispatch until @wait_finished
+ refresh_timeout
@wait_finished = false
@match_buffer = ""
nil
end
# Send bytes to the remote application.
#
# NOTE: This method returns immediately, even if not all the bytes are
# finished being sent. Remaining bytes will be sent during an expect,
# wait, or sleep call.
def send(bytes)
@conn.write(bytes)
true
end
# Close the connection and exit.
def exit
@net.exit
dispatch until @net.done?
end
private
+ # Kick the watchdog timer
+ def refresh_timeout
+ disable_timeout
+ enable_timeout
+ end
+
+ def without_timeout
+ raise ArgumentError.new("no block given") unless block_given?
+ disable_timeout
+ begin
+ yield
+ ensure
+ enable_timeout
+ end
+ end
+
+ # Disable timeout handling
+ def disable_timeout
+ if @timeout_timer
+ @timeout_timer.cancel
+ @timeout_timer = nil
+ end
+ nil
+ end
+
+ # Enable timeout handling (if @timeout is set)
+ def enable_timeout
+ if @timeout
+ @timeout_timer = @net.timer(@timeout, :daemon=>true) { raise ScripTTY::Exception::Timeout.new("Operation timed out") }
+ end
+ nil
+ end
+
# Re-enter the dispatch loop
def dispatch
if @suspended
@suspended = @net.resume
else
@suspended = @net.main
end
end
def handle_connection_close # XXX - we should raise an error when disconnected prematurely
self.exit
end
def handle_connect
init_term
end
def handle_receive_bytes(bytes)
@match_buffer << bytes
@term.feed_bytes(bytes)
check_expect_match
end
# Check for a match.
#
# If there is a (non-background) match, set @wait_finished and return true. Otherwise, return false.
def check_expect_match
found = true
while found
found = false
@effective_patterns.each { |ph|
case ph.pattern
when Regexp
m = ph.pattern.match(@match_buffer)
@match_buffer = @match_buffer[m.end(0)..-1] if m # truncate match buffer
when ScreenPattern
m = ph.pattern.match_term(@term)
else
raise "BUG: pattern is #{ph.pattern.inspect}"
end
next unless m
# Matched - Invoke the callback
ph.callback.call(m) if ph.callback
# Make the next wait() call return
unless ph.background?
@wait_finished = true
@net.suspend
return true
else
found = true
end
}
end
false
end
class Evaluator
def initialize(expect_object)
@_expect_object = expect_object
end
# Define proxy methods
EXPORTED_METHODS.each do |m|
# We would use define_method, but JRuby 1.4 doesn't support defining
# a block that takes a block. http://jira.codehaus.org/browse/JRUBY-4180
class_eval("def #{m}(*args, &block) @_expect_object.__send__(#{m.inspect}, *args, &block); end")
end
end
class PatternHandle
attr_reader :pattern
attr_reader :callback
def initialize(pattern, callback, background)
@pattern = pattern
@callback = callback
@background = background
end
def background?
@background
end
end
class Match
attr_reader :pattern_handle
attr_reader :result
def initialize(pattern_handle, result)
@pattern_handle = pattern_handle
@result = result
end
end
end
end
|
infonium/scriptty
|
189a6d273b0ae133f94ce22221fa786f35549277
|
Version bump to 0.0.0
|
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..77d6f4c
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.0.0
|
infonium/scriptty
|
5cd3586c1cf19c096abc8f9afeb2c3654e215b10
|
Add Jeweler gemspec to Rakefile
|
diff --git a/Rakefile b/Rakefile
index ff837d4..4cc8949 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,22 +1,43 @@
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "scriptty"
+ gemspec.summary = "write expect-like script to control full-screen terminal-based applications"
+ gemspec.description = <<EOF
+ScripTTY is a JRuby application and library that lets you control full-screen
+terminal applications using an expect-like scripting language and a full-screen
+matching engine.
+EOF
+ gemspec.platform = "java"
+ gemspec.email = "[email protected]"
+ gemspec.homepage = "http://github.com/infonium/scriptty"
+ gemspec.authors = ["Dwayne Litzenberger"]
+ gemspec.add_dependency "treetop"
+ gemspec.add_dependency "multibyte"
+ end
+rescue LoadError
+ puts "Jeweler not available. Install it with: gem install jeweler"
+end
+
require 'rake/rdoctask'
Rake::RDocTask.new do |t|
t.rdoc_files = Dir.glob(%w( README* COPYING* lib/**/*.rb *.rdoc )).uniq
t.main = "README.rdoc"
t.title = "ScripTTY - RDoc Documentation"
t.options = %w( --charset -UTF-8 --line-numbers )
end
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.pattern = 'test/**/*_test.rb'
end
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.pattern = 'test/**/*_test.rb'
t.rcov_opts = ['--text-report', '--exclude', 'gems,rcov,jruby.*,\(eval\)']
end
rescue LoadError
$stderr.puts "warning: rcov not installed; coverage testing not available."
end
|
mmond/photo-gallery
|
c1c6d321966cc49d77e39d6d46c526650f84738c
|
First import
|
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/.DS_Store differ
diff --git a/banner.php b/banner.php
new file mode 100644
index 0000000..0c239bf
--- /dev/null
+++ b/banner.php
@@ -0,0 +1,58 @@
+<?
+$gall = $_GET[gallerylink];
+
+session_start();
+if (!session_is_registered("valid_user")) {
+ header("location: http://austinauts.com/tools/gallery/login.php?gallerylink=$gall");
+}
+
+print "<h2>You are logged in as: $_SESSION[valid_user]</h2>";
+
+print "<br><br>";
+?>
+
+<html>
+<body
+<?
+if (isset($_POST[header])) {
+ print $_POST[header].$_POST[gallerylink].$_POST[text] ;
+ print '<BODY onLoad="opener.window.location.reload();self.close();return false;" ' ;
+}
+?> >
+
+<?
+
+if (isset($_POST[header])) {
+ $file = $_SERVER[DOCUMENT_ROOT].'/pics'. $_POST[gallerylink].'/banner.txt';
+ $fp = fopen($file, "w");
+ $banner = '<font size="6">'.htmlspecialchars(stripslashes($_POST[header]), ENT_QUOTES).'</font><br>
+ <end header>';
+
+ if (strlen($_POST[text]) > 0) {
+ $banner .= '
+ <begin text content>
+
+ '.nl2br(htmlspecialchars(stripslashes($_POST[text]), ENT_QUOTES)).'<br>';
+ }
+
+ fwrite($fp, $banner);
+ fclose($fp);
+}
+?>
+<font size="6">Header</font><br>
+<form method="POST" action="banner.php">
+<input type="text" name="header" size="50"><br>
+
+Content<br>
+<textarea rows="10" cols="40" name="text" size="10">
+</textarea><br>
+<br>
+
+<b>File to be created or overwritten is: <? print $_SERVER[DOCUMENT_ROOT].'/pics'. $gall.'/banner.txt' ?><b><br><br>
+<input type="hidden" name="gallerylink" value="<? print $gall ?>">
+<input type="reset" value="Clear">
+<input type="submit" value="Write to file: ">
+</form>
+</body>
+</html>
+
diff --git a/exif.php b/exif.php
new file mode 100644
index 0000000..d8d0d70
--- /dev/null
+++ b/exif.php
@@ -0,0 +1,6 @@
+<?php
+
+include('rotate.php');
+print $_GET['src'];
+
+?>
\ No newline at end of file
diff --git a/hidden.php b/hidden.php
new file mode 100644
index 0000000..92424ed
--- /dev/null
+++ b/hidden.php
@@ -0,0 +1,19 @@
+<?
+print '<font size="5" color="#5571B0">Hidden Files</font><br><br>';
+$home = $_SERVER['DOCUMENT_ROOT']."/pics/";
+hidden_search($home);
+
+function secret_search($home) {
+ $dp = opendir($home);
+ while ($dir = readdir($dp)) {
+ if (is_dir($home.$dir) and $dir !== "." and $dir !== "..") {
+ if($dir == "secret") {
+ $gallerylink = substr($home.$dir, 37);
+ $galleryname = substr($home, 31);
+ print '<a href="SERVERNAME/?gallerylink='. $gallerylink .'">'. $galleryname .'</a><br>';
+ }
+ hidden_search($home.$dir."/");
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/jpeg_rotate.php b/jpeg_rotate.php
new file mode 100644
index 0000000..549087c
--- /dev/null
+++ b/jpeg_rotate.php
@@ -0,0 +1,254 @@
+<?php
+// justThumb.php - by Jack-the-ripper (c) Lars Ollén 2005
+// Feel free to use this program if u like just remember to give credits =D
+//
+// This is just a small php program that just creates a thumbnail of a picture..
+// it can use cached thumbs or not.
+// I made this because i could not find anything that just made a thumbnail.
+//
+/*
+ atributes
+ src - source image
+ w - thumb width
+ h - thumb hight
+ fcu - force cache usage,can be true or false, *not implemented*
+ ver - only, show - adds justThumbs verion on the image. *only only is implemented at the moment*
+ Only makes an image that only has the version this overrides src.
+*/
+// config variable
+$useCache = true; // true if u want to use a cache
+$cacheDir = "thumb_cache/"; // the cachedirectoryname, where the cachefiles will be
+$cachePrefix = "thumbcache_"; // the cache for hej.jpg would bee hej_thumbcache.jpg in this case
+$cacheQuality = 75; //quality is optional, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default is the default IJG quality value (about 75).
+
+
+//-----------------------
+// don't edit below this
+//-----------------------
+
+global $_GET;
+
+$srcFile = false; // src - source image
+$thumbW = false; // w - thumb width
+$thumbH = false; // h - thumb hight
+$fcu = false; // fcu - force cache usage,can be true or false
+$ver = false;
+$width = false;
+$height = false;
+$type = false;
+$version = "0.9.1 beta";
+define("__DEFAULTTHUMBW__", 175);
+define("__MAXSIZE__", 940);
+getTheGets();
+
+if($ver == "only")
+{
+ $srcFile = false;
+ $thumb = makeVersionOnly();
+}
+else
+{
+ if(is_file($srcFile))
+ {
+ loadInfo();
+ $thumb = false;
+
+ if($useCache)
+ {
+ $thumbFile = dirname($srcFile)."/".$cacheDir."/$cachePrefix".basename($srcFile,".jpg")."_w".$thumbW."h".$thumbH.".jpg";
+ $thumb = loadImage($thumbFile);
+ if($thumb !== false)
+ $useCache = false;
+ }
+
+ if($thumb === false)
+ $thumb = loadAndResize();
+
+ if($useCache)
+ {
+ saveImage($thumb,$thumbFile,$cacheQuality);
+ }
+ }
+ else
+ {
+ $thumb = makeErrorImg("File not found - " . basename($srcFile));
+ }
+}
+
+// Rotate jpeg using exif information
+include("rotate.php");
+$thumb = imagerotate($thumb, $rotation, 0);
+
+header('Content-type: image/jpeg');
+@imagejpeg($thumb);
+imagedestroy($thumb);
+
+
+//----------------
+// functions...
+//----------------
+
+
+ function getTheGets()
+ {
+ global $_GET, $srcFile, $thumbW, $thumbH, $fcu, $ver;
+
+ $srcFile = isset($_GET['src'])?($_GET['src']):false;
+
+ if(isset($_GET['ver']))
+ {
+ if(strtolower($_GET['ver']) == "only")
+ $ver = "only";
+ }
+
+// to be implented $fcu = ($_GET['fcu']=="true" ? true:false);
+
+ $thumbW = isset($_GET['w'])?($_GET['w']):false;
+ $thumbH = isset($_GET['h'])?($_GET['h']):false;
+
+ if(($thumbW > __MAXSIZE__ || ($thumbW <= 0)) || ($thumbH > __MAXSIZE__ || ($thumbH <= 0 && $thumbH !== false)))
+ {
+ $thumbW = __DEFAULTTHUMBW__;
+ $thumbH = false;
+ }
+
+
+ if(!$thumbW && !$thumbH)
+ $thumbW = __DEFAULTTHUMBW__;
+ }
+
+
+ function loadImageByType($filename,$type)
+ {
+ switch($type)
+ {
+ case IMAGETYPE_GIF:
+ return @imagecreatefromgif($filename);
+ case IMAGETYPE_JPEG:
+ return @imagecreatefromjpeg($filename);
+ case IMAGETYPE_PNG:
+ return @imagecreatefrompng($filename);
+ default:
+ return false;
+ }
+ }
+
+ function makeErrorImg($msg)
+ {
+ $thumb = imagecreate(120, 100); /* Create a blank image */
+ $bgc = imagecolorallocate($thumb, 255, 255, 255);
+ $tc = imagecolorallocate($thumb, 0, 0, 0);
+ imagefilledrectangle($thumb, 0, 0, 120, 30, $bgc);
+ /* Output an errmsg */
+ imagestring($thumb, 1, 5, 5, $msg, $tc);
+ return $thumb;
+ }
+
+ function loadInfo()
+ {
+ global $srcFile, $thumbW, $thumbH, $useCache, $width, $height, $type;
+
+ list($width, $height, $type) = getimagesize($srcFile);
+
+ if($thumbH === false && $thumbW !== false)
+ {
+ $thumbH = round($height*($thumbW/$width));
+ }
+ else if($thumbH !== false && $thumbW === false)
+ {
+ $thumbW = round($width*($thumbH/$height));
+ }
+ else if($thumbH === false && $thumbW === false)
+ {
+ die("This should not be able to happen..");
+ }
+
+ }
+
+ function loadAndResize()
+ {
+ global $srcFile, $thumbW, $thumbH, $useCache, $width, $height, $type;
+
+ $source = loadImageByType($srcFile,$type);
+
+ if (!$source)
+ {
+ $useCache = false; // dont save the error thumb
+ $thumb = makeErrorImg("Error loading $srcFile");
+ }
+ else
+ {
+ if($thumbH === false && $thumbW === false)
+ {
+ die("This should not be able to happen..");
+ }
+
+ $thumb = imageCreateTrueColor($thumbW, $thumbH);
+ imagecopyresampled($thumb, $source, 0, 0, 0, 0, $thumbW, $thumbH, $width, $height);
+ imagedestroy($source);
+ }
+
+ return $thumb;
+ }
+
+ function loadImage($filename)
+ {
+ $img = false;
+ if(is_file($filename))
+ {
+ list($width, $height, $type) = getimagesize($filename);
+ $img = loadImageByType($filename,$type);
+ }
+
+ if(!$img)
+ return false;
+ else
+ return $img;
+ }
+
+ function saveImage($img,$file,$quality)
+ {
+ if(!$img)
+ return;
+
+ if(!is_dir(dirname($file)))
+ {
+ $dirok = RecursiveMkdir(dirname($file));
+ }
+ else
+ $dirok = true;
+
+ if($dirok)
+ @imagejpeg($img,$file,$quality);
+ }
+
+ function RecursiveMkdir($path)
+ {
+ // This function creates the specified directory using mkdir(). Note
+ // that the recursive feature on mkdir() is broken with PHP 5.0.4 for
+ // Windows, so I have to do the recursion myself.
+ if (!file_exists($path))
+ {
+ RecursiveMkdir(dirname($path));
+ mkdir($path, 0777);
+ }
+ }
+
+ function makeVersionOnly()
+ {
+ global $version;
+
+
+ $thumb = imagecreate(220, 50); /* Create a blank image */
+ $bgc = imagecolorallocate($thumb, 0, 255, 0);
+ $tc = imagecolorallocate($thumb, 0, 0, 0);
+ imagefilledrectangle($thumb, 10, 10, 50, 40, $bgc);
+
+ imagestring($thumb, 5, 9, 7, "justThumb.php", $tc);
+ imagestring($thumb, 5, 40, 25, "version ".$version, $tc);
+
+ return $thumb;
+ }
+
+
+?>
diff --git a/login.php b/login.php
new file mode 100644
index 0000000..57755df
--- /dev/null
+++ b/login.php
@@ -0,0 +1,55 @@
+<?
+
+$SERVERNAME = "http://YOURSERVER.com/PATH/TO/SCRIPT-HOME";
+$USERNAME = "";
+$PASSWORD = "";
+
+session_start();
+$gall = $_GET[gallerylink];
+
+if (isset($_POST[username]))
+{
+ // if the user has just tried to log in
+
+ if ($_POST[username] == "USERNAME" && $_POST[password] == "PASSWORD")
+ {
+ // if credentias match
+ $valid_user = $_POST[username];
+ session_register("valid_user");
+ header("location: SERVERNAME/banner.php?gallerylink=$gall");
+ }
+}
+
+ if (session_is_registered("valid_user"))
+ {
+ header("location: $SERVERNAME/banner.php?gallerylink=$gall");
+ }
+ else
+ {
+ if (isset($userid))
+ {
+ // if they've tried and failed to log in
+ echo "Could not log you in";
+ }
+ else
+ {
+ // they have not tried to log in yet or have logged out
+
+print "<html><body>
+ <h1>Please login to update banner</h1>
+ You are not logged in.<br>";
+ }
+
+ // provide form to log in
+ echo "<form method=post action=login.php?gallerylink=$gall>";
+ echo "<table>";
+ echo "<tr><td>Userid:</td>";
+ echo "<td><input type=text name=username size=20></td></tr>";
+ echo "<tr><td>Password:</td>";
+ echo "<td><input type=password name=password size=20></td></tr>";
+ echo "<tr><td colspan=2 align=center>";
+ echo "<input type=submit value='Log in'></td></tr>";
+ echo "</table></form>";
+ }
+?>
+</html>
\ No newline at end of file
diff --git a/render.php b/render.php
new file mode 100644
index 0000000..c461dd6
--- /dev/null
+++ b/render.php
@@ -0,0 +1,161 @@
+<?
+// Map short variables globals=off version's long syntax
+$dir = "tools/gallery";
+$gallery = $_GET['gallerylink'];
+$src = $_GET['src'];
+$w = $_GET['w'];
+if (!isset($dir)) $dir = ".";
+
+if (isset($src)) { // Trim the filename off the end of the src link and ../.. off the beginning
+ $lastslash = strrpos($src, "/");
+ $gallery = substr($src, 11, $lastslash - 10);
+}
+
+// consider ".." in path an attempt to read dirs outside gallery, so redirect to gallery root
+if (strstr($gallery, "..")) $gallery = "";
+
+// Display the Banner
+if (file_exists($_SERVER['DOCUMENT_ROOT']."/pics/".$gallery."/banner.txt")) {
+ print '<td width="100%" align="center">';
+ include($_SERVER['DOCUMENT_ROOT']."/pics/".$gallery."/banner.txt");
+ print '<br></td>';
+}
+
+print '<tr valign="top"><td align="center">';
+print '<b><a href="?gallerylink=" >Gallery Home</a></b>';
+
+if ($gallery == "") {
+ $gallery = "";
+} else { // If $gallerylink is set and not "" then....
+
+ // Build the full gallery path into an array
+ $gallerypath = explode("/", $gallery);
+
+ // Render the Up directory links
+ foreach ($gallerypath as $key => $level) {
+ $parentpath = $parentpath . $level ;
+ // Unless it is the current directory
+ if ($key < count($gallerypath) - 1) {
+ print '<b> / <a href="?gallerylink='. $parentpath .'" >'. $level .'</a></b>';
+ } else {
+ // In that case render the current gallery name, but don't hyperlink
+ print "<b> / $level</b>";
+ }
+ $parentpath = $parentpath . "/";
+ }
+}
+
+print ' <a href=".?content=tools/gallery/zip.php&gallerylink=' . $gallery . '" title="Download a zipped archive of all photos in this gallery">-zip-</a>
+</table><b> ';
+
+// Create the arrays with the dir's media files
+$dp = opendir($_SERVER['DOCUMENT_ROOT']."/pics/".$gallery);
+while ($filename = readdir($dp)) {
+ if (!is_dir($_SERVER['DOCUMENT_ROOT']."/pics/".$gallery. "/". $filename)) { // If it's a file, begin
+ $pic_types = array("JPG", "jpg", "GIF", "gif", "PNG", "png");
+ if (in_array(substr($filename, -3), $pic_types)) $pic_array[] = $filename; // If it's a picture, add it to thumb array
+ else {
+ $movie_types = array("AVI", "avi", "MOV", "mov", "MP3", "mp3", "MP4", "mp4");
+ if (in_array(substr($filename, -3), $movie_types)) $movie_array[$filename] = size_readable(filesize($_SERVER['DOCUMENT_ROOT']."/pics/".$gallery. "/". $filename)); // If it's a movie, add name and size to the movie array
+ }
+ }
+}
+if($pic_array) sort($pic_array);
+
+//print the movie items
+if($movie_array) {
+ print "Movies: ";
+ foreach ($movie_array as $filename => $filesize) {
+ print '
+ <a href="tools/gallery/source.php?avi=../../pics/'. $parentpath.$subdir.$filename. '" title="Movies may take much longer to download. This file size is '. $filesize .'">' .$filename.'</a> ';
+ }
+}
+closedir($dp);
+
+// If this is a gallery marked hidden, link to the index of other galleries marked hidden
+if($level == "hidden") print '<a href="./?content=tools/gallery/hidden.php">- Index of all hidden galleries - </a><br>';
+
+print 'Sub Galleries / ';
+// Render the Subdirectory links
+$dp = opendir($_SERVER['DOCUMENT_ROOT']."/pics/".$gallery);
+
+// If the subdir is not a unix marker or set as hidden, enter it into the array
+while ($subdir = readdir($dp)) {
+ if (is_dir($_SERVER['DOCUMENT_ROOT']."/pics/".$gallery. "/". $subdir) && $subdir !="thumb_cache" && $subdir != "." && $subdir != ".." && !strstr($subdir, "hidden")) {
+ $subdirs[] = $subdir;
+ }
+}
+
+if($subdirs) {
+ sort($subdirs);
+ foreach ($subdirs as $key => $subdir) {
+ print '
+<a href="?gallerylink='. $parentpath.$subdir. '" >' .$subdir.'</a> / ';
+ }
+}
+closedir($dp);
+print '</b>
+<br><br>
+
+<table border="0" cellpadding="0" cellspacing="0">';
+
+
+
+// Render the gallery view, and links
+if (!isset($src) && isset($pic_array)) {
+ if ($gallery == "") $w=700; // If it is the root gallery, display that single picture larger
+ $column = 0;
+ print '<tr align="top">';
+ foreach ($pic_array as $filename) { // Use the pic_array to assign the links and img src
+ // If it is a jpeg include the exif rotation logic
+ if(strstr($filename, ".JPG")) print '
+ <td valign="top"><a href="?src=../../pics/'.$gallery. "/" .$filename.'"><img src="'. $dir .'/jpeg_rotate.php?src=../../pics/'.$gallery. "/". $filename.'&w=' .$w. '"></a></td>';
+ else print '
+ <td valign="top"><a href="?src=../../pics/'.$gallery. "/" .$filename.'"><img src="'. $dir .'/thumb.php?src=../../pics/'.$gallery. "/". $filename.'&w=' .$w. '"></a></td>';
+ $column++;
+ if ( $column == 6 ) {
+ $column = 0;
+ print '</tr><tr>
+';
+ }
+ }
+} else {
+
+// Render the 700 pixel wide version, link to original, last/next picture, and link to parent gallery
+ if (!strstr($src, "../pics/")) die; // If "../pics" is not in path it may be an attempt to read files outside gallery, so redirect to gallery root
+ $filename = substr($src, $lastslash + 1);
+ $before_filename = $pic_array[array_search($filename, $pic_array) - 1 ];
+ $after_filename = $pic_array[array_search($filename, $pic_array) + 1 ];
+
+ // Display the before thumb
+ if ($before_filename) {
+ // If it is a jpeg include the exif rotation logic
+ if(strstr($before_filename, ".JPG")) print '<td align="center"><a href="?src=../../pics/' . $gallery.$before_filename .'">...<img src="'. $dir .'/jpeg_rotate.php?src=../../pics/' .$gallery.$before_filename .'"></a></td>';
+ else print '<td align="center"><a href="?src=../../pics/' . $gallery.$before_filename .'">...<img src="'. $dir .'/thumb.php?src=../../pics/' .$gallery.$before_filename .'"></a></td>';
+ }
+ // Display the current/websize pic
+ // If it is a jpeg include the exif rotation logic
+ if(strstr($src, ".JPG")) print '<td><a href="tools/gallery/source.php?pic=' . $src . '"><img src="./'. $dir .'/jpeg_rotate.php?src='. $src. '&w=700"></a></td>';
+ else print '<td><a href="tools/gallery/source.php?pic=' . $src . '"><img src="./'. $dir .'/thumb.php?src='. $src. '&w=700"></a></td>';
+
+ // Display the after thumb
+ if ($after_filename) {
+ if(strstr($after_filename, ".JPG")) print '<td align="center"><a href="?src=../../pics/' . $gallery.$after_filename .'"><img src="'. $dir .'/jpeg_rotate.php?src=../../pics/' .$gallery.$after_filename .'">...</a></td></tr>';
+ else print '<td align="center"><a href="?src=../../pics/' . $gallery.$after_filename .'"><img src="'. $dir .'/thumb.php?src=../../pics/' .$gallery.$after_filename .'">...</a></td></tr>';
+ }
+}
+print '</tr>';
+
+function size_readable ($size, $retstring = null) {
+ // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
+ $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
+ if ($retstring === null) { $retstring = '%01.2f %s'; }
+ $lastsizestring = end($sizes);
+ foreach ($sizes as $sizestring) {
+ if ($size < 1024) { break; }
+ if ($sizestring != $lastsizestring) { $size /= 1024; }
+ }
+ if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional
+ return sprintf($retstring, $size, $sizestring);
+}
+?>
\ No newline at end of file
diff --git a/rotate.php b/rotate.php
new file mode 100644
index 0000000..3cf60fe
--- /dev/null
+++ b/rotate.php
@@ -0,0 +1,51 @@
+<?
+
+$exif = exif_read_data($_GET['src'], EXIF, true);
+
+$o = $exif["IFD0"]["Orientation"];
+$rotation = 0;
+$flip = false;
+
+switch($o) {
+
+case 1:
+$rotation = 0;
+$flip = false;
+break;
+
+case 2:
+$rotation = 0;
+$flip = true;
+break;
+
+case 3:
+$rotation = 180;
+$flip = false;
+break;
+
+case 4:
+$rotation = 180;
+$flip = true;
+break;
+
+case 5:
+$rotation = 270;
+$flip = true;
+break;
+
+case 6:
+$rotation = 270;
+$flip = false;
+break;
+
+case 7:
+$rotation = 90;
+$flip = true;
+break;
+
+case 8:
+$rotation = 90;
+$flip = false;
+break;
+}
+?>
\ No newline at end of file
diff --git a/source.php b/source.php
new file mode 100644
index 0000000..89ffad1
--- /dev/null
+++ b/source.php
@@ -0,0 +1,43 @@
+<?
+// Choose the URL argument being passed to source.php
+// Build the content type link based on file type
+
+if ($_GET['pic']) {
+ $filename = $_GET['pic'];
+ $len = filesize($filename);
+ $lastslash = strrpos($filename, "/");
+ $name = substr($filename, $lastslash + 1);
+
+ header("Content-type: image/jpeg;\r\n");
+ header("Content-Length: $len;\r\n");
+ header("Content-Transfer-Encoding: binary;\r\n");
+ header('Content-Disposition: inline; filename="'.$name.'"'); // Render the photo inline.
+ readfile($filename);
+}
+if ($_GET['zip']) {
+
+ $path = "../../" . $_GET['zip'];
+ $len = filesize($path);
+
+ $lastslash = strrpos($path, "/");
+ $filename = substr($path, $lastslash + 1);
+
+ header('Content-type: application/x-zip-compressed');
+ header('Content-Length: $len');
+ header('Content-Disposition: attachment; filename="' . $filename . '"'); // Create a download stream link
+ readfile($path);
+}
+
+if ($_GET['avi']) {
+ $filename = $_GET['avi'];
+ $len = filesize($filename);
+ $lastslash = strrpos($filename, "/");
+ $name = substr($filename, $lastslash + 1);
+
+ header("Content-type: video/x-msvideo;\r\n");
+ header("Content-Length: $len;\r\n");
+ header("Content-Transfer-Encoding: binary;\r\n");
+ header('Content-Disposition: inline; filename="'.$name.'"'); // Render the photo inline.
+ readfile($filename);
+}
+?>
\ No newline at end of file
diff --git a/thumb.php b/thumb.php
new file mode 100644
index 0000000..a7a026f
--- /dev/null
+++ b/thumb.php
@@ -0,0 +1,250 @@
+<?php
+// justThumb.php - by Jack-the-ripper (c) Lars Ollén 2005
+// Feel free to use this program if u like just remember to give credits =D
+//
+// This is just a small php program that just creates a thumbnail of a picture..
+// it can use cached thumbs or not.
+// I made this because i could not find anything that just made a thumbnail.
+//
+/*
+ atributes
+ src - source image
+ w - thumb width
+ h - thumb hight
+ fcu - force cache usage,can be true or false, *not implemented*
+ ver - only, show - adds justThumbs verion on the image. *only only is implemented at the moment*
+ Only makes an image that only has the version this overrides src.
+*/
+// config variable
+$useCache = true; // true if u want to use a cache
+$cacheDir = "thumb_cache/"; // the cachedirectoryname, where the cachefiles will be
+$cachePrefix = "thumbcache_"; // the cache for hej.jpg would bee hej_thumbcache.jpg in this case
+$cacheQuality = 75; //quality is optional, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default is the default IJG quality value (about 75).
+
+
+//-----------------------
+// don't edit below this
+//-----------------------
+
+global $_GET;
+
+$srcFile = false; // src - source image
+$thumbW = false; // w - thumb width
+$thumbH = false; // h - thumb hight
+$fcu = false; // fcu - force cache usage,can be true or false
+$ver = false;
+$width = false;
+$height = false;
+$type = false;
+$version = "0.9.1 beta";
+define("__DEFAULTTHUMBW__", 175);
+define("__MAXSIZE__", 940);
+getTheGets();
+
+if($ver == "only")
+{
+ $srcFile = false;
+ $thumb = makeVersionOnly();
+}
+else
+{
+ if(is_file($srcFile))
+ {
+ loadInfo();
+ $thumb = false;
+
+ if($useCache)
+ {
+ $thumbFile = dirname($srcFile)."/".$cacheDir."/$cachePrefix".basename($srcFile,".jpg")."_w".$thumbW."h".$thumbH.".jpg";
+ $thumb = loadImage($thumbFile);
+ if($thumb !== false)
+ $useCache = false;
+ }
+
+ if($thumb === false)
+ $thumb = loadAndResize();
+
+ if($useCache)
+ {
+ saveImage($thumb,$thumbFile,$cacheQuality);
+ }
+ }
+ else
+ {
+ $thumb = makeErrorImg("File not found - " . basename($srcFile));
+ }
+}
+
+header('Content-type: image/jpeg');
+@imagejpeg($thumb);
+imagedestroy($thumb);
+
+
+//----------------
+// functions...
+//----------------
+
+
+ function getTheGets()
+ {
+ global $_GET, $srcFile, $thumbW, $thumbH, $fcu, $ver;
+
+ $srcFile = isset($_GET['src'])?($_GET['src']):false;
+
+ if(isset($_GET['ver']))
+ {
+ if(strtolower($_GET['ver']) == "only")
+ $ver = "only";
+ }
+
+// to be implented $fcu = ($_GET['fcu']=="true" ? true:false);
+
+ $thumbW = isset($_GET['w'])?($_GET['w']):false;
+ $thumbH = isset($_GET['h'])?($_GET['h']):false;
+
+ if(($thumbW > __MAXSIZE__ || ($thumbW <= 0)) || ($thumbH > __MAXSIZE__ || ($thumbH <= 0 && $thumbH !== false)))
+ {
+ $thumbW = __DEFAULTTHUMBW__;
+ $thumbH = false;
+ }
+
+
+ if(!$thumbW && !$thumbH)
+ $thumbW = __DEFAULTTHUMBW__;
+ }
+
+
+ function loadImageByType($filename,$type)
+ {
+ switch($type)
+ {
+ case IMAGETYPE_GIF:
+ return @imagecreatefromgif($filename);
+ case IMAGETYPE_JPEG:
+ return @imagecreatefromjpeg($filename);
+ case IMAGETYPE_PNG:
+ return @imagecreatefrompng($filename);
+ default:
+ return false;
+ }
+ }
+
+ function makeErrorImg($msg)
+ {
+ $thumb = imagecreate(120, 100); /* Create a blank image */
+ $bgc = imagecolorallocate($thumb, 255, 255, 255);
+ $tc = imagecolorallocate($thumb, 0, 0, 0);
+ imagefilledrectangle($thumb, 0, 0, 120, 30, $bgc);
+ /* Output an errmsg */
+ imagestring($thumb, 1, 5, 5, $msg, $tc);
+ return $thumb;
+ }
+
+ function loadInfo()
+ {
+ global $srcFile, $thumbW, $thumbH, $useCache, $width, $height, $type;
+
+ list($width, $height, $type) = getimagesize($srcFile);
+
+ if($thumbH === false && $thumbW !== false)
+ {
+ $thumbH = round($height*($thumbW/$width));
+ }
+ else if($thumbH !== false && $thumbW === false)
+ {
+ $thumbW = round($width*($thumbH/$height));
+ }
+ else if($thumbH === false && $thumbW === false)
+ {
+ die("This should not be able to happen..");
+ }
+
+ }
+
+ function loadAndResize()
+ {
+ global $srcFile, $thumbW, $thumbH, $useCache, $width, $height, $type;
+
+ $source = loadImageByType($srcFile,$type);
+
+ if (!$source)
+ {
+ $useCache = false; // dont save the error thumb
+ $thumb = makeErrorImg("Error loading $srcFile");
+ }
+ else
+ {
+ if($thumbH === false && $thumbW === false)
+ {
+ die("This should not be able to happen..");
+ }
+
+ $thumb = imageCreateTrueColor($thumbW, $thumbH);
+ imagecopyresampled($thumb, $source, 0, 0, 0, 0, $thumbW, $thumbH, $width, $height);
+ imagedestroy($source);
+ }
+
+ return $thumb;
+ }
+
+ function loadImage($filename)
+ {
+ $img = false;
+ if(is_file($filename))
+ {
+ list($width, $height, $type) = getimagesize($filename);
+ $img = loadImageByType($filename,$type);
+ }
+
+ if(!$img)
+ return false;
+ else
+ return $img;
+ }
+
+ function saveImage($img,$file,$quality)
+ {
+ if(!$img)
+ return;
+
+ if(!is_dir(dirname($file)))
+ {
+ $dirok = RecursiveMkdir(dirname($file));
+ }
+ else
+ $dirok = true;
+
+ if($dirok)
+ @imagejpeg($img,$file,$quality);
+ }
+
+ function RecursiveMkdir($path)
+ {
+ // This function creates the specified directory using mkdir(). Note
+ // that the recursive feature on mkdir() is broken with PHP 5.0.4 for
+ // Windows, so I have to do the recursion myself.
+ if (!file_exists($path))
+ {
+ RecursiveMkdir(dirname($path));
+ mkdir($path, 0777);
+ }
+ }
+
+ function makeVersionOnly()
+ {
+ global $version;
+
+
+ $thumb = imagecreate(220, 50); /* Create a blank image */
+ $bgc = imagecolorallocate($thumb, 0, 255, 0);
+ $tc = imagecolorallocate($thumb, 0, 0, 0);
+ imagefilledrectangle($thumb, 10, 10, 50, 40, $bgc);
+
+ imagestring($thumb, 5, 9, 7, "justThumb.php", $tc);
+ imagestring($thumb, 5, 40, 25, "version ".$version, $tc);
+
+ return $thumb;
+ }
+
+
+?>
diff --git a/zip.php b/zip.php
new file mode 100644
index 0000000..9ba1f6b
--- /dev/null
+++ b/zip.php
@@ -0,0 +1,24 @@
+Building the archive now.... <br>
+
+A summary will print below when the zip file is ready. Depending on the number of photos it may take a few minutes to complete. Your browser may even time out before it's ready. If so, just hit refresh and this page will reload with the summary and zip file link. <br><br>
+<?
+$dir = "pics/" . $_GET['gallerylink'];
+
+// Create the arrays with the dir's media files
+$dp = opendir($dir);
+while ($filename = readdir($dp)) {
+ if (!is_dir($dir."/pics/".$gallery. "/". $filename)) { // If it's a file, begin
+ $pic_types = array("JPG", "jpg", "GIF", "gif", "PNG", "png");
+ if (in_array(substr($filename, -3), $pic_types)) $pic_array[] = $filename; // If it's a picture, add it to pic array
+ }
+}
+foreach ($pic_array as $filename) {
+ $media_files = $media_files . " " . $dir . "/" . $filename;
+}
+
+$output = `zip -u -j $dir/pics.zip $media_files`;
+print "<pre>$output</pre>";
+
+print 'Complete. The file can be downloaded <a href="tools/gallery/source.php?zip=' . $dir . '/pics.zip">here</a>';
+
+?>
\ No newline at end of file
|
hiroshi/inventory
|
a548ba752f089d889b9398ae35470406b57014b2
|
Separate params_scope.rb as a plugin, using git submodule.
|
diff --git a/.gitmodules b/.gitmodules
index c866009..faee88e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,12 @@
[submodule "vendor/plugins/script-refactor"]
path = vendor/plugins/script-refactor
url = git://github.com/hiroshi/script-refactor.git
[submodule "vendor/plugins/passenger_deploy"]
path = vendor/plugins/passenger_deploy
url = git://github.com/hiroshi/passenger_deploy.git
[submodule "vendor/plugins/cap_remote_rake"]
path = vendor/plugins/cap_remote_rake
url = git://github.com/hiroshi/cap_remote_rake.git
+[submodule "vendor/plugins/params_scope"]
+ path = vendor/plugins/params_scope
+ url = git://github.com/hiroshi/params_scope.git
diff --git a/config/initializers/modules/params_scope.rb b/config/initializers/modules/params_scope.rb
deleted file mode 100644
index 2f41092..0000000
--- a/config/initializers/modules/params_scope.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# Chainning up named scopes by a params hash.
-# Usage example:
-# class User
-# named_scope :age, lambda{|age| {:conditions => ["age = ?", age]}}
-# named_scope :city, lambda{|city| {:conditions => ["city = ?", city]}}
-# end
-#
-# class UsersController < ApplicationController
-# def index
-# params # => {:age => 30, :city => "Tokyo"}
-# @users = User.params_scope(params).find(:all) # => User.age(30).city("Tokyo").find(:all)
-
-module ParamsScope
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- def params_scope(params)
- self.scopes.keys.inject(self) do |ret, scope_name|
- if (value = (params[scope_name] || params[scope_name.to_s])) && !value.blank?
- ret.send(scope_name, *value)
- else
- ret
- end
- end
- end
- end
-end
-
-ActiveRecord::Base.send(:include, ParamsScope)
-ActiveRecord::Associations::AssociationProxy.send(:include, ParamsScope::ClassMethods)
diff --git a/vendor/plugins/params_scope b/vendor/plugins/params_scope
new file mode 160000
index 0000000..5afc271
--- /dev/null
+++ b/vendor/plugins/params_scope
@@ -0,0 +1 @@
+Subproject commit 5afc27106a5b3a99ae730b9e9900886170304134
|
hiroshi/inventory
|
e1cfc23bfc5d01a076dd54c743aea7f312c8766a
|
remove garbage
|
diff --git a/.gitmodules b/.gitmodules
index fb70d71..c866009 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,12 +1,9 @@
[submodule "vendor/plugins/script-refactor"]
path = vendor/plugins/script-refactor
url = git://github.com/hiroshi/script-refactor.git
[submodule "vendor/plugins/passenger_deploy"]
path = vendor/plugins/passenger_deploy
url = git://github.com/hiroshi/passenger_deploy.git
[submodule "vendor/plugins/cap_remote_rake"]
path = vendor/plugins/cap_remote_rake
url = git://github.com/hiroshi/cap_remote_rake.git
-[submodule "script-refactor"]
- path = script-refactor
- url = /Users/hiroshi/Desktop/inventory/vendor/plugins/script-refactor/.git
|
hiroshi/inventory
|
a5f85aa88a1c3176b9e5339d6da4e67811e67513
|
remove garbage
|
diff --git a/.gitmodules b/.gitmodules
index c866009..fb70d71 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,12 @@
[submodule "vendor/plugins/script-refactor"]
path = vendor/plugins/script-refactor
url = git://github.com/hiroshi/script-refactor.git
[submodule "vendor/plugins/passenger_deploy"]
path = vendor/plugins/passenger_deploy
url = git://github.com/hiroshi/passenger_deploy.git
[submodule "vendor/plugins/cap_remote_rake"]
path = vendor/plugins/cap_remote_rake
url = git://github.com/hiroshi/cap_remote_rake.git
+[submodule "script-refactor"]
+ path = script-refactor
+ url = /Users/hiroshi/Desktop/inventory/vendor/plugins/script-refactor/.git
|
hiroshi/inventory
|
571eb485501d942f7da21066727afc5c5004c259
|
add filedset and legend to assets#index filter form
|
diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb
index 4dbfc21..326f9b8 100644
--- a/app/views/assets/index.html.erb
+++ b/app/views/assets/index.html.erb
@@ -1,13 +1,16 @@
<%= render :partial => "menu" %>
<% form_tag "", :method => "get" do %>
+<fieldset>
+ <legend><%= t("filter") %></legend>
<%= t("activerecord.attributes.asset.developer_name") %>:
<%= auto_complete_combo_box_tag "developer_name", Developer.find(:all).map(&:name) %>
<%= t("activerecord.attributes.asset.user_login") %>:
<%= auto_complete_combo_box_tag "user_login", User.find(:all).map(&:login) %>
- <%= submit_tag "filter" %>
+ <%= submit_tag t("filter") %>
+</fieldset>
<% end %>
<%= render :partial => "index", :locals => {:assets => @assets} %>
diff --git a/config/deploy.rb b/config/deploy.rb
index fb24c1f..a6da7ea 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -1,31 +1,35 @@
set :application, "inventory"
set :repository, "git://github.com/hiroshi/inventory"
set(:deploy_to) { "/var/www/#{target}" }
set :scm, :git
#set :branch, "master"
set :deploy_via, :remote_cache
namespace "demo.inventory.yakitara.com" do
desc "set deploy target to demo.inventory.yakitara.com"
task :default do
set :target, task_call_frames.first.task.namespace.name
server "silent.yakitara.com", :app, :web, :db, :primary => true
set :user, "www-data"
set :use_sudo, false
end
namespace :config do
task :replace, :roles => :app do
put <<-YML, "#{current_path}/config/database.yml"
production:
adapter: postgresql
encoding: unicode
database: inventory_demo_production
pool: 5
username: www-data
password:
YML
end
after "deploy:update", "#{fully_qualified_name}:replace"
end
end
+
+task :foo do
+ puts fetch(:rails_env, "production")
+end
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index d1c9ca8..f7a4354 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1,65 +1,67 @@
ja:
create: ç»é²
update: æ´æ°
delete: åé¤
+ filter: ãã£ã«ã¿ã¼
+
today: 仿¥
no_user: å©ç¨è
ãªã
sessions:
new: ãã°ã¤ã³
users:
new: ã¦ã¼ã¶ã¼ç»é²
assets:
index: æ©æä¸è¦§
new: æ©æç»é²
create: æ©æç»é²
show: æ©æ
members:
index: å©ç¨è
new: å©ç¨è
ç»é²
utilizations:
children: ä»å±æ©æ
revisions: å©ç¨å±¥æ´
activerecord:
models:
user: "å©ç¨è
"
member: "å©ç¨è
"
asset: "æ©æ"
utilization: "å©ç¨æ
å ±"
attributes:
user:
login: "ãã°ã¤ã³å"
email: "ã¡ã¼ã«ã¢ãã¬ã¹"
name: "åå"
password: "ãã¹ã¯ã¼ã"
password_confirmation: "ãã¹ã¯ã¼ã確èª"
asset:
developer_name: "ã¡ã¼ã«ã¼"
product_name: "製åå"
model_number: "åçª"
utilization: "å©ç¨æ
å ±"
user_login: "å©ç¨è
"
utilization:
user_id: "å©ç¨è
"
description: "åè"
started_on: "éå§æ¥"
parent_id: "æ¥ç¶å
"
errors:
template:
header: "" # {{count}} errors prohibited this user from being saved
body: "" # There were problems with the following fields
messages:
blank: "ãæå®ãã¦ãã ãã"
too_short: "ã®é·ããè¶³ãã¾ãã"
models:
user:
attributes:
group_id:
blank: "ãæå®ãã¦ãã ãã"
asset:
attributes:
utilization:
invalid: "ãæ£ããããã¾ãã"
diff --git a/vendor/plugins/cap_remote_rake b/vendor/plugins/cap_remote_rake
index 7934cb1..b13fa6f 160000
--- a/vendor/plugins/cap_remote_rake
+++ b/vendor/plugins/cap_remote_rake
@@ -1 +1 @@
-Subproject commit 7934cb162b4f9a22af15d66a9f34bf6c5d544b51
+Subproject commit b13fa6f327f0587e56fcf3af562f9d914af4536d
|
hiroshi/inventory
|
b1e4ad2f56ff15e51ed87defadc30d08e65cf16b
|
add cap extention plugins as submodules
|
diff --git a/.gitmodules b/.gitmodules
index 708279d..c866009 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,9 @@
[submodule "vendor/plugins/script-refactor"]
path = vendor/plugins/script-refactor
url = git://github.com/hiroshi/script-refactor.git
+[submodule "vendor/plugins/passenger_deploy"]
+ path = vendor/plugins/passenger_deploy
+ url = git://github.com/hiroshi/passenger_deploy.git
+[submodule "vendor/plugins/cap_remote_rake"]
+ path = vendor/plugins/cap_remote_rake
+ url = git://github.com/hiroshi/cap_remote_rake.git
diff --git a/Capfile b/Capfile
new file mode 100644
index 0000000..c36d48d
--- /dev/null
+++ b/Capfile
@@ -0,0 +1,3 @@
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
+load 'config/deploy'
\ No newline at end of file
diff --git a/config/deploy.rb b/config/deploy.rb
new file mode 100644
index 0000000..fb24c1f
--- /dev/null
+++ b/config/deploy.rb
@@ -0,0 +1,31 @@
+set :application, "inventory"
+set :repository, "git://github.com/hiroshi/inventory"
+set(:deploy_to) { "/var/www/#{target}" }
+set :scm, :git
+#set :branch, "master"
+set :deploy_via, :remote_cache
+
+namespace "demo.inventory.yakitara.com" do
+ desc "set deploy target to demo.inventory.yakitara.com"
+ task :default do
+ set :target, task_call_frames.first.task.namespace.name
+ server "silent.yakitara.com", :app, :web, :db, :primary => true
+ set :user, "www-data"
+ set :use_sudo, false
+ end
+
+ namespace :config do
+ task :replace, :roles => :app do
+ put <<-YML, "#{current_path}/config/database.yml"
+production:
+ adapter: postgresql
+ encoding: unicode
+ database: inventory_demo_production
+ pool: 5
+ username: www-data
+ password:
+ YML
+ end
+ after "deploy:update", "#{fully_qualified_name}:replace"
+ end
+end
diff --git a/config/environment.rb b/config/environment.rb
index dbae7ec..a5d743a 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,76 +1,78 @@
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
#RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '2.3.0' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# See Rails::Configuration for more options.
# Skip frameworks you're not going to use. To use Rails without a database
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Specify gems that this application depends on.
# They can then be installed with "rake gems:install" on new installations.
# You have to specify the :lib option for libraries, where the Gem name (sqlite3-ruby) differs from the file itself (sqlite3)
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
+ config.gem "postgres"
+ config.gem "rcov"
# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
# config.log_level = :debug
# Make Time.zone default to the specified zone, and make Active Record store time values
# in the database in UTC, and return them converted to the specified local zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
config.time_zone = 'UTC'
# The internationalization framework can be changed to have another default locale (standard is :en) or more load paths.
# All files from config/locales/*.rb,yml are added automatically.
# config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
config.action_controller.session = {
:session_key => '_kizai_session',
:secret => '57cb7362962e08d79185323797e22d0f9d7efd97adfd2095c6e7543a0e1fa0631f34f445c18e6d748aa0cb591c19ca213f042161b263514923a9f96e3d0c5218'
}
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
# config.action_controller.session_store = :active_record_store
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
config.active_record.schema_format = :sql
# Activate observers that should always be running
# Please note that observers generated using script/generate observer need to have an _observer suffix
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
end
diff --git a/doc/README_FOR_DEVELOPER b/doc/README_FOR_DEVELOPER
index 6c9536d..c895771 100644
--- a/doc/README_FOR_DEVELOPER
+++ b/doc/README_FOR_DEVELOPER
@@ -1,28 +1,29 @@
-Before rading this, read README_FOR_APP first.
+Before reading farther, read README_FOR_APP first.
= Maintenance
-This application depends on many plugins.
-Those plugins other than home brewed ones, managed with 'git submodule', may be need update by re-installing.
-To update plugins:
+This application depends on many plugins.
+Home brewed ones are managed as "git submodule", as described in README_FOR_APP, and other external plugins.
- script/plugin install --force {URL}
+Home brewed plugins are:
+* script-refactor
+* passenger_deploy
+* cap_remote_rake
-== home brewed
+To update other plugins, just re-install them.
-script-refactor.git
- Provides script/refactor.
+ script/plugin install --force {URL}
== redhillonrails_core and dependants
git://github.com/harukizaemon/redhillonrails_core.git
git://github.com/harukizaemon/foreign_key_migrations.git
git://github.com/harukizaemon/schema_validations.git
== rails spin-offs
git://github.com/rails/acts_as_tree.git
git://github.com/rails/auto_complete.git
== RESTful Authentication
git://github.com/technoweenie/restful-authentication.git
== etc
http://svn.codahale.com/rails_rcov
diff --git a/vendor/plugins/cap_remote_rake b/vendor/plugins/cap_remote_rake
new file mode 160000
index 0000000..7934cb1
--- /dev/null
+++ b/vendor/plugins/cap_remote_rake
@@ -0,0 +1 @@
+Subproject commit 7934cb162b4f9a22af15d66a9f34bf6c5d544b51
diff --git a/vendor/plugins/passenger_deploy b/vendor/plugins/passenger_deploy
new file mode 160000
index 0000000..13dd9d9
--- /dev/null
+++ b/vendor/plugins/passenger_deploy
@@ -0,0 +1 @@
+Subproject commit 13dd9d9f950a1918a09f0f20cb23668d6cd70052
|
hiroshi/inventory
|
1e9daebb2d4ab0702a0c06f47598f9d8e1baac02
|
add user_name search combo box, etc
|
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ac9ef8a..d96e225 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,27 +1,27 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# TODO: to be plugin
# TODO: implement FormTagHelper like version
def auto_complete_combo_box_tag(name, options, value = nil, tag_options = {}, completion_options = {})
array = options.to_json
value ||= params[name]
(completion_options[:skip_style] ? "" : auto_complete_stylesheet) +
text_field_tag(name, value, tag_options) +
content_tag("div", "", :id => "#{name}_auto_complete", :class => "auto_complete") +
- javascript_tag("var #{name}_auto_completer = new Autocompleter.LocalCombo('#{name}', '#{name}_auto_complete', #{array}, {frequency:0.1, partialSearch:true, fullSearch:true});") +
+ javascript_tag("var #{name}_auto_completer = new Autocompleter.LocalCombo('#{name}', '#{name}_auto_complete', #{array}, {frequency:0.1, partialSearch:true, fullSearch:true, partialChars:1});") +
link_to_function("â¼", "#{name}_auto_completer.toggle();", :style => "text-decoration:none; border:thin solid gray")
# TODO: to be more pretty button (i.e. use image)
end
# def render_field(builder, method, label=nil, &block)
# #label ||= t("activerecord.attributes.#{builder.object.class.name.underscore}.#{method}")
# label ||= t("activerecord.attributes.#{builder.object_name}.#{method}")
# <<-END
# <tr>
# <td><label for='#{builder.object_name}_#{method}' >#{label}:</label></td>
# <td>#{block_given? ? yield : builder.text_field(method)}</td>
# </tr>
# END
# end
end
diff --git a/app/models/asset.rb b/app/models/asset.rb
index d214ab3..92144c9 100644
--- a/app/models/asset.rb
+++ b/app/models/asset.rb
@@ -1,21 +1,28 @@
class Asset < ActiveRecord::Base
# developer
belongs_to :developer
validates_presence_of :developer_name
smart_delegate :developer, :name, :strip_spaces => true
# group
belongs_to :group
# utilization
has_many :utilizations, :order => "started_on DESC", :dependent => :destroy
has_one :utilization, :order => "started_on DESC" # means "current"
# scopes
named_scope :user_id, lambda{|user_id|
+ # NOTE: If you use join, old utilizations belongs to assets can satisfy given condition,
+ # NOTE: I don't have any resolution other than using subquery yet.
+ # {:joins => :utilization, :conditions => ["utilizations.user_id = ?", user_id]}
{:conditions => ["(SELECT user_id FROM utilizations WHERE asset_id = assets.id ORDER BY started_on DESC LIMIT 1) = ?", user_id]}
}
+ named_scope :user_login, lambda{|user_login|
+ # {:joins => {:utilization => :user}, :conditions => ["users.login = ?", user_login]}
+ {:conditions => ["(SELECT users.login FROM utilizations LEFT JOIN users ON users.id = utilizations.user_id WHERE asset_id = assets.id ORDER BY started_on DESC LIMIT 1) %% ?", user_login]}
+ }
named_scope :developer_name, lambda{|developer_name|
{:joins => :developer, :conditions => ["developers.name %% ?", developer_name]}
}
end
diff --git a/app/views/assets/_index.html.erb b/app/views/assets/_index.html.erb
index e19738a..ed6eab4 100644
--- a/app/views/assets/_index.html.erb
+++ b/app/views/assets/_index.html.erb
@@ -1,18 +1,18 @@
<table>
<tr>
- <th> </th>
+ <th>ID</th>
<th><%= h t("activerecord.attributes.asset.product_name") %></th>
<th><%= h t("activerecord.attributes.asset.developer_name") %></th>
<th><%= h t("activerecord.attributes.asset.model_number") %></th>
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
</tr>
<% assets.each do |asset| %>
<tr class='<%= cycle "", "even" %>'>
<td><%= link_to "##{asset.id}", asset_path(asset) %></td>
<td><%= h(asset.product_name) %></td>
<td><%= h asset.developer_name %></td>
<td><%= h asset.model_number %></td>
<td><%= link_to_unless asset.utilization.user.blank?, h(asset.utilization.user.try(:login)), user_assets_path(asset.utilization.user) %></td>
</tr>
<% end %>
</table>
diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb
index 530714a..4dbfc21 100644
--- a/app/views/assets/index.html.erb
+++ b/app/views/assets/index.html.erb
@@ -1,8 +1,13 @@
<%= render :partial => "menu" %>
<% form_tag "", :method => "get" do %>
- ã¡ã¼ã«ã¼: <%= auto_complete_combo_box_tag "developer_name", Developer.find(:all).map(&:name) %>
+ <%= t("activerecord.attributes.asset.developer_name") %>:
+ <%= auto_complete_combo_box_tag "developer_name", Developer.find(:all).map(&:name) %>
+
+ <%= t("activerecord.attributes.asset.user_login") %>:
+ <%= auto_complete_combo_box_tag "user_login", User.find(:all).map(&:login) %>
+
<%= submit_tag "filter" %>
<% end %>
<%= render :partial => "index", :locals => {:assets => @assets} %>
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index 5de6cd8..d1c9ca8 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1,64 +1,65 @@
ja:
create: ç»é²
update: æ´æ°
delete: åé¤
today: 仿¥
no_user: å©ç¨è
ãªã
sessions:
new: ãã°ã¤ã³
users:
new: ã¦ã¼ã¶ã¼ç»é²
assets:
index: æ©æä¸è¦§
new: æ©æç»é²
create: æ©æç»é²
show: æ©æ
members:
index: å©ç¨è
new: å©ç¨è
ç»é²
utilizations:
children: ä»å±æ©æ
revisions: å©ç¨å±¥æ´
activerecord:
models:
user: "å©ç¨è
"
member: "å©ç¨è
"
asset: "æ©æ"
utilization: "å©ç¨æ
å ±"
attributes:
user:
login: "ãã°ã¤ã³å"
email: "ã¡ã¼ã«ã¢ãã¬ã¹"
name: "åå"
password: "ãã¹ã¯ã¼ã"
password_confirmation: "ãã¹ã¯ã¼ã確èª"
asset:
developer_name: "ã¡ã¼ã«ã¼"
product_name: "製åå"
model_number: "åçª"
utilization: "å©ç¨æ
å ±"
+ user_login: "å©ç¨è
"
utilization:
user_id: "å©ç¨è
"
description: "åè"
started_on: "éå§æ¥"
parent_id: "æ¥ç¶å
"
errors:
template:
header: "" # {{count}} errors prohibited this user from being saved
body: "" # There were problems with the following fields
messages:
blank: "ãæå®ãã¦ãã ãã"
too_short: "ã®é·ããè¶³ãã¾ãã"
models:
user:
attributes:
group_id:
blank: "ãæå®ãã¦ãã ãã"
asset:
attributes:
utilization:
invalid: "ãæ£ããããã¾ãã"
|
hiroshi/inventory
|
237764325936be5863bc3b2688df607ddc0c2a7b
|
add coverage directory to be git ignored
|
diff --git a/.gitignore b/.gitignore
index 61e82f2..c085f7b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
log/*.log
db/development_structure.sql
+coverage
|
hiroshi/inventory
|
aa94f266fb280b3e4de23499a322431c83505e48
|
* added rcov_rails plugin * wrote assets_controller_test
|
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb
index af1cead..64c8a26 100644
--- a/app/controllers/assets_controller.rb
+++ b/app/controllers/assets_controller.rb
@@ -1,80 +1,79 @@
class AssetsController < ApplicationController
before_filter :login_required
before_filter :new_asset, :only => [:new, :create]
before_filter :set_asset, :only => [:show, :update, :destroy]
# FIXME
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_asset_developer_name]
def index
-# raise current_group.assets.respond_to?(:proxy_owner).inspect
@assets = current_group.assets.params_scope(params)
end
def new
render :action => "show"
end
def create
if @asset.valid? && @utilization.valid?
@asset.save!
redirect_to assets_path
else
render :action => "show"
end
end
def show
# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @asset.utilization], :order => "revision DESC")
# @utilizations = @utilization.revisions
@utilizations = @asset.utilizations
end
def update
if @asset.valid? && @utilization.valid?
ActiveRecord::Base.transaction do
# replace utilization if user is altered
if Utilization.new(params[:utilization]).user_id != @asset.utilization.user_id
@asset.utilization = current_group.utilizations.build(params[:utilization])
@utilization.asset = @asset
else
@utilization.update_attributes!(params[:utilization])
end
@asset.update_attributes!(params[:asset])
end
redirect_to assets_path
else
render :action => "show"
end
end
def destroy
@asset.destroy
redirect_to assets_path
end
# TODO: to be a REST action
def auto_complete_for_asset_developer_name
name = params[:asset]["developer_name"]
# OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
# @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
@developers = Developer.find(:all, :conditions => ["name ~* ?", name])
if @developers.blank?
render :nothing => true
else
render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
end
end
private
def new_asset
@asset = current_group.assets.build(params[:asset])
@asset.utilization = @utilization = current_group.utilizations.build(params[:utilization])
@utilization.asset = @asset
end
def set_asset
@asset = current_user.group.assets.find_by_id(params[:id]) or raise NotFoundError
@utilization = @asset.utilization || @asset.build_utilization
end
end
diff --git a/doc/README_FOR_DEVELOPER b/doc/README_FOR_DEVELOPER
index f70fbc4..6c9536d 100644
--- a/doc/README_FOR_DEVELOPER
+++ b/doc/README_FOR_DEVELOPER
@@ -1,25 +1,28 @@
Before rading this, read README_FOR_APP first.
= Maintenance
This application depends on many plugins.
Those plugins other than home brewed ones, managed with 'git submodule', may be need update by re-installing.
To update plugins:
script/plugin install --force {URL}
== home brewed
script-refactor.git
Provides script/refactor.
== redhillonrails_core and dependants
git://github.com/harukizaemon/redhillonrails_core.git
git://github.com/harukizaemon/foreign_key_migrations.git
git://github.com/harukizaemon/schema_validations.git
== rails spin-offs
git://github.com/rails/acts_as_tree.git
git://github.com/rails/auto_complete.git
== RESTful Authentication
git://github.com/technoweenie/restful-authentication.git
+
+== etc
+http://svn.codahale.com/rails_rcov
diff --git a/lib/tasks/ludia.rake b/lib/tasks/ludia.rake
new file mode 100644
index 0000000..5b5812d
--- /dev/null
+++ b/lib/tasks/ludia.rake
@@ -0,0 +1,15 @@
+# Credits:
+# darashi: http://d.hatena.ne.jp/darashi/20071129/1196307189
+
+# namespace :db do
+# namespace :test do
+# namespace :ludia do
+# task :install => :environment do
+# dbname = ActiveRecord::Base.configurations["test"]["database"]
+# sh "psql -f `pg_config --sharedir`/pgsenna2.sql #{dbname}"
+# end
+# end
+# task :clone => %w(test:ludia:install)
+# task :clone_structure => %w(test:ludia:install)
+# end
+# end
diff --git a/test/fixtures/assets.yml b/test/fixtures/assets.yml
index 5bf0293..7f3de6e 100644
--- a/test/fixtures/assets.yml
+++ b/test/fixtures/assets.yml
@@ -1,7 +1,6 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-# one:
-# column: value
-#
-# two:
-# column: value
+macbook:
+ group: one
+ developer: apple
+ product_name: MacBook
diff --git a/test/fixtures/developers.yml b/test/fixtures/developers.yml
index 5bf0293..c57494b 100644
--- a/test/fixtures/developers.yml
+++ b/test/fixtures/developers.yml
@@ -1,7 +1,7 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-# one:
-# column: value
-#
-# two:
-# column: value
+apple:
+ name: Apple Inc
+
+panasonic:
+ name: Panasonic
diff --git a/test/fixtures/utilizations.yml b/test/fixtures/utilizations.yml
index 5bf0293..f44f0aa 100644
--- a/test/fixtures/utilizations.yml
+++ b/test/fixtures/utilizations.yml
@@ -1,7 +1,6 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-# one:
-# column: value
-#
-# two:
-# column: value
+quentin_uses_macbook:
+ group: one
+ asset: macbook
+ user: quentin
diff --git a/test/functional/assets_controller_test.rb b/test/functional/assets_controller_test.rb
index 62eb4a5..868fe96 100644
--- a/test/functional/assets_controller_test.rb
+++ b/test/functional/assets_controller_test.rb
@@ -1,8 +1,61 @@
require 'test_helper'
class AssetsControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+ test "index" do
+ login_as :quentin
+ get :index
+ assert_response :success
+
+ assert_operator 0, :<, assigns(:assets).size
+ end
+
+ test "new" do
+ login_as :quentin
+ get :new
+ assert_response :success
+ end
+
+ test "create and show" do
+ login_as :quentin
+ post :create, :asset => {:developer_name => developers(:apple).name, :product_name => "PowerBook"}
+ assert_valid assigns(:asset)
+ assert_redirected_to assets_path
+
+ get :show, :id => assigns(:asset).id
+ assert_response :success
+ assert_equal 1, assigns(:asset).utilizations.size
+ end
+
+ test "show" do
+ login_as :quentin
+ get :show, :id => assets(:macbook).id
+ assert_response :success
+ end
+
+ test "update" do
+ assert_equal "MacBook", assets(:macbook).product_name
+
+ login_as :quentin
+ put :update, :id => assets(:macbook).id, :asset => {:product_name => "MacBook Pro"}
+ assert_redirected_to assets_path
+
+ assert_equal "MacBook Pro", assets(:macbook, true).product_name
+ end
+
+ test "destroy" do
+ login_as :quentin
+ delete :destroy, :id => assets(:macbook).id
+ assert_redirected_to assets_path
+
+ assert_raise(ActiveRecord::RecordNotFound){ assets(:macbook, true) }
+ end
+
+ test "auto_complete_for_asset_developer_name" do
+ login_as :quentin
+ get :auto_complete_for_asset_developer_name, :asset => {:developer_name => "app"}
+ assert_response :success
+
+ assert assigns(:developers).include?(developers(:apple))
+ assert !assigns(:developers).include?(developers(:panasonic))
end
end
diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb
index e53bcd8..fd9f713 100644
--- a/test/functional/sessions_controller_test.rb
+++ b/test/functional/sessions_controller_test.rb
@@ -1,82 +1,78 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'sessions_controller'
# Re-raise errors caught by the controller.
class SessionsController; def rescue_action(e) raise e end; end
class SessionsControllerTest < ActionController::TestCase
- # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
- # Then, you can remove it from this and the units test.
- include AuthenticatedTestHelper
-
- fixtures :users
+# fixtures :users
def test_should_login_and_redirect
post :create, :login => 'quentin', :password => 'monkey'
assert session[:user_id]
assert_response :redirect
end
def test_should_fail_login_and_not_redirect
post :create, :login => 'quentin', :password => 'bad password'
assert_nil session[:user_id]
assert_response :success
end
def test_should_logout
login_as :quentin
get :destroy
assert_nil session[:user_id]
assert_response :redirect
end
def test_should_remember_me
@request.cookies["auth_token"] = nil
post :create, :login => 'quentin', :password => 'monkey', :remember_me => "1"
assert_not_nil @response.cookies["auth_token"]
end
def test_should_not_remember_me
@request.cookies["auth_token"] = nil
post :create, :login => 'quentin', :password => 'monkey', :remember_me => "0"
puts @response.cookies["auth_token"]
assert @response.cookies["auth_token"].blank?
end
def test_should_delete_token_on_logout
login_as :quentin
get :destroy
assert @response.cookies["auth_token"].blank?
end
def test_should_login_with_cookie
users(:quentin).remember_me
@request.cookies["auth_token"] = cookie_for(:quentin)
get :new
assert @controller.send(:logged_in?)
end
def test_should_fail_expired_cookie_login
users(:quentin).remember_me
users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago
@request.cookies["auth_token"] = cookie_for(:quentin)
get :new
assert [email protected](:logged_in?)
end
def test_should_fail_cookie_login
users(:quentin).remember_me
@request.cookies["auth_token"] = auth_token('invalid_auth_token')
get :new
assert [email protected](:logged_in?)
end
protected
def auth_token(token)
CGI::Cookie.new('name' => 'auth_token', 'value' => token)
end
def cookie_for(user)
auth_token users(user).remember_token
end
end
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 367bfbd..c81707c 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -1,61 +1,57 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'users_controller'
# Re-raise errors caught by the controller.
class UsersController; def rescue_action(e) raise e end; end
class UsersControllerTest < ActionController::TestCase
- # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead
- # Then, you can remove it from this and the units test.
- include AuthenticatedTestHelper
-
fixtures :users
def test_should_allow_signup
assert_difference 'User.count' do
create_user
assert_response :redirect
end
end
def test_should_require_login_on_signup
assert_no_difference 'User.count' do
create_user(:login => nil)
assert assigns(:user).errors.on(:login)
assert_response :success
end
end
def test_should_require_password_on_signup
assert_no_difference 'User.count' do
create_user(:password => nil)
assert assigns(:user).errors.on(:password)
assert_response :success
end
end
def test_should_require_password_confirmation_on_signup
assert_no_difference 'User.count' do
create_user(:password_confirmation => nil)
assert assigns(:user).errors.on(:password_confirmation)
assert_response :success
end
end
def test_should_require_email_on_signup
assert_no_difference 'User.count' do
create_user(:email => nil)
assert assigns(:user).errors.on(:email)
assert_response :success
end
end
protected
def create_user(options = {})
post :create, :user => { :login => 'quire', :email => '[email protected]',
:password => 'quire69', :password_confirmation => 'quire69' }.merge(options)
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 9f19269..be677cd 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,38 +1,38 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test database remains unchanged so your fixtures don't have to be reloaded
# between every test method. Fewer database queries means faster tests.
#
# Read Mike Clark's excellent walkthrough at
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
#
# Every Active Record database supports transactions except MyISAM tables
# in MySQL. Turn off transactional fixtures in this case; however, if you
# don't care one way or the other, switching from MyISAM to InnoDB tables
# is recommended.
#
# The only drawback to using transactional fixtures is when you actually
# need to test transactions. Since your test is bracketed by a transaction,
# any transactions started in your code will be automatically rolled back.
self.use_transactional_fixtures = true
# Instantiated fixtures are slow, but give you @david where otherwise you
# would need people(:david). If you don't want to migrate your existing
# test cases which use the @david style and don't mind the speed hit (each
# instantiated fixtures translates to a database query per test method),
# then set this back to true.
self.use_instantiated_fixtures = false
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
- # Add more helper methods to be used by all tests here...
+ include AuthenticatedTestHelper
end
diff --git a/test/unit/asset_test.rb b/test/unit/asset_test.rb
index 063f114..68b7036 100644
--- a/test/unit/asset_test.rb
+++ b/test/unit/asset_test.rb
@@ -1,13 +1,13 @@
require 'test_helper'
class AssetTest < ActiveSupport::TestCase
test "developer_name" do
# test setter and getter
assert_equal 0, Developer.count(:conditions => {:name => "Apple"})
- asset = Asset.create!(:group => groups(:one), :developer_name => "Apple")
+ asset = Asset.create!(:group => groups(:one), :developer_name => "Apple", :product_name => "Macbook")
assert_equal "Apple", asset.developer_name
assert_equal 1, Developer.count(:conditions => {:name => "Apple"})
asset = Asset.find(asset.id)
assert_equal "Apple", asset.developer_name
end
end
diff --git a/vendor/plugins/rails_rcov/MIT-LICENSE b/vendor/plugins/rails_rcov/MIT-LICENSE
new file mode 100644
index 0000000..c61f2c8
--- /dev/null
+++ b/vendor/plugins/rails_rcov/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2006 Coda Hale
+
+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.
diff --git a/vendor/plugins/rails_rcov/README b/vendor/plugins/rails_rcov/README
new file mode 100644
index 0000000..eb9d84c
--- /dev/null
+++ b/vendor/plugins/rails_rcov/README
@@ -0,0 +1,86 @@
+ = rails_rcov plugin for Rails
+
+rails_rcov provides easy-to-use Rake tasks to determine the code coverage of
+your unit, functional, and integration tests using Mauricio Fernandez's rcov
+tool.
+
+== Installation
+
+First, install rcov from Mauricio's web site
+[http://eigenclass.org/hiki.rb?rcov]. Make sure it's on your system path, so
+that typing +rcov+ on the command line actually runs it. THIS PLUGIN DOESN'T DO
+ANYTHING BESIDES GENERATE ERRORS UNLESS YOU INSTALL RCOV FIRST. RCOV CONTAINS
+ALL THE MAGIC, THIS PLUGIN JUST RUNS IT.
+
+Second, install this plugin. If your project is source-controlled by Subversion
+(which it should be, really), the easiest way to install this is via Rails'
+plugin script:
+
+ ./script/plugin install -x http://svn.codahale.com/rails_rcov
+
+If you're not using Subversion, or if you don't want it adding
+<tt>svn:externals</tt> in your project, remove the <tt>-x</tt> switch:
+
+ ./script/plugin install http://svn.codahale.com/rails_rcov
+
+== Usage
+
+For each <tt>test:blah</tt> task you have for your Rails project, rails_rcov
+adds two more: <tt>test:blah:rcov</tt> and <tt>test:blah:clobber_rcov</tt>.
+
+Running <tt>rake test:units:rcov</tt>, for example, will run your unit tests
+through rcov and write the code coverage reports to
+<tt>your_rails_app/coverage/units</tt>.
+
+Running <tt>test:units:clobber_rcov</tt> will erase the generated report for the
+unit tests.
+
+Each rcov task takes two optional parameters: RCOV_PARAMS, whose argument is
+passed along to rcov, and SHOW_ONLY, which limits the files displayed in the
+report.
+
+RCOV_PARAMS:
+ # sort by coverage
+ rake test:units:rcov RCOV_PARAMS="--sort=coverage"
+
+ # show callsites and hide fully covered files
+ rake test:units:rcov RCOV_PARAMS="--callsites --only-uncovered"
+
+Check the rcov documentation for more details.
+
+SHOW_ONLY is a comma-separated list of the files you'd like to see. Right now
+there are four types of files rake_rcov recognizes: models, helpers,
+controllers, and lib. These can be abbreviated to their first letters:
+
+ # only show files from app/models
+ rake test:units:rcov SHOW_ONLY=models
+
+ # only show files from app/helpers and app/controllers
+ rake test:units:rcov SHOW_ONLY=helpers,controllers
+
+ # only show files from app/helpers and app/controllers, with less typing
+ rake test:units:rcov SHOW_ONLY=h,c
+
+Please note that rails_rcov has only been tested with a Bash shell, and any
+other environment could well explode in your face. If you're having trouble
+getting this to work on Windows, please take the time to figure out what's not
+working. Most of the time it boils down to the different ways the Window shell
+and the Bash shell escape metacharacters. Play around with the way rcov_rake
+escapes data (like on line 73, or 78) and send me a fix. I don't have a working
+Windows environment anymore, so leaving it up to me won't solve anything. ;-)
+
+== Resources
+
+=== Subversion
+
+* http://svn.codahale.com/rails_rcov
+
+=== Blog
+
+* http://blog.codahale.com
+
+== Credits
+
+Written by Coda Hale <[email protected]>. Thanks to Nils Franzen for a Win32
+escaping patch. Thanks to Alex Wayne for suggesting how to make SHOW_ONLY not be
+useless.
\ No newline at end of file
diff --git a/vendor/plugins/rails_rcov/tasks/rails_rcov.rake b/vendor/plugins/rails_rcov/tasks/rails_rcov.rake
new file mode 100644
index 0000000..4fd798d
--- /dev/null
+++ b/vendor/plugins/rails_rcov/tasks/rails_rcov.rake
@@ -0,0 +1,150 @@
+# This File Uses Magic
+# ====================
+# Here's an example of how this file works. As an example, let's say you typed
+# this into your terminal:
+#
+# $ rake --tasks
+#
+# The rake executable goes through all the various places .rake files can be,
+# accumulates them all, and then runs them. When this file is loaded by Rake,
+# it iterates through all the tasks, and for each task named 'test:blah' adds
+# test:blah:rcov and test:blah:rcov_clobber.
+#
+# So you've seen all the tasks, and you type this into your terminal:
+#
+# $ rake test:units:rcov
+#
+# Rake does the same thing as above, but it runs the test:units:rcov task, which
+# pretty much just does this:
+#
+# $ ruby [this file] [the test you want to run] [some options]
+#
+# Now this file is run via the Ruby interpreter, and after glomming up the
+# options, it acts just like the Rake executable, with a slight difference: it
+# passes all the arguments to rcov, not ruby, so all your unit tests get some
+# rcov sweet loving.
+
+if ARGV.grep(/--run-rake-task=/).empty?
+ # Define all our Rake tasks
+
+ require 'rake/clean'
+ require 'rcov/rcovtask'
+
+ def to_rcov_task_sym(s)
+ s = s.gsub(/(test:)/,'')
+ s.empty? ? nil : s.intern
+ end
+
+ def to_rcov_task_name(s)
+ s = s.gsub(/(test:)/,'')
+ s =~ /s$/i ? s[0..-2] : s
+ end
+
+ def new_rcov_task(test_name)
+ output_dir = "./coverage/#{test_name.gsub('test:','')}"
+ CLOBBER.include(output_dir)
+
+ # Add a task to run the rcov process
+ desc "Run all #{to_rcov_task_name(test_name)} tests with Rcov to measure coverage"
+ task :rcov => [:clobber_rcov] do |t|
+ run_code = '"' << File.expand_path(__FILE__) << '"'
+ run_code << " --run-rake-task=#{test_name}"
+
+ params = String.new
+ if ENV['RCOV_PARAMS']
+ params << ENV['RCOV_PARAMS']
+ end
+
+ # rake test:units:rcov SHOW_ONLY=models,controllers,lib,helpers
+ # rake test:units:rcov SHOW_ONLY=m,c,l,h
+ if ENV['SHOW_ONLY']
+ show_only = ENV['SHOW_ONLY'].to_s.split(',').map{|x|x.strip}
+ if show_only.any?
+ reg_exp = []
+ for show_type in show_only
+ reg_exp << case show_type
+ when 'm', 'models' : 'app\/models'
+ when 'c', 'controllers' : 'app\/controllers'
+ when 'h', 'helpers' : 'app\/helpers'
+ when 'l', 'lib' : 'lib'
+ else
+ show_type
+ end
+ end
+ reg_exp.map!{ |m| "(#{m})" }
+ params << " -x \\\"^(?!#{reg_exp.join('|')})\\\""
+ end
+ end
+
+ unless params.empty?
+ run_code << " --rcov-params=\"#{params}\""
+ end
+
+ ruby run_code
+ end
+
+ # Add a task to clean up after ourselves
+ desc "Remove Rcov reports for #{to_rcov_task_name(test_name)} tests"
+ task :clobber_rcov do |t|
+ rm_r output_dir, :force => true
+ end
+
+ # Link our clobber task to the main one
+ task :clobber => [:clobber_rcov]
+ end
+
+ test_tasks = Rake::Task.tasks.select{ |t| t.comment && t.name =~ /^test/ }
+ for test_task in test_tasks
+ namespace :test do
+ if sym = to_rcov_task_sym(test_task.name)
+ namespace sym do
+ new_rcov_task(test_task.name)
+ end
+ end
+ end
+ end
+else
+ # Load rake tasks, hijack ruby, and redirect the task through rcov
+ require 'rubygems'
+ require 'rake'
+
+ module RcovTestSettings
+ class << self
+ attr_accessor :output_dir, :options
+ def to_params
+ "-o \"#{@output_dir}\" -T -x \"rubygems/*,rcov*\" --rails #{@options}"
+ end
+ end
+
+ # load options and arguments from command line
+ unless (cmd_line = ARGV.grep(/--rcov-params=/)).empty?
+ @options = cmd_line.first.gsub(/--rcov-params=/, '')
+ end
+ end
+
+ def is_windows?
+ processor, platform, *rest = RUBY_PLATFORM.split("-")
+ platform == 'mswin32'
+ end
+
+ # intercept what Rake *would* be doing with Ruby, and send it through Rcov instead
+ module RakeFileUtils
+ alias :ruby_without_rcov :ruby
+ def ruby(*args, &block)
+ cmd = (is_windows? ? 'rcov.cmd' : 'rcov') << " #{RcovTestSettings.to_params} #{args}"
+ status = sh(cmd, {}, &block)
+ puts "View the full results at <file://#{RcovTestSettings.output_dir}/index.html>"
+ return status
+ end
+ end
+
+ # read the test name and execute it (through Rcov)
+ unless (cmd_line = ARGV.grep(/--run-rake-task=/)).empty?
+ test_name = cmd_line.first.gsub(/--run-rake-task=/,'')
+ ARGV.clear; ARGV << test_name
+ RcovTestSettings.output_dir = File.expand_path("./coverage/#{test_name.gsub('test:','')}")
+ Rake.application.run
+ else
+ raise "No test to execute!"
+ end
+end
\ No newline at end of file
|
hiroshi/inventory
|
4fdbb075d451ac62c4f686011e58a09cf10a632c
|
* implement params_scope * experimentally implement "auto complete combobox"
|
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb
index c7f987b..af1cead 100644
--- a/app/controllers/assets_controller.rb
+++ b/app/controllers/assets_controller.rb
@@ -1,85 +1,80 @@
class AssetsController < ApplicationController
before_filter :login_required
before_filter :new_asset, :only => [:new, :create]
before_filter :set_asset, :only => [:show, :update, :destroy]
# FIXME
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_asset_developer_name]
def index
- # TODO: refactor and generalize as find
- options = {:include => :developer, :order => "assets.id ASC"}
- if user_id = params[:user_id]
- # TODO: to avoid sub query it would good having current flag on utilizations
- options[:conditions] = ["(SELECT user_id FROM utilizations WHERE asset_id = assets.id ORDER BY started_on DESC LIMIT 1) = ?", user_id]
- end
- @assets = current_group.assets.find(:all, options)
+# raise current_group.assets.respond_to?(:proxy_owner).inspect
+ @assets = current_group.assets.params_scope(params)
end
def new
render :action => "show"
end
def create
if @asset.valid? && @utilization.valid?
@asset.save!
redirect_to assets_path
else
render :action => "show"
end
end
def show
# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @asset.utilization], :order => "revision DESC")
# @utilizations = @utilization.revisions
@utilizations = @asset.utilizations
end
def update
if @asset.valid? && @utilization.valid?
ActiveRecord::Base.transaction do
# replace utilization if user is altered
if Utilization.new(params[:utilization]).user_id != @asset.utilization.user_id
@asset.utilization = current_group.utilizations.build(params[:utilization])
@utilization.asset = @asset
else
@utilization.update_attributes!(params[:utilization])
end
@asset.update_attributes!(params[:asset])
end
redirect_to assets_path
else
render :action => "show"
end
end
def destroy
@asset.destroy
redirect_to assets_path
end
# TODO: to be a REST action
def auto_complete_for_asset_developer_name
name = params[:asset]["developer_name"]
# OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
# @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
@developers = Developer.find(:all, :conditions => ["name ~* ?", name])
if @developers.blank?
render :nothing => true
else
render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
end
end
private
def new_asset
@asset = current_group.assets.build(params[:asset])
@asset.utilization = @utilization = current_group.utilizations.build(params[:utilization])
@utilization.asset = @asset
end
def set_asset
@asset = current_user.group.assets.find_by_id(params[:id]) or raise NotFoundError
@utilization = @asset.utilization || @asset.build_utilization
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1271505..ac9ef8a 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,13 +1,27 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
+ # TODO: to be plugin
+ # TODO: implement FormTagHelper like version
+ def auto_complete_combo_box_tag(name, options, value = nil, tag_options = {}, completion_options = {})
+ array = options.to_json
+ value ||= params[name]
+
+ (completion_options[:skip_style] ? "" : auto_complete_stylesheet) +
+ text_field_tag(name, value, tag_options) +
+ content_tag("div", "", :id => "#{name}_auto_complete", :class => "auto_complete") +
+ javascript_tag("var #{name}_auto_completer = new Autocompleter.LocalCombo('#{name}', '#{name}_auto_complete', #{array}, {frequency:0.1, partialSearch:true, fullSearch:true});") +
+ link_to_function("â¼", "#{name}_auto_completer.toggle();", :style => "text-decoration:none; border:thin solid gray")
+ # TODO: to be more pretty button (i.e. use image)
+ end
+
# def render_field(builder, method, label=nil, &block)
# #label ||= t("activerecord.attributes.#{builder.object.class.name.underscore}.#{method}")
# label ||= t("activerecord.attributes.#{builder.object_name}.#{method}")
# <<-END
# <tr>
# <td><label for='#{builder.object_name}_#{method}' >#{label}:</label></td>
# <td>#{block_given? ? yield : builder.text_field(method)}</td>
# </tr>
# END
# end
end
diff --git a/app/models/asset.rb b/app/models/asset.rb
index a4e5b52..d214ab3 100644
--- a/app/models/asset.rb
+++ b/app/models/asset.rb
@@ -1,13 +1,21 @@
class Asset < ActiveRecord::Base
# developer
belongs_to :developer
validates_presence_of :developer_name
smart_delegate :developer, :name, :strip_spaces => true
# group
belongs_to :group
# utilization
has_many :utilizations, :order => "started_on DESC", :dependent => :destroy
has_one :utilization, :order => "started_on DESC" # means "current"
+
+ # scopes
+ named_scope :user_id, lambda{|user_id|
+ {:conditions => ["(SELECT user_id FROM utilizations WHERE asset_id = assets.id ORDER BY started_on DESC LIMIT 1) = ?", user_id]}
+ }
+ named_scope :developer_name, lambda{|developer_name|
+ {:joins => :developer, :conditions => ["developers.name %% ?", developer_name]}
+ }
end
diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb
index 82bd838..530714a 100644
--- a/app/views/assets/index.html.erb
+++ b/app/views/assets/index.html.erb
@@ -1,3 +1,8 @@
<%= render :partial => "menu" %>
+<% form_tag "", :method => "get" do %>
+ ã¡ã¼ã«ã¼: <%= auto_complete_combo_box_tag "developer_name", Developer.find(:all).map(&:name) %>
+ <%= submit_tag "filter" %>
+<% end %>
+
<%= render :partial => "index", :locals => {:assets => @assets} %>
diff --git a/app/views/shared/_head.html.erb b/app/views/shared/_head.html.erb
index 8efa550..4b5e247 100644
--- a/app/views/shared/_head.html.erb
+++ b/app/views/shared/_head.html.erb
@@ -1,7 +1,7 @@
<meta content='text/html; charset=utf-8' http-equiv='Content-type' />
<title><%= t("#{controller_name}.#{action_name}") %> - inventory</title>
<link rel="stylesheet" href="/stylesheets/blueprint/screen.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="/stylesheets/blueprint/print.css" type="text/css" media="print" />
<!--[if IE]><link rel="stylesheet" href="/stylesheets/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]-->
<link rel="stylesheet" href="/stylesheets/main.css" type="text/css" media="screen, projection" />
- <%= javascript_include_tag :defaults %>
+ <%= javascript_include_tag :defaults, "combobox" %>
diff --git a/config/initializers/modules/params_scope.rb b/config/initializers/modules/params_scope.rb
new file mode 100644
index 0000000..2f41092
--- /dev/null
+++ b/config/initializers/modules/params_scope.rb
@@ -0,0 +1,32 @@
+# Chainning up named scopes by a params hash.
+# Usage example:
+# class User
+# named_scope :age, lambda{|age| {:conditions => ["age = ?", age]}}
+# named_scope :city, lambda{|city| {:conditions => ["city = ?", city]}}
+# end
+#
+# class UsersController < ApplicationController
+# def index
+# params # => {:age => 30, :city => "Tokyo"}
+# @users = User.params_scope(params).find(:all) # => User.age(30).city("Tokyo").find(:all)
+
+module ParamsScope
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def params_scope(params)
+ self.scopes.keys.inject(self) do |ret, scope_name|
+ if (value = (params[scope_name] || params[scope_name.to_s])) && !value.blank?
+ ret.send(scope_name, *value)
+ else
+ ret
+ end
+ end
+ end
+ end
+end
+
+ActiveRecord::Base.send(:include, ParamsScope)
+ActiveRecord::Associations::AssociationProxy.send(:include, ParamsScope::ClassMethods)
diff --git a/public/javascripts/combobox.js b/public/javascripts/combobox.js
new file mode 100644
index 0000000..e2a2c46
--- /dev/null
+++ b/public/javascripts/combobox.js
@@ -0,0 +1,46 @@
+// LocalCombo provides 'toggle' method to show/hide autocompletion options.
+// This is intended to implement a combo-box.
+Autocompleter.LocalCombo = Class.create(Autocompleter.Local, {
+ version: 0.1, // implemented with script.aculo.us 1.8.0.1 (maybe) and prototype.js 1.6.0.3
+ initialize: function(element, update, array, options) {
+ this.baseInitialize(element, update, options);
+ this.options.array = array;
+ // re-register fixed 'onBlur' handler
+ Event.stopObserving(this.element, 'blur', false);
+ Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
+ },
+
+ onBlur: function(event) {
+ // Don't try to hide the list if it doesn't visible
+ if (Element.visible(this.update)) setTimeout(this.hide.bind(this), 250);
+ this.hasFocus = false;
+ this.active = false;
+ },
+
+ getAllChoices: function() {
+ var ret = [];
+ for (var i=0; i< this.options.array.length && ret.length < this.options.choices; i++) {
+ var elem = this.options.array[i];
+ ret.push("<li>" + elem + "</li>");
+ }
+ this.update.innerHTML = "<ul>" + ret.join('') + "</ul>";
+ this.entryCount = ret.length;
+ for (var i = 0; i < this.entryCount; i++) {
+ var entry = this.getEntry(i);
+ entry.autocompleteIndex = i;
+ this.addObservers(entry);
+ }
+ },
+
+ toggle: function() {
+ if (Element.visible(this.update)) {
+ this.hide();
+ } else {
+ this.tokenBounds = null;
+ this.element.focus();
+ //if (this.entryCount < 1) this.getAllChoices();
+ this.getAllChoices();
+ this.show();
+ }
+ }
+});
|
hiroshi/inventory
|
e87929280f144608536059d11685286f4184ecfd
|
split readme for developer from readme for app
|
diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP
index de8333b..8e04b55 100644
--- a/doc/README_FOR_APP
+++ b/doc/README_FOR_APP
@@ -1,21 +1,8 @@
-= Plugins
-This application depends on many plugins.
-To update plugins:
-script/plugin install --force {URL}
+= How to get started
+== Get home brewed plugins
+Some plugins, home brewed ones, are managed with 'git submodule' command.
+If you get this application from a git repository, before starting:
-== home brewed
-git://github.com/hiroshi/script-refactor.git
- Provides script/refactor.
-
-== redhillonrails_core and dependants
-git://github.com/harukizaemon/redhillonrails_core.git
-git://github.com/harukizaemon/foreign_key_migrations.git
-git://github.com/harukizaemon/schema_validations.git
-
-== rails spin-offs
-git://github.com/rails/acts_as_tree.git
-git://github.com/rails/auto_complete.git
-
-== RESTful Authentication
-git://github.com/technoweenie/restful-authentication.git
+ git submodule init
+ git submodule update
diff --git a/doc/README_FOR_DEVELOPER b/doc/README_FOR_DEVELOPER
new file mode 100644
index 0000000..f70fbc4
--- /dev/null
+++ b/doc/README_FOR_DEVELOPER
@@ -0,0 +1,25 @@
+Before rading this, read README_FOR_APP first.
+
+= Maintenance
+This application depends on many plugins.
+Those plugins other than home brewed ones, managed with 'git submodule', may be need update by re-installing.
+To update plugins:
+
+ script/plugin install --force {URL}
+
+== home brewed
+
+script-refactor.git
+ Provides script/refactor.
+
+== redhillonrails_core and dependants
+git://github.com/harukizaemon/redhillonrails_core.git
+git://github.com/harukizaemon/foreign_key_migrations.git
+git://github.com/harukizaemon/schema_validations.git
+
+== rails spin-offs
+git://github.com/rails/acts_as_tree.git
+git://github.com/rails/auto_complete.git
+
+== RESTful Authentication
+git://github.com/technoweenie/restful-authentication.git
|
hiroshi/inventory
|
6bcc8f560420148c262663f69f282c2e99f1ccd1
|
git submodule add git://github.com/hiroshi/script-refactor.git vendor/plugins/script-refactor git submodule init
|
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..708279d
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "vendor/plugins/script-refactor"]
+ path = vendor/plugins/script-refactor
+ url = git://github.com/hiroshi/script-refactor.git
diff --git a/vendor/plugins/script-refactor b/vendor/plugins/script-refactor
new file mode 160000
index 0000000..e2c674e
--- /dev/null
+++ b/vendor/plugins/script-refactor
@@ -0,0 +1 @@
+Subproject commit e2c674e8e2f81b5477b665149ff29df82644d9c7
|
hiroshi/inventory
|
8a28f0ba64548951859741d91823807fd22e0b22
|
script/plugin install --force git://github.com/hiroshi/script-refactor.git
|
diff --git a/script/refactor b/script/refactor
new file mode 100755
index 0000000..4388ef0
--- /dev/null
+++ b/script/refactor
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../vendor/plugins/script-refactor/lib/script_refactor'
diff --git a/vendor/plugins/script-refactor/MIT-LICENSE b/vendor/plugins/script-refactor/MIT-LICENSE
new file mode 100644
index 0000000..80935d7
--- /dev/null
+++ b/vendor/plugins/script-refactor/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 yakitara.com (Hiroshi Saito)
+
+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.
diff --git a/vendor/plugins/script-refactor/README b/vendor/plugins/script-refactor/README
new file mode 100644
index 0000000..ed321d4
--- /dev/null
+++ b/vendor/plugins/script-refactor/README
@@ -0,0 +1,16 @@
+script/refactor
+===============
+
+First of all, if you don't install this via:
+
+ script/plugin install git://github.com/hiroshi/script-refactor.git
+
+You may have no script/refactor. If so, do install.rb by hand:
+
+ ruby vendor/plugins/script-refactor/install.rb
+
+Next, just type:
+
+ script/refactor
+
+You will see the usage and other information of the script.
diff --git a/vendor/plugins/script-refactor/init.rb b/vendor/plugins/script-refactor/init.rb
new file mode 100644
index 0000000..3c19a74
--- /dev/null
+++ b/vendor/plugins/script-refactor/init.rb
@@ -0,0 +1 @@
+# Include hook code here
diff --git a/vendor/plugins/script-refactor/install.rb b/vendor/plugins/script-refactor/install.rb
new file mode 100644
index 0000000..dc458d6
--- /dev/null
+++ b/vendor/plugins/script-refactor/install.rb
@@ -0,0 +1,14 @@
+# install script/refactor
+require "fileutils"
+file_name = "script/refactor"
+puts " create #{file_name}"
+dst = File.dirname(__FILE__) + "/../../../#{file_name}"
+src = File.dirname(__FILE__) + "/#{file_name}"
+# open(path, "w") do |file|
+# file.print <<-SCRIPT
+# #!/usr/bin/env ruby
+# require File.dirname(__FILE__) + '/../vendor/plugins/script_refactor/lib/script_refactor'
+# SCRIPT
+# file.chmod(0755) # make it executable
+# end
+FileUtils.copy(src, dst)
diff --git a/vendor/plugins/script-refactor/lib/script_refactor.rb b/vendor/plugins/script-refactor/lib/script_refactor.rb
new file mode 100644
index 0000000..7cb7e57
--- /dev/null
+++ b/vendor/plugins/script-refactor/lib/script_refactor.rb
@@ -0,0 +1,111 @@
+=begin
+TODO:
+* Please refactor me
+* Ignore db directory and create migration?
+=end
+module Refactor
+ VERSION = "0.1"
+end
+# usage
+if ARGV.size != 3
+ puts <<-USAGE
+script-refactor #{Refactor::VERSION}
+
+Help refactoring application:
+* Renaming files with git, svn aware manner
+* Replacing class names, variable names as possible
+
+THIS SCRIPT MAY DESTRUCT FILES AND/OR DIRECTORIES OF YOUR RAILS APPLICATION.
+BE SURE YOUR CHANGES ARE COMMITED OR BACKED UP!
+
+Usage:
+ #{$0} type from to
+
+Possible types:
+
+ resource: Replace resouce name.
+
+Examples:
+ #{$0} resource user person
+
+ USAGE
+ exit 1
+end
+
+# main
+require "find"
+require "rubygems"
+require "activesupport"
+
+# arguments
+type, from, to = ARGV
+# scm
+case
+when File.directory?(".git")
+ scm = :git
+ def rename_cmd(src, dst); "git mv #{src} #{dst}"; end
+when File.directory?(".svn")
+ scm = :svn
+ def rename_cmd(src, dst); "svn mv #{src} #{dst}"; end
+else
+ def rename_cmd(src, dst); "mv #{src} #{dst}"; end
+end
+
+renames = {
+ "test/unit/#{from}_test.rb" => "test/unit/#{to}_test.rb",
+ "test/functional/#{from.pluralize}_controller_test.rb" => "test/functional/#{to.pluralize}_controller_test.rb",
+ "test/fixtures/#{from.pluralize}.yml" => "test/fixtures/#{to.pluralize}.yml",
+ "app/views/#{from.pluralize}" => "app/views/#{to.pluralize}",
+ "app/models/#{from}.rb" => "app/models/#{to}.rb",
+ "app/helpers/#{from.pluralize}_helper.rb" => "app/helpers/#{to.pluralize}_helper.rb",
+ "app/controllers/#{from.pluralize}_controller.rb" => "app/controllers/#{to.pluralize}_controller.rb",
+}
+
+puts "Renamming files and directories:"
+renames.each do |src, dst|
+ cmd = rename_cmd(src, dst)
+ if File.exist? src
+ puts cmd
+ `#{cmd}`
+ end
+end
+
+puts "\nReplacing class and variables:"
+replaces = {
+ from => to,
+ from.classify => to.classify,
+ from.pluralize => to.pluralize,
+ from.classify.pluralize => to.classify.pluralize,
+}
+replaces.each do |f,t|
+ puts "#{f} -> #{t}"
+end
+pattern = "(\\b|_)(#{replaces.keys.join("|")})(\\b|[_A-Z])"
+puts "pettern: /#{pattern}/"
+puts ""
+
+Find.find(".") do |path|
+ Find.prune if path =~ /\/(vendor|log|script|tmp|\.(git|\.svn))$/
+
+ if File.file? path
+ input = File.read(path)
+ # print replacing lines
+ input.each_with_index do |line, idx|
+ line.scan(/#{pattern}/).each do
+ puts "#{path}:#{idx+1}: #{line}"
+ end
+ end
+ # replace file content
+ open(path, "w") do |out|
+ out.print input.gsub(/#{pattern}/){ "#{$1}#{replaces[$2]}#{$3}"}
+ end
+ end
+end
+
+puts "\nNOTE: If you want to revert them:" if scm
+case scm
+when :git
+ puts " git reset --hard"
+when :svn
+ puts " svn revert -R ."
+end
diff --git a/vendor/plugins/script-refactor/script/refactor b/vendor/plugins/script-refactor/script/refactor
new file mode 100755
index 0000000..4388ef0
--- /dev/null
+++ b/vendor/plugins/script-refactor/script/refactor
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../vendor/plugins/script-refactor/lib/script_refactor'
diff --git a/vendor/plugins/script-refactor/uninstall.rb b/vendor/plugins/script-refactor/uninstall.rb
new file mode 100644
index 0000000..6620072
--- /dev/null
+++ b/vendor/plugins/script-refactor/uninstall.rb
@@ -0,0 +1,5 @@
+# uninstall script/refactor
+require "fileutils"
+file_name = "script/refactor"
+puts " rm #{file_name}"
+FileUtils.rm File.dirname(__FILE__) + "/../../../#{file_name}"
|
hiroshi/inventory
|
b9eae117f41b5a02982889b610407953af47374d
|
rename application name from kizai to inventory
|
diff --git a/app/views/shared/_head.html.erb b/app/views/shared/_head.html.erb
index c081721..8efa550 100644
--- a/app/views/shared/_head.html.erb
+++ b/app/views/shared/_head.html.erb
@@ -1,7 +1,7 @@
<meta content='text/html; charset=utf-8' http-equiv='Content-type' />
- <title><%= t("#{controller_name}.#{action_name}") %> - kizai</title>
+ <title><%= t("#{controller_name}.#{action_name}") %> - inventory</title>
<link rel="stylesheet" href="/stylesheets/blueprint/screen.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="/stylesheets/blueprint/print.css" type="text/css" media="print" />
<!--[if IE]><link rel="stylesheet" href="/stylesheets/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]-->
<link rel="stylesheet" href="/stylesheets/main.css" type="text/css" media="screen, projection" />
<%= javascript_include_tag :defaults %>
diff --git a/config/database.yml b/config/database.yml
index 1102d4b..497f7a5 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -1,23 +1,23 @@
development:
adapter: postgresql
encoding: unicode
- database: kizai_development
+ database: inventory_development
pool: 5
username: postgres
password:
test:
adapter: postgresql
encoding: unicode
- database: kizai_test
+ database: inventory_test
pool: 5
username: postgres
password:
production:
adapter: postgresql
encoding: unicode
- database: kizai_production
+ database: inventory_production
pool: 5
username: postgres
password:
|
hiroshi/inventory
|
721b5e39f715ca8ed9ff2a8c57f28064e86fb92d
|
* implement script/refactor and refactor "computer_asset" to "asset" * drop unusing computer_models
|
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 3641f66..15ee4f5 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -1,21 +1,21 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include HttpError
include AuthenticatedSystem
helper :all # include all helpers, all the time
protect_from_forgery # :secret => 'c23e808fd9c186e9a355fd6ff35899ae'
filter_parameter_logging :password
def index
- redirect_to computer_assets_path
+ redirect_to assets_path
end
def current_group
current_user.group
end
helper_method :current_group
end
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb
new file mode 100644
index 0000000..c7f987b
--- /dev/null
+++ b/app/controllers/assets_controller.rb
@@ -0,0 +1,85 @@
+class AssetsController < ApplicationController
+ before_filter :login_required
+ before_filter :new_asset, :only => [:new, :create]
+ before_filter :set_asset, :only => [:show, :update, :destroy]
+ # FIXME
+ skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_asset_developer_name]
+
+ def index
+ # TODO: refactor and generalize as find
+ options = {:include => :developer, :order => "assets.id ASC"}
+ if user_id = params[:user_id]
+ # TODO: to avoid sub query it would good having current flag on utilizations
+ options[:conditions] = ["(SELECT user_id FROM utilizations WHERE asset_id = assets.id ORDER BY started_on DESC LIMIT 1) = ?", user_id]
+ end
+ @assets = current_group.assets.find(:all, options)
+ end
+
+ def new
+ render :action => "show"
+ end
+
+ def create
+ if @asset.valid? && @utilization.valid?
+ @asset.save!
+ redirect_to assets_path
+ else
+ render :action => "show"
+ end
+ end
+
+ def show
+# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @asset.utilization], :order => "revision DESC")
+# @utilizations = @utilization.revisions
+ @utilizations = @asset.utilizations
+ end
+
+ def update
+ if @asset.valid? && @utilization.valid?
+ ActiveRecord::Base.transaction do
+ # replace utilization if user is altered
+ if Utilization.new(params[:utilization]).user_id != @asset.utilization.user_id
+ @asset.utilization = current_group.utilizations.build(params[:utilization])
+ @utilization.asset = @asset
+ else
+ @utilization.update_attributes!(params[:utilization])
+ end
+ @asset.update_attributes!(params[:asset])
+ end
+ redirect_to assets_path
+ else
+ render :action => "show"
+ end
+ end
+
+ def destroy
+ @asset.destroy
+ redirect_to assets_path
+ end
+
+ # TODO: to be a REST action
+ def auto_complete_for_asset_developer_name
+ name = params[:asset]["developer_name"]
+ # OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
+ # @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
+ @developers = Developer.find(:all, :conditions => ["name ~* ?", name])
+ if @developers.blank?
+ render :nothing => true
+ else
+ render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
+ end
+ end
+
+ private
+
+ def new_asset
+ @asset = current_group.assets.build(params[:asset])
+ @asset.utilization = @utilization = current_group.utilizations.build(params[:utilization])
+ @utilization.asset = @asset
+ end
+
+ def set_asset
+ @asset = current_user.group.assets.find_by_id(params[:id]) or raise NotFoundError
+ @utilization = @asset.utilization || @asset.build_utilization
+ end
+end
diff --git a/app/controllers/computer_assets_controller.rb b/app/controllers/computer_assets_controller.rb
deleted file mode 100644
index 3b3c99b..0000000
--- a/app/controllers/computer_assets_controller.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-class ComputerAssetsController < ApplicationController
- before_filter :login_required
- before_filter :new_computer_asset, :only => [:new, :create]
- before_filter :set_computer_asset, :only => [:show, :update, :destroy]
- # FIXME
- skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_computer_asset_developer_name]
-
- def index
- # TODO: refactor and generalize as find
- options = {:include => :developer, :order => "computer_assets.id ASC"}
- if user_id = params[:user_id]
- # TODO: to avoid sub query it would good having current flag on utilizations
- options[:conditions] = ["(SELECT user_id FROM utilizations WHERE computer_asset_id = computer_assets.id ORDER BY started_on DESC LIMIT 1) = ?", user_id]
- end
- @computer_assets = current_group.computer_assets.find(:all, options)
- end
-
- def new
- render :action => "show"
- end
-
- def create
- if @computer_asset.valid? && @utilization.valid?
- @computer_asset.save!
- redirect_to computer_assets_path
- else
- render :action => "show"
- end
- end
-
- def show
-# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @computer_asset.utilization], :order => "revision DESC")
-# @utilizations = @utilization.revisions
- @utilizations = @computer_asset.utilizations
- end
-
- def update
- if @computer_asset.valid? && @utilization.valid?
- ActiveRecord::Base.transaction do
- # replace utilization if user is altered
- if Utilization.new(params[:utilization]).user_id != @computer_asset.utilization.user_id
- @computer_asset.utilization = current_group.utilizations.build(params[:utilization])
- @utilization.computer_asset = @computer_asset
- else
- @utilization.update_attributes!(params[:utilization])
- end
- @computer_asset.update_attributes!(params[:computer_asset])
- end
- redirect_to computer_assets_path
- else
- render :action => "show"
- end
- end
-
- def destroy
- @computer_asset.destroy
- redirect_to computer_assets_path
- end
-
- # TODO: to be a REST action
- def auto_complete_for_computer_asset_developer_name
- name = params[:computer_asset]["developer_name"]
- # OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
- # @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
- @developers = Developer.find(:all, :conditions => ["name ~* ?", name])
- if @developers.blank?
- render :nothing => true
- else
- render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
- end
- end
-
- private
-
- def new_computer_asset
- @computer_asset = current_group.computer_assets.build(params[:computer_asset])
- @computer_asset.utilization = @utilization = current_group.utilizations.build(params[:utilization])
- @utilization.computer_asset = @computer_asset
- end
-
- def set_computer_asset
- @computer_asset = current_user.group.computer_assets.find_by_id(params[:id]) or raise NotFoundError
- @utilization = @computer_asset.utilization || @computer_asset.build_utilization
- end
-end
diff --git a/app/helpers/assets_helper.rb b/app/helpers/assets_helper.rb
new file mode 100644
index 0000000..9824bb4
--- /dev/null
+++ b/app/helpers/assets_helper.rb
@@ -0,0 +1,2 @@
+module AssetsHelper
+end
diff --git a/app/helpers/computer_assets_helper.rb b/app/helpers/computer_assets_helper.rb
deleted file mode 100644
index b4e5a27..0000000
--- a/app/helpers/computer_assets_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module ComputerAssetsHelper
-end
diff --git a/app/models/computer_asset.rb b/app/models/asset.rb
similarity index 89%
rename from app/models/computer_asset.rb
rename to app/models/asset.rb
index a1a7636..a4e5b52 100644
--- a/app/models/computer_asset.rb
+++ b/app/models/asset.rb
@@ -1,13 +1,13 @@
-class ComputerAsset < ActiveRecord::Base
+class Asset < ActiveRecord::Base
# developer
belongs_to :developer
validates_presence_of :developer_name
smart_delegate :developer, :name, :strip_spaces => true
# group
belongs_to :group
# utilization
has_many :utilizations, :order => "started_on DESC", :dependent => :destroy
has_one :utilization, :order => "started_on DESC" # means "current"
end
diff --git a/app/models/group.rb b/app/models/group.rb
index f22624b..2ce7b22 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1,5 +1,5 @@
class Group < ActiveRecord::Base
has_many :users, :dependent => :destroy
- has_many :computer_assets, :dependent => :destroy
+ has_many :assets, :dependent => :destroy
has_many :utilizations
end
diff --git a/app/models/utilization.rb b/app/models/utilization.rb
index 72bb85b..df8f740 100644
--- a/app/models/utilization.rb
+++ b/app/models/utilization.rb
@@ -1,15 +1,15 @@
class Utilization < ActiveRecord::Base
acts_as_tree
- belongs_to :computer_asset
+ belongs_to :asset
belongs_to :user
belongs_to :group
before_validation do |utilization|
- utilization.group_id ||= utilization.computer_asset.try(:group_id)
+ utilization.group_id ||= utilization.asset.try(:group_id)
end
include Revision::Model
- named_scope :include_asset, :include => :computer_asset
-# named_scope :include_asset_and_user, :include => [:computer_asset, :user]
+ named_scope :include_asset, :include => :asset
+# named_scope :include_asset_and_user, :include => [:asset, :user]
end
diff --git a/app/views/assets/_index.html.erb b/app/views/assets/_index.html.erb
new file mode 100644
index 0000000..e19738a
--- /dev/null
+++ b/app/views/assets/_index.html.erb
@@ -0,0 +1,18 @@
+<table>
+ <tr>
+ <th> </th>
+ <th><%= h t("activerecord.attributes.asset.product_name") %></th>
+ <th><%= h t("activerecord.attributes.asset.developer_name") %></th>
+ <th><%= h t("activerecord.attributes.asset.model_number") %></th>
+ <th><%= h t("activerecord.attributes.utilization.user_id") %></th>
+ </tr>
+ <% assets.each do |asset| %>
+ <tr class='<%= cycle "", "even" %>'>
+ <td><%= link_to "##{asset.id}", asset_path(asset) %></td>
+ <td><%= h(asset.product_name) %></td>
+ <td><%= h asset.developer_name %></td>
+ <td><%= h asset.model_number %></td>
+ <td><%= link_to_unless asset.utilization.user.blank?, h(asset.utilization.user.try(:login)), user_assets_path(asset.utilization.user) %></td>
+ </tr>
+ <% end %>
+</table>
diff --git a/app/views/assets/_menu.html.erb b/app/views/assets/_menu.html.erb
new file mode 100644
index 0000000..e6158c8
--- /dev/null
+++ b/app/views/assets/_menu.html.erb
@@ -0,0 +1,3 @@
+<%= link_to t("assets.index"), assets_path %>
+|
+<%= link_to t("assets.new"), new_asset_path %>
diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb
new file mode 100644
index 0000000..82bd838
--- /dev/null
+++ b/app/views/assets/index.html.erb
@@ -0,0 +1,3 @@
+<%= render :partial => "menu" %>
+
+<%= render :partial => "index", :locals => {:assets => @assets} %>
diff --git a/app/views/computer_assets/show.html.erb b/app/views/assets/show.html.erb
similarity index 74%
rename from app/views/computer_assets/show.html.erb
rename to app/views/assets/show.html.erb
index 5e8be63..3c658d0 100644
--- a/app/views/computer_assets/show.html.erb
+++ b/app/views/assets/show.html.erb
@@ -1,76 +1,76 @@
<%= render :partial => "menu" %>
-<% form_for @computer_asset, :builder => TableFormBuilder do |form| %>
+<% form_for @asset, :builder => TableFormBuilder do |form| %>
<div class="span-12">
<fieldset>
- <legend><%= t("activerecord.models.computer_asset") %></legend>
- <%= error_messages_for :computer_asset %>
+ <legend><%= t("activerecord.models.asset") %></legend>
+ <%= error_messages_for :asset %>
<table>
<% form.tr :developer_name do |method| %>
<%= text_field_with_auto_complete form.object_name, method %>
<% end %>
<% form.tr :product_name do |method| %>
<%= form.text_field method %>
<% end %>
<% form.tr :model_number do |method| %>
<%= form.text_field method %>
<% end %>
</table>
</fieldset>
</div>
<div class="span-12 last">
<fieldset>
<legend><%= t("activerecord.models.utilization") %></legend>
<%= error_messages_for :utilization %>
<table>
<% fields_for @utilization, :builder => TableFormBuilder do |utilization_fields| %>
<% utilization_fields.tr :user_id do |method| %>
<%= utilization_fields.collection_select method, current_user.group.users, :id, :login, :include_blank => t("no_user") %>
<% end %>
<% utilization_fields.tr :started_on do |method| %>
<%= utilization_fields.text_field method %>
<%= link_to_function t("today"), "$('utilization_started_on').value = '#{Date.today}'" %>
<% end %>
<% utilization_fields.tr :parent_id do |method| %>
- <%= utilization_fields.collection_select method, current_group.utilizations.include_asset.map{|u| [u.id, u.computer_asset.product_name]}, :first, :last, :include_blank => true %>
+ <%= utilization_fields.collection_select method, current_group.utilizations.include_asset.map{|u| [u.id, u.asset.product_name]}, :first, :last, :include_blank => true %>
<% end %>
<% utilization_fields.tr :description do |method| %>
<%= utilization_fields.text_field method %>
<% end %>
<% end %>
</table>
</fieldset>
</div>
<div class="clear" />
<div>
-<% unless @computer_asset.new_record? %>
- <span style="float:right"><%= link_to t("delete"), computer_asset_path(@computer_asset), :method => "delete" %></span>
+<% unless @asset.new_record? %>
+ <span style="float:right"><%= link_to t("delete"), asset_path(@asset), :method => "delete" %></span>
<% end %>
- <div style="text-align:center"><%= submit_tag t(@computer_asset.new_record? ? "create" : "update") %></div>
+ <div style="text-align:center"><%= submit_tag t(@asset.new_record? ? "create" : "update") %></div>
</div>
<% end %>
-<% unless @computer_asset.new_record? %>
+<% unless @asset.new_record? %>
<hr/>
<h3><%= t("utilizations.children") %></h3>
-<%= render :partial => "index", :locals => {:computer_assets => @utilization.children.map(&:computer_asset)} %>
+<%= render :partial => "index", :locals => {:assets => @utilization.children.map(&:asset)} %>
<h3><%= t("utilizations.revisions") %></h3>
<table>
<tr>
<!-- <th>revision</th> -->
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
<th><%= h t("activerecord.attributes.utilization.started_on") %></th>
<th><%= h t("activerecord.attributes.utilization.description") %></th>
</tr>
<% @utilizations.each do |utilization| %>
<tr class='<%= cycle "", "even" %>'>
<!-- <td><%#= utilization.revision %></td> -->
<td><%= link_to h(utilization.user.try(:login)), user_assets_path(utilization.user) %></td>
<td><%= h utilization.started_on %></td>
<td><%= h utilization.description %></td>
</tr>
<% end %>
</table>
<% end %>
diff --git a/app/views/computer_assets/_index.html.erb b/app/views/computer_assets/_index.html.erb
deleted file mode 100644
index a51f63f..0000000
--- a/app/views/computer_assets/_index.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-<table>
- <tr>
- <th> </th>
- <th><%= h t("activerecord.attributes.computer_asset.product_name") %></th>
- <th><%= h t("activerecord.attributes.computer_asset.developer_name") %></th>
- <th><%= h t("activerecord.attributes.computer_asset.model_number") %></th>
- <th><%= h t("activerecord.attributes.utilization.user_id") %></th>
- </tr>
- <% computer_assets.each do |computer_asset| %>
- <tr class='<%= cycle "", "even" %>'>
- <td><%= link_to "##{computer_asset.id}", computer_asset_path(computer_asset) %></td>
- <td><%= h(computer_asset.product_name) %></td>
- <td><%= h computer_asset.developer_name %></td>
- <td><%= h computer_asset.model_number %></td>
- <td><%= link_to_unless computer_asset.utilization.user.blank?, h(computer_asset.utilization.user.try(:login)), user_assets_path(computer_asset.utilization.user) %></td>
- </tr>
- <% end %>
-</table>
diff --git a/app/views/computer_assets/_menu.html.erb b/app/views/computer_assets/_menu.html.erb
deleted file mode 100644
index 7eba114..0000000
--- a/app/views/computer_assets/_menu.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%= link_to t("computer_assets.index"), computer_assets_path %>
-|
-<%= link_to t("computer_assets.new"), new_computer_asset_path %>
diff --git a/app/views/computer_assets/index.html.erb b/app/views/computer_assets/index.html.erb
deleted file mode 100644
index 876469a..0000000
--- a/app/views/computer_assets/index.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%= render :partial => "menu" %>
-
-<%= render :partial => "index", :locals => {:computer_assets => @computer_assets} %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index ad9575f..c67e017 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,23 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<%= render :partial => "/shared/head" %>
</head>
<body>
<div class="container" style="margin:0px 1em">
<%= render :partial => "/shared/header" %>
<hr/>
<ul class="h_menu">
- <li><%= link_to t("activerecord.models.computer_asset"), computer_assets_path %></li>
+ <li><%= link_to t("activerecord.models.asset"), assets_path %></li>
<li><%= link_to t("activerecord.models.member"), members_path %></li>
</ul>
<hr/>
<%= yield %>
</div>
</body>
</html>
diff --git a/app/views/members/index.html.erb b/app/views/members/index.html.erb
index 8d2354c..b8f099b 100644
--- a/app/views/members/index.html.erb
+++ b/app/views/members/index.html.erb
@@ -1,8 +1,8 @@
<%= link_to t("members.new"), new_member_path %>
<h2><%= t("members.index") %></h2>
<ul>
<% @users.each do |user| %>
- <li><%= h user.login %> <%= link_to t("computer_assets.index"), computer_assets_path(:user_id => user) %></li>
+ <li><%= h user.login %> <%= link_to t("assets.index"), assets_path(:user_id => user) %></li>
<% end %>
</ul>
diff --git a/app/views/members/show.html.erb b/app/views/members/show.html.erb
index 0e324fc..2de0de5 100644
--- a/app/views/members/show.html.erb
+++ b/app/views/members/show.html.erb
@@ -1,28 +1,28 @@
-<%= link_to t("members.index"), computer_assets_path %>
+<%= link_to t("members.index"), assets_path %>
<% form_for @user, :url => members_path, :builder => TableFormBuilder do |form| %>
<fieldset>
<legend><%= t("member") %></legend>
<%= error_messages_for form.object_name %>
<table>
<% form.tr :login do |method| %>
<%= form.text_field method %>
<% end %>
<% form.tr :email do |method| %>
<%= form.text_field method %>
<% end %>
<% form.tr :password do |method| %>
<%= form.password_field method %>
<% end %>
<% form.tr :password_confirmation do |method| %>
<%= form.password_field method %>
<% end %>
<!--
<% form.tr :name do |method| %>
<%= form.text_field method %>
<% end %>
-->
</table>
</fieldset>
<%= submit_tag t("create") %>
<% end %>
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index f1d35a0..5de6cd8 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1,64 +1,64 @@
ja:
create: ç»é²
update: æ´æ°
delete: åé¤
today: 仿¥
no_user: å©ç¨è
ãªã
sessions:
new: ãã°ã¤ã³
users:
new: ã¦ã¼ã¶ã¼ç»é²
- computer_assets:
+ assets:
index: æ©æä¸è¦§
new: æ©æç»é²
create: æ©æç»é²
show: æ©æ
members:
index: å©ç¨è
new: å©ç¨è
ç»é²
utilizations:
children: ä»å±æ©æ
revisions: å©ç¨å±¥æ´
activerecord:
models:
user: "å©ç¨è
"
member: "å©ç¨è
"
- computer_asset: "æ©æ"
+ asset: "æ©æ"
utilization: "å©ç¨æ
å ±"
attributes:
user:
login: "ãã°ã¤ã³å"
email: "ã¡ã¼ã«ã¢ãã¬ã¹"
name: "åå"
password: "ãã¹ã¯ã¼ã"
password_confirmation: "ãã¹ã¯ã¼ã確èª"
- computer_asset:
+ asset:
developer_name: "ã¡ã¼ã«ã¼"
product_name: "製åå"
model_number: "åçª"
utilization: "å©ç¨æ
å ±"
utilization:
user_id: "å©ç¨è
"
description: "åè"
started_on: "éå§æ¥"
parent_id: "æ¥ç¶å
"
errors:
template:
header: "" # {{count}} errors prohibited this user from being saved
body: "" # There were problems with the following fields
messages:
blank: "ãæå®ãã¦ãã ãã"
too_short: "ã®é·ããè¶³ãã¾ãã"
models:
user:
attributes:
group_id:
blank: "ãæå®ãã¦ãã ãã"
- computer_asset:
+ asset:
attributes:
utilization:
invalid: "ãæ£ããããã¾ãã"
diff --git a/config/routes.rb b/config/routes.rb
index a3ce7ad..e008790 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,64 +1,64 @@
ActionController::Routing::Routes.draw do |map|
map.resources :members
map.resources :groups
map.resources :developers
map.root :controller => "application", :action => "index"
map.resources :utilizations
- map.resources :computer_assets
- map.user_assets "/user/:user_id/computer_assets", :controller => "computer_assets", :action => "index"
+ map.resources :assets
+ map.user_assets "/user/:user_id/assets", :controller => "assets", :action => "index"
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'new'
map.resources :users
map.resource :session
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
# products.resources :sales, :collection => { :recent => :get }
# end
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing the them or commenting them out if you're using named routes and resources.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
diff --git a/db/migrate/20090115081929_create_initial_schema.rb b/db/migrate/20090115081929_create_initial_schema.rb
index f398ef0..fa14e1e 100644
--- a/db/migrate/20090115081929_create_initial_schema.rb
+++ b/db/migrate/20090115081929_create_initial_schema.rb
@@ -1,70 +1,65 @@
class CreateInitialSchema < ActiveRecord::Migration
def self.up
create_table "groups", :force => true do |t|
t.string :name
t.timestamps
end
create_table "users", :force => true do |t|
t.column :login, :string, :limit => 40
t.column :name, :string, :limit => 100, :default => '', :null => true
t.column :email, :string, :limit => 100
t.column :crypted_password, :string, :limit => 40
t.column :salt, :string, :limit => 40
t.column :created_at, :datetime
t.column :updated_at, :datetime
t.column :remember_token, :string, :limit => 40
t.column :remember_token_expires_at, :datetime
t.references :group, :null => false
end
add_index :users, :login, :unique => true
add_index :users, :group_id
create_table :developers do |t|
t.string :name, :null => false
t.timestamps
end
add_index :developers, :name, :unique => true
- create_table :computer_models do |t|
- t.timestamps
- end
-
- create_table :computer_assets do |t|
+ create_table :assets do |t|
t.references :developer
t.string :model_number
t.string :product_name, :null => false
t.references :group, :null => false
t.string :asset_number
t.timestamps
end
create_table :utilizations, :revision => true do |t|
- t.references :computer_asset, :null => false
+ t.references :asset, :null => false
t.references :user
t.references :group, :null => false
t.text :description
t.date :started_on
t.integer :parent_id, :references => :utilizations
t.timestamps
end
# TODO: extend create_table so that reviisons table is automaticaly created
# create_table :utilization_revisions, :primary_key => false do |t|
# t.integer :id, :null => false
# t.integer :revision, :null => false
-# t.references :computer_asset, :user, :null => false
+# t.references :asset, :user, :null => false
# t.string :host_name
# t.timestamps
# end
# add_index :utilization_revisions, [:id, :revision], :unique => true
end
def self.down
drop_table :utilizations
- drop_table :computer_assets
- drop_table :computer_models
+ drop_table :assets
drop_table :developers
drop_table :users
drop_table :groups
end
end
diff --git a/script/refactor b/script/refactor
new file mode 100755
index 0000000..b790b8d
--- /dev/null
+++ b/script/refactor
@@ -0,0 +1,104 @@
+#!/usr/bin/env ruby
+=begin
+TODO:
+* Please refactor me
+* Ignore db directory and create migration?
+=end
+
+# usage
+if ARGV.size != 3
+ puts <<-USAGE
+Refactoring application.
+* Renaming files with git, svn aware manner
+* Replacing class names, variable names as possible
+
+THIS SCRIPT MAY DESTRACT FILES AND/OR DIRECTORIES. BE SURE YOUR CHANGES ARE COMMITED OR BACKED UP!
+
+Usage:
+ #{$0} type from to
+
+Possible types:
+ resource: Replace resouce name, including file names.
+
+Examples:
+ #{$0} resource user person
+
+ USAGE
+ exit
+end
+
+# main
+require "find"
+require "rubygems"
+require "activesupport"
+
+# arguments
+type, from, to = ARGV
+# scm
+case
+when File.directory?(".git")
+ scm = :git
+ def rename_cmd(src, dst); "git mv #{src} #{dst}"; end
+when File.directory?(".svn")
+ scm = :svn
+ def rename_cmd(src, dst); "svn mv #{src} #{dst}"; end
+end
+
+renames = {
+ "test/unit/#{from}_test.rb" => "test/unit/#{to}_test.rb",
+ "test/functional/#{from.pluralize}_controller_test.rb" => "test/functional/#{to.pluralize}_controller_test.rb",
+ "test/fixtures/#{from.pluralize}.yml" => "test/fixtures/#{to.pluralize}.yml",
+ "app/views/#{from.pluralize}" => "app/views/#{to.pluralize}",
+ "app/models/#{from}.rb" => "app/models/#{to}.rb",
+ "app/helpers/#{from.pluralize}_helper.rb" => "app/helpers/#{to.pluralize}_helper.rb",
+ "app/controllers/#{from.pluralize}_controller.rb" => "app/controllers/#{to.pluralize}_controller.rb",
+}
+
+puts "Renamming files and directories:"
+renames.each do |src, dst|
+ cmd = rename_cmd(src, dst)
+ if File.exist? src
+ puts cmd
+ `#{cmd}`
+ end
+end
+
+puts "\nReplacing class and variables:"
+replaces = {
+ from => to,
+ from.classify => to.classify,
+ from.pluralize => to.pluralize,
+ from.classify.pluralize => to.classify.pluralize,
+}
+replaces.each do |f,t|
+ puts "#{f} -> #{t}"
+end
+pattern = "(\\b|_)(#{replaces.keys.join("|")})(\\b|[_A-Z])"
+puts "pettern: /#{pattern}/"
+puts ""
+
+Find.find(".") do |path|
+ Find.prune if path =~ /\/(vendor|log|script|tmp|\.(git|\.svn))$/
+
+ if File.file? path
+ input = File.read(path)
+ # print replacing lines
+ input.each_with_index do |line, idx|
+ line.scan(/#{pattern}/).each do
+ puts "#{path}:#{idx+1}: #{line}"
+ end
+ end
+ # replace file content
+ open(path, "w") do |out|
+ out.print input.gsub(/#{pattern}/){ "#{$1}#{replaces[$2]}#{$3}"}
+ end
+ end
+end
+
+puts "\nNOTE: If you want to revert them:"
+case scm
+when :git
+ puts " git reset --hard"
+when :svn
+ puts " svn revert -R ."
+end
diff --git a/test/fixtures/computer_assets.yml b/test/fixtures/assets.yml
similarity index 100%
rename from test/fixtures/computer_assets.yml
rename to test/fixtures/assets.yml
diff --git a/test/functional/computer_assets_controller_test.rb b/test/functional/assets_controller_test.rb
similarity index 63%
rename from test/functional/computer_assets_controller_test.rb
rename to test/functional/assets_controller_test.rb
index 88d1d13..62eb4a5 100644
--- a/test/functional/computer_assets_controller_test.rb
+++ b/test/functional/assets_controller_test.rb
@@ -1,8 +1,8 @@
require 'test_helper'
-class ComputerAssetsControllerTest < ActionController::TestCase
+class AssetsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
diff --git a/test/unit/computer_asset_test.rb b/test/unit/asset_test.rb
similarity index 64%
rename from test/unit/computer_asset_test.rb
rename to test/unit/asset_test.rb
index c3fd575..063f114 100644
--- a/test/unit/computer_asset_test.rb
+++ b/test/unit/asset_test.rb
@@ -1,13 +1,13 @@
require 'test_helper'
-class ComputerAssetTest < ActiveSupport::TestCase
+class AssetTest < ActiveSupport::TestCase
test "developer_name" do
# test setter and getter
assert_equal 0, Developer.count(:conditions => {:name => "Apple"})
- asset = ComputerAsset.create!(:group => groups(:one), :developer_name => "Apple")
+ asset = Asset.create!(:group => groups(:one), :developer_name => "Apple")
assert_equal "Apple", asset.developer_name
assert_equal 1, Developer.count(:conditions => {:name => "Apple"})
- asset = ComputerAsset.find(asset.id)
+ asset = Asset.find(asset.id)
assert_equal "Apple", asset.developer_name
end
end
diff --git a/test/unit/utilization_test.rb b/test/unit/utilization_test.rb
index 1725315..b617a4f 100644
--- a/test/unit/utilization_test.rb
+++ b/test/unit/utilization_test.rb
@@ -1,8 +1,8 @@
require 'test_helper'
class UtilizationTest < ActiveSupport::TestCase
test "revisions" do
- utilization = Utilization.create!(:computer_asset => ComputerAsset.create!(:product_name => "PC", :model_number => "A1", :group => groups(:one), :developer_name => "Anon"))
+ utilization = Utilization.create!(:asset => Asset.create!(:product_name => "PC", :model_number => "A1", :group => groups(:one), :developer_name => "Anon"))
assert_equal 1, utilization.revisions.size
end
end
|
hiroshi/inventory
|
4e37788511b8b46d4545c19091d645cb40093b69
|
script/destroy computer_model
|
diff --git a/app/controllers/computer_models_controller.rb b/app/controllers/computer_models_controller.rb
deleted file mode 100644
index 7b1c85f..0000000
--- a/app/controllers/computer_models_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class ComputerModelsController < ApplicationController
-end
diff --git a/app/helpers/computer_models_helper.rb b/app/helpers/computer_models_helper.rb
deleted file mode 100644
index 5153567..0000000
--- a/app/helpers/computer_models_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module ComputerModelsHelper
-end
diff --git a/app/models/computer_model.rb b/app/models/computer_model.rb
deleted file mode 100644
index 126eff8..0000000
--- a/app/models/computer_model.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class ComputerModel < ActiveRecord::Base
-end
diff --git a/config/routes.rb b/config/routes.rb
index 9e3cd4a..a3ce7ad 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,66 +1,64 @@
ActionController::Routing::Routes.draw do |map|
map.resources :members
map.resources :groups
map.resources :developers
map.root :controller => "application", :action => "index"
map.resources :utilizations
map.resources :computer_assets
map.user_assets "/user/:user_id/computer_assets", :controller => "computer_assets", :action => "index"
- map.resources :computer_models
-
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'new'
map.resources :users
map.resource :session
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
# products.resources :sales, :collection => { :recent => :get }
# end
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing the them or commenting them out if you're using named routes and resources.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
diff --git a/test/fixtures/computer_models.yml b/test/fixtures/computer_models.yml
deleted file mode 100644
index 5bf0293..0000000
--- a/test/fixtures/computer_models.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-
-# one:
-# column: value
-#
-# two:
-# column: value
diff --git a/test/functional/computer_models_controller_test.rb b/test/functional/computer_models_controller_test.rb
deleted file mode 100644
index ce1d35d..0000000
--- a/test/functional/computer_models_controller_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class ComputerModelsControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/unit/computer_model_test.rb b/test/unit/computer_model_test.rb
deleted file mode 100644
index 34bc8ac..0000000
--- a/test/unit/computer_model_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class ComputerModelTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
|
hiroshi/inventory
|
a95e0e943e77aa45f26a5bdfb0be89bd418ceec5
|
* fix a bug: assets of old utilizations' user appeared in user filtered assets#index * add user_assets route
|
diff --git a/app/controllers/computer_assets_controller.rb b/app/controllers/computer_assets_controller.rb
index 2f40dd8..3b3c99b 100644
--- a/app/controllers/computer_assets_controller.rb
+++ b/app/controllers/computer_assets_controller.rb
@@ -1,85 +1,85 @@
class ComputerAssetsController < ApplicationController
before_filter :login_required
before_filter :new_computer_asset, :only => [:new, :create]
before_filter :set_computer_asset, :only => [:show, :update, :destroy]
# FIXME
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_computer_asset_developer_name]
def index
# TODO: refactor and generalize as find
options = {:include => :developer, :order => "computer_assets.id ASC"}
if user_id = params[:user_id]
- options[:joins] = "LEFT JOIN utilizations u ON u.computer_asset_id = computer_assets.id"
- options[:conditions] = ["u.user_id = ?", user_id]
+ # TODO: to avoid sub query it would good having current flag on utilizations
+ options[:conditions] = ["(SELECT user_id FROM utilizations WHERE computer_asset_id = computer_assets.id ORDER BY started_on DESC LIMIT 1) = ?", user_id]
end
@computer_assets = current_group.computer_assets.find(:all, options)
end
def new
render :action => "show"
end
def create
if @computer_asset.valid? && @utilization.valid?
@computer_asset.save!
redirect_to computer_assets_path
else
render :action => "show"
end
end
def show
# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @computer_asset.utilization], :order => "revision DESC")
# @utilizations = @utilization.revisions
@utilizations = @computer_asset.utilizations
end
def update
if @computer_asset.valid? && @utilization.valid?
ActiveRecord::Base.transaction do
# replace utilization if user is altered
if Utilization.new(params[:utilization]).user_id != @computer_asset.utilization.user_id
@computer_asset.utilization = current_group.utilizations.build(params[:utilization])
@utilization.computer_asset = @computer_asset
else
@utilization.update_attributes!(params[:utilization])
end
@computer_asset.update_attributes!(params[:computer_asset])
end
redirect_to computer_assets_path
else
render :action => "show"
end
end
def destroy
@computer_asset.destroy
redirect_to computer_assets_path
end
# TODO: to be a REST action
def auto_complete_for_computer_asset_developer_name
name = params[:computer_asset]["developer_name"]
# OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
# @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
@developers = Developer.find(:all, :conditions => ["name ~* ?", name])
if @developers.blank?
render :nothing => true
else
render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
end
end
private
def new_computer_asset
@computer_asset = current_group.computer_assets.build(params[:computer_asset])
@computer_asset.utilization = @utilization = current_group.utilizations.build(params[:utilization])
@utilization.computer_asset = @computer_asset
end
def set_computer_asset
@computer_asset = current_user.group.computer_assets.find_by_id(params[:id]) or raise NotFoundError
@utilization = @computer_asset.utilization || @computer_asset.build_utilization
end
end
diff --git a/app/views/computer_assets/_index.html.erb b/app/views/computer_assets/_index.html.erb
index bd80def..a51f63f 100644
--- a/app/views/computer_assets/_index.html.erb
+++ b/app/views/computer_assets/_index.html.erb
@@ -1,18 +1,18 @@
<table>
<tr>
<th> </th>
<th><%= h t("activerecord.attributes.computer_asset.product_name") %></th>
<th><%= h t("activerecord.attributes.computer_asset.developer_name") %></th>
<th><%= h t("activerecord.attributes.computer_asset.model_number") %></th>
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
</tr>
<% computer_assets.each do |computer_asset| %>
<tr class='<%= cycle "", "even" %>'>
<td><%= link_to "##{computer_asset.id}", computer_asset_path(computer_asset) %></td>
<td><%= h(computer_asset.product_name) %></td>
<td><%= h computer_asset.developer_name %></td>
<td><%= h computer_asset.model_number %></td>
- <td><%= h computer_asset.try(:utilization, :user, :login) %></td>
+ <td><%= link_to_unless computer_asset.utilization.user.blank?, h(computer_asset.utilization.user.try(:login)), user_assets_path(computer_asset.utilization.user) %></td>
</tr>
<% end %>
</table>
diff --git a/app/views/computer_assets/show.html.erb b/app/views/computer_assets/show.html.erb
index d0f141e..5e8be63 100644
--- a/app/views/computer_assets/show.html.erb
+++ b/app/views/computer_assets/show.html.erb
@@ -1,76 +1,76 @@
<%= render :partial => "menu" %>
<% form_for @computer_asset, :builder => TableFormBuilder do |form| %>
<div class="span-12">
<fieldset>
<legend><%= t("activerecord.models.computer_asset") %></legend>
<%= error_messages_for :computer_asset %>
<table>
<% form.tr :developer_name do |method| %>
<%= text_field_with_auto_complete form.object_name, method %>
<% end %>
<% form.tr :product_name do |method| %>
<%= form.text_field method %>
<% end %>
<% form.tr :model_number do |method| %>
<%= form.text_field method %>
<% end %>
</table>
</fieldset>
</div>
<div class="span-12 last">
<fieldset>
<legend><%= t("activerecord.models.utilization") %></legend>
<%= error_messages_for :utilization %>
<table>
<% fields_for @utilization, :builder => TableFormBuilder do |utilization_fields| %>
<% utilization_fields.tr :user_id do |method| %>
<%= utilization_fields.collection_select method, current_user.group.users, :id, :login, :include_blank => t("no_user") %>
<% end %>
<% utilization_fields.tr :started_on do |method| %>
<%= utilization_fields.text_field method %>
<%= link_to_function t("today"), "$('utilization_started_on').value = '#{Date.today}'" %>
<% end %>
<% utilization_fields.tr :parent_id do |method| %>
<%= utilization_fields.collection_select method, current_group.utilizations.include_asset.map{|u| [u.id, u.computer_asset.product_name]}, :first, :last, :include_blank => true %>
<% end %>
<% utilization_fields.tr :description do |method| %>
<%= utilization_fields.text_field method %>
<% end %>
<% end %>
</table>
</fieldset>
</div>
<div class="clear" />
<div>
<% unless @computer_asset.new_record? %>
<span style="float:right"><%= link_to t("delete"), computer_asset_path(@computer_asset), :method => "delete" %></span>
<% end %>
<div style="text-align:center"><%= submit_tag t(@computer_asset.new_record? ? "create" : "update") %></div>
</div>
<% end %>
<% unless @computer_asset.new_record? %>
<hr/>
<h3><%= t("utilizations.children") %></h3>
<%= render :partial => "index", :locals => {:computer_assets => @utilization.children.map(&:computer_asset)} %>
<h3><%= t("utilizations.revisions") %></h3>
<table>
<tr>
<!-- <th>revision</th> -->
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
<th><%= h t("activerecord.attributes.utilization.started_on") %></th>
<th><%= h t("activerecord.attributes.utilization.description") %></th>
</tr>
<% @utilizations.each do |utilization| %>
<tr class='<%= cycle "", "even" %>'>
<!-- <td><%#= utilization.revision %></td> -->
- <td><%= h utilization.user.try(:login) %></td>
+ <td><%= link_to h(utilization.user.try(:login)), user_assets_path(utilization.user) %></td>
<td><%= h utilization.started_on %></td>
<td><%= h utilization.description %></td>
</tr>
<% end %>
</table>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index f33b74f..9e3cd4a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,65 +1,66 @@
ActionController::Routing::Routes.draw do |map|
map.resources :members
map.resources :groups
map.resources :developers
map.root :controller => "application", :action => "index"
map.resources :utilizations
map.resources :computer_assets
+ map.user_assets "/user/:user_id/computer_assets", :controller => "computer_assets", :action => "index"
map.resources :computer_models
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'new'
map.resources :users
map.resource :session
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
# products.resources :sales, :collection => { :recent => :get }
# end
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing the them or commenting them out if you're using named routes and resources.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
|
hiroshi/inventory
|
2781e6819cf5246e43bebd03e5814f309c4e75fa
|
make an asset has many utilizations.
|
diff --git a/app/controllers/computer_assets_controller.rb b/app/controllers/computer_assets_controller.rb
index 48d0143..2f40dd8 100644
--- a/app/controllers/computer_assets_controller.rb
+++ b/app/controllers/computer_assets_controller.rb
@@ -1,78 +1,85 @@
class ComputerAssetsController < ApplicationController
before_filter :login_required
before_filter :new_computer_asset, :only => [:new, :create]
before_filter :set_computer_asset, :only => [:show, :update, :destroy]
# FIXME
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_computer_asset_developer_name]
def index
# TODO: refactor and generalize as find
options = {:include => :developer, :order => "computer_assets.id ASC"}
if user_id = params[:user_id]
options[:joins] = "LEFT JOIN utilizations u ON u.computer_asset_id = computer_assets.id"
options[:conditions] = ["u.user_id = ?", user_id]
end
@computer_assets = current_group.computer_assets.find(:all, options)
end
def new
render :action => "show"
end
def create
if @computer_asset.valid? && @utilization.valid?
@computer_asset.save!
redirect_to computer_assets_path
else
render :action => "show"
end
end
def show
# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @computer_asset.utilization], :order => "revision DESC")
- @utilizations = @utilization.revisions
+# @utilizations = @utilization.revisions
+ @utilizations = @computer_asset.utilizations
end
def update
if @computer_asset.valid? && @utilization.valid?
ActiveRecord::Base.transaction do
+ # replace utilization if user is altered
+ if Utilization.new(params[:utilization]).user_id != @computer_asset.utilization.user_id
+ @computer_asset.utilization = current_group.utilizations.build(params[:utilization])
+ @utilization.computer_asset = @computer_asset
+ else
+ @utilization.update_attributes!(params[:utilization])
+ end
@computer_asset.update_attributes!(params[:computer_asset])
- @utilization.update_attributes!(params[:utilization])
end
redirect_to computer_assets_path
else
render :action => "show"
end
end
def destroy
@computer_asset.destroy
redirect_to computer_assets_path
end
# TODO: to be a REST action
def auto_complete_for_computer_asset_developer_name
name = params[:computer_asset]["developer_name"]
# OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
# @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
@developers = Developer.find(:all, :conditions => ["name ~* ?", name])
if @developers.blank?
render :nothing => true
else
render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
end
end
private
def new_computer_asset
@computer_asset = current_group.computer_assets.build(params[:computer_asset])
@computer_asset.utilization = @utilization = current_group.utilizations.build(params[:utilization])
@utilization.computer_asset = @computer_asset
end
def set_computer_asset
@computer_asset = current_user.group.computer_assets.find_by_id(params[:id]) or raise NotFoundError
@utilization = @computer_asset.utilization || @computer_asset.build_utilization
end
end
diff --git a/app/models/computer_asset.rb b/app/models/computer_asset.rb
index 3b3fd26..a1a7636 100644
--- a/app/models/computer_asset.rb
+++ b/app/models/computer_asset.rb
@@ -1,13 +1,13 @@
class ComputerAsset < ActiveRecord::Base
# developer
belongs_to :developer
validates_presence_of :developer_name
smart_delegate :developer, :name, :strip_spaces => true
# group
belongs_to :group
# utilization
- has_one :utilization, :order => "created_at DESC", :dependent => :destroy
-# validates_associated :utilization
+ has_many :utilizations, :order => "started_on DESC", :dependent => :destroy
+ has_one :utilization, :order => "started_on DESC" # means "current"
end
diff --git a/app/views/computer_assets/show.html.erb b/app/views/computer_assets/show.html.erb
index 8919346..d0f141e 100644
--- a/app/views/computer_assets/show.html.erb
+++ b/app/views/computer_assets/show.html.erb
@@ -1,76 +1,76 @@
<%= render :partial => "menu" %>
<% form_for @computer_asset, :builder => TableFormBuilder do |form| %>
<div class="span-12">
<fieldset>
<legend><%= t("activerecord.models.computer_asset") %></legend>
<%= error_messages_for :computer_asset %>
<table>
<% form.tr :developer_name do |method| %>
<%= text_field_with_auto_complete form.object_name, method %>
<% end %>
<% form.tr :product_name do |method| %>
<%= form.text_field method %>
<% end %>
<% form.tr :model_number do |method| %>
<%= form.text_field method %>
<% end %>
</table>
</fieldset>
</div>
<div class="span-12 last">
<fieldset>
<legend><%= t("activerecord.models.utilization") %></legend>
<%= error_messages_for :utilization %>
<table>
<% fields_for @utilization, :builder => TableFormBuilder do |utilization_fields| %>
<% utilization_fields.tr :user_id do |method| %>
<%= utilization_fields.collection_select method, current_user.group.users, :id, :login, :include_blank => t("no_user") %>
<% end %>
<% utilization_fields.tr :started_on do |method| %>
<%= utilization_fields.text_field method %>
<%= link_to_function t("today"), "$('utilization_started_on').value = '#{Date.today}'" %>
<% end %>
<% utilization_fields.tr :parent_id do |method| %>
<%= utilization_fields.collection_select method, current_group.utilizations.include_asset.map{|u| [u.id, u.computer_asset.product_name]}, :first, :last, :include_blank => true %>
<% end %>
<% utilization_fields.tr :description do |method| %>
<%= utilization_fields.text_field method %>
<% end %>
<% end %>
</table>
</fieldset>
</div>
<div class="clear" />
<div>
<% unless @computer_asset.new_record? %>
<span style="float:right"><%= link_to t("delete"), computer_asset_path(@computer_asset), :method => "delete" %></span>
<% end %>
<div style="text-align:center"><%= submit_tag t(@computer_asset.new_record? ? "create" : "update") %></div>
</div>
<% end %>
<% unless @computer_asset.new_record? %>
<hr/>
<h3><%= t("utilizations.children") %></h3>
<%= render :partial => "index", :locals => {:computer_assets => @utilization.children.map(&:computer_asset)} %>
<h3><%= t("utilizations.revisions") %></h3>
<table>
<tr>
- <th>revision</th>
+<!-- <th>revision</th> -->
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
<th><%= h t("activerecord.attributes.utilization.started_on") %></th>
<th><%= h t("activerecord.attributes.utilization.description") %></th>
</tr>
<% @utilizations.each do |utilization| %>
<tr class='<%= cycle "", "even" %>'>
- <td><%= utilization.revision %></td>
+<!-- <td><%#= utilization.revision %></td> -->
<td><%= h utilization.user.try(:login) %></td>
<td><%= h utilization.started_on %></td>
<td><%= h utilization.description %></td>
</tr>
<% end %>
</table>
<% end %>
|
hiroshi/inventory
|
88ef820ac03f55791bfd8a5f6fa2ab5ef64768ae
|
some implementation (i fogot)
|
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 4233415..3641f66 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -1,24 +1,21 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
- class BadRequestError < Exception; end
- class ForbiddenError < Exception; end
- class NotFoundError < Exception; end
-
+ include HttpError
include AuthenticatedSystem
helper :all # include all helpers, all the time
protect_from_forgery # :secret => 'c23e808fd9c186e9a355fd6ff35899ae'
filter_parameter_logging :password
def index
redirect_to computer_assets_path
end
def current_group
current_user.group
end
helper_method :current_group
end
diff --git a/app/controllers/computer_assets_controller.rb b/app/controllers/computer_assets_controller.rb
index 1f2cb92..48d0143 100644
--- a/app/controllers/computer_assets_controller.rb
+++ b/app/controllers/computer_assets_controller.rb
@@ -1,65 +1,78 @@
class ComputerAssetsController < ApplicationController
before_filter :login_required
before_filter :new_computer_asset, :only => [:new, :create]
- before_filter :set_computer_asset, :only => [:show, :update]
+ before_filter :set_computer_asset, :only => [:show, :update, :destroy]
# FIXME
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_computer_asset_developer_name]
def index
# TODO: refactor and generalize as find
options = {:include => :developer, :order => "computer_assets.id ASC"}
if user_id = params[:user_id]
options[:joins] = "LEFT JOIN utilizations u ON u.computer_asset_id = computer_assets.id"
options[:conditions] = ["u.user_id = ?", user_id]
end
@computer_assets = current_group.computer_assets.find(:all, options)
end
def new
render :action => "show"
end
def create
- @computer_asset.save!
- redirect_to computer_assets_path
+ if @computer_asset.valid? && @utilization.valid?
+ @computer_asset.save!
+ redirect_to computer_assets_path
+ else
+ render :action => "show"
+ end
end
def show
# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @computer_asset.utilization], :order => "revision DESC")
- @utilizations = @computer_asset.utilization.revisions
+ @utilizations = @utilization.revisions
end
-
+
def update
- ActiveRecord::Base.transaction do
- @computer_asset.update_attributes!(params[:computer_asset])
- @computer_asset.utilization.update_attributes!(params[:utilization])
+ if @computer_asset.valid? && @utilization.valid?
+ ActiveRecord::Base.transaction do
+ @computer_asset.update_attributes!(params[:computer_asset])
+ @utilization.update_attributes!(params[:utilization])
+ end
+ redirect_to computer_assets_path
+ else
+ render :action => "show"
end
+ end
+ def destroy
+ @computer_asset.destroy
redirect_to computer_assets_path
end
# TODO: to be a REST action
def auto_complete_for_computer_asset_developer_name
name = params[:computer_asset]["developer_name"]
# OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
# @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
@developers = Developer.find(:all, :conditions => ["name ~* ?", name])
if @developers.blank?
render :nothing => true
else
render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
end
end
private
def new_computer_asset
@computer_asset = current_group.computer_assets.build(params[:computer_asset])
- # @computer_asset.group_id = current_user.group_id
- @computer_asset.build_utilization(params[:utilization])
+ @computer_asset.utilization = @utilization = current_group.utilizations.build(params[:utilization])
+ @utilization.computer_asset = @computer_asset
end
def set_computer_asset
@computer_asset = current_user.group.computer_assets.find_by_id(params[:id]) or raise NotFoundError
+ @utilization = @computer_asset.utilization || @computer_asset.build_utilization
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 08bc3ff..1271505 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,13 +1,13 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
- def render_field(builder, method, label=nil, &block)
- #label ||= t("activerecord.attributes.#{builder.object.class.name.underscore}.#{method}")
- label ||= t("activerecord.attributes.#{builder.object_name}.#{method}")
- <<-END
- <tr>
- <td><label for='#{builder.object_name}_#{method}' >#{label}:</label></td>
- <td>#{block_given? ? yield : builder.text_field(method)}</td>
- </tr>
- END
- end
+# def render_field(builder, method, label=nil, &block)
+# #label ||= t("activerecord.attributes.#{builder.object.class.name.underscore}.#{method}")
+# label ||= t("activerecord.attributes.#{builder.object_name}.#{method}")
+# <<-END
+# <tr>
+# <td><label for='#{builder.object_name}_#{method}' >#{label}:</label></td>
+# <td>#{block_given? ? yield : builder.text_field(method)}</td>
+# </tr>
+# END
+# end
end
diff --git a/app/models/computer_asset.rb b/app/models/computer_asset.rb
index 2b543ba..3b3fd26 100644
--- a/app/models/computer_asset.rb
+++ b/app/models/computer_asset.rb
@@ -1,12 +1,13 @@
class ComputerAsset < ActiveRecord::Base
# developer
belongs_to :developer
- # TODO: may be separated as "smart delegate"
+ validates_presence_of :developer_name
smart_delegate :developer, :name, :strip_spaces => true
# group
belongs_to :group
- has_one :utilization, :order => "created_at DESC"
-# has_many :utilization_histories
+ # utilization
+ has_one :utilization, :order => "created_at DESC", :dependent => :destroy
+# validates_associated :utilization
end
diff --git a/app/models/group.rb b/app/models/group.rb
index f2aa75a..f22624b 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1,5 +1,5 @@
class Group < ActiveRecord::Base
- has_many :users
- has_many :computer_assets
+ has_many :users, :dependent => :destroy
+ has_many :computer_assets, :dependent => :destroy
has_many :utilizations
end
diff --git a/app/models/utilization.rb b/app/models/utilization.rb
index 8c61aa2..72bb85b 100644
--- a/app/models/utilization.rb
+++ b/app/models/utilization.rb
@@ -1,10 +1,15 @@
class Utilization < ActiveRecord::Base
acts_as_tree
belongs_to :computer_asset
belongs_to :user
+ belongs_to :group
+ before_validation do |utilization|
+ utilization.group_id ||= utilization.computer_asset.try(:group_id)
+ end
+
include Revision::Model
named_scope :include_asset, :include => :computer_asset
# named_scope :include_asset_and_user, :include => [:computer_asset, :user]
end
diff --git a/app/views/computer_assets/_index.html.erb b/app/views/computer_assets/_index.html.erb
index b95836b..bd80def 100644
--- a/app/views/computer_assets/_index.html.erb
+++ b/app/views/computer_assets/_index.html.erb
@@ -1,18 +1,18 @@
<table>
<tr>
<th> </th>
<th><%= h t("activerecord.attributes.computer_asset.product_name") %></th>
<th><%= h t("activerecord.attributes.computer_asset.developer_name") %></th>
<th><%= h t("activerecord.attributes.computer_asset.model_number") %></th>
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
</tr>
<% computer_assets.each do |computer_asset| %>
<tr class='<%= cycle "", "even" %>'>
<td><%= link_to "##{computer_asset.id}", computer_asset_path(computer_asset) %></td>
<td><%= h(computer_asset.product_name) %></td>
<td><%= h computer_asset.developer_name %></td>
<td><%= h computer_asset.model_number %></td>
- <td><%= h computer_asset.utilization.user.try(:login) %></td>
+ <td><%= h computer_asset.try(:utilization, :user, :login) %></td>
</tr>
<% end %>
</table>
diff --git a/app/views/computer_assets/_menu.html.erb b/app/views/computer_assets/_menu.html.erb
new file mode 100644
index 0000000..7eba114
--- /dev/null
+++ b/app/views/computer_assets/_menu.html.erb
@@ -0,0 +1,3 @@
+<%= link_to t("computer_assets.index"), computer_assets_path %>
+|
+<%= link_to t("computer_assets.new"), new_computer_asset_path %>
diff --git a/app/views/computer_assets/index.html.erb b/app/views/computer_assets/index.html.erb
index 786609b..876469a 100644
--- a/app/views/computer_assets/index.html.erb
+++ b/app/views/computer_assets/index.html.erb
@@ -1,4 +1,3 @@
-
-<%= link_to t("computer_assets.new"), new_computer_asset_path %>
+<%= render :partial => "menu" %>
<%= render :partial => "index", :locals => {:computer_assets => @computer_assets} %>
diff --git a/app/views/computer_assets/show.html.erb b/app/views/computer_assets/show.html.erb
index 16f40f5..8919346 100644
--- a/app/views/computer_assets/show.html.erb
+++ b/app/views/computer_assets/show.html.erb
@@ -1,69 +1,76 @@
-<%= link_to t("computer_assets.index"), computer_assets_path %>
+<%= render :partial => "menu" %>
<% form_for @computer_asset, :builder => TableFormBuilder do |form| %>
<div class="span-12">
<fieldset>
<legend><%= t("activerecord.models.computer_asset") %></legend>
+ <%= error_messages_for :computer_asset %>
<table>
<% form.tr :developer_name do |method| %>
<%= text_field_with_auto_complete form.object_name, method %>
<% end %>
<% form.tr :product_name do |method| %>
<%= form.text_field method %>
<% end %>
<% form.tr :model_number do |method| %>
<%= form.text_field method %>
<% end %>
</table>
</fieldset>
</div>
<div class="span-12 last">
<fieldset>
<legend><%= t("activerecord.models.utilization") %></legend>
+ <%= error_messages_for :utilization %>
<table>
- <% fields_for @computer_asset.utilization, :builder => TableFormBuilder do |utilization_fields| %>
+ <% fields_for @utilization, :builder => TableFormBuilder do |utilization_fields| %>
<% utilization_fields.tr :user_id do |method| %>
- <%= utilization_fields.collection_select method, current_user.group.users, :id, :login, :include_blank => true %>
+ <%= utilization_fields.collection_select method, current_user.group.users, :id, :login, :include_blank => t("no_user") %>
<% end %>
<% utilization_fields.tr :started_on do |method| %>
<%= utilization_fields.text_field method %>
<%= link_to_function t("today"), "$('utilization_started_on').value = '#{Date.today}'" %>
<% end %>
<% utilization_fields.tr :parent_id do |method| %>
<%= utilization_fields.collection_select method, current_group.utilizations.include_asset.map{|u| [u.id, u.computer_asset.product_name]}, :first, :last, :include_blank => true %>
<% end %>
<% utilization_fields.tr :description do |method| %>
<%= utilization_fields.text_field method %>
<% end %>
<% end %>
</table>
</fieldset>
</div>
<div class="clear" />
- <%= submit_tag t(@computer_asset.new_record? ? "create" : "update") %>
+<div>
+<% unless @computer_asset.new_record? %>
+ <span style="float:right"><%= link_to t("delete"), computer_asset_path(@computer_asset), :method => "delete" %></span>
+<% end %>
+ <div style="text-align:center"><%= submit_tag t(@computer_asset.new_record? ? "create" : "update") %></div>
+</div>
<% end %>
+<% unless @computer_asset.new_record? %>
<hr/>
<h3><%= t("utilizations.children") %></h3>
-<%= render :partial => "index", :locals => {:computer_assets => @computer_asset.utilization.children.map(&:computer_asset)} %>
+<%= render :partial => "index", :locals => {:computer_assets => @utilization.children.map(&:computer_asset)} %>
<h3><%= t("utilizations.revisions") %></h3>
-<% if @utilizations %>
<table>
<tr>
<th>revision</th>
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
<th><%= h t("activerecord.attributes.utilization.started_on") %></th>
<th><%= h t("activerecord.attributes.utilization.description") %></th>
</tr>
<% @utilizations.each do |utilization| %>
<tr class='<%= cycle "", "even" %>'>
<td><%= utilization.revision %></td>
<td><%= h utilization.user.try(:login) %></td>
<td><%= h utilization.started_on %></td>
<td><%= h utilization.description %></td>
</tr>
<% end %>
</table>
<% end %>
diff --git a/config/initializers/modules/http_error.rb b/config/initializers/modules/http_error.rb
new file mode 100644
index 0000000..2055482
--- /dev/null
+++ b/config/initializers/modules/http_error.rb
@@ -0,0 +1,5 @@
+module HttpError
+ class BadRequestError < Exception; end
+ class ForbiddenError < Exception; end
+ class NotFoundError < Exception; end
+end
diff --git a/config/initializers/modules/try.rb b/config/initializers/modules/try.rb
index 557b31a..0b8b1b2 100644
--- a/config/initializers/modules/try.rb
+++ b/config/initializers/modules/try.rb
@@ -1,5 +1,8 @@
class Object
- def try(method)
- self.nil? ? nil : self.send(method)
+ def try(*methods)
+ #self.nil? ? nil : self.send(method)
+ methods.inject(self) do |obj, method|
+ obj.nil? ? nil : obj.send(method)
+ end
end
end
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index c23253b..f1d35a0 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1,56 +1,64 @@
ja:
create: ç»é²
update: æ´æ°
+ delete: åé¤
+
today: 仿¥
+ no_user: å©ç¨è
ãªã
sessions:
new: ãã°ã¤ã³
users:
new: ã¦ã¼ã¶ã¼ç»é²
computer_assets:
index: æ©æä¸è¦§
new: æ©æç»é²
+ create: æ©æç»é²
show: æ©æ
members:
index: å©ç¨è
new: å©ç¨è
ç»é²
utilizations:
children: ä»å±æ©æ
revisions: å©ç¨å±¥æ´
activerecord:
models:
user: "å©ç¨è
"
member: "å©ç¨è
"
computer_asset: "æ©æ"
- utilization: "å©ç¨"
+ utilization: "å©ç¨æ
å ±"
attributes:
user:
login: "ãã°ã¤ã³å"
email: "ã¡ã¼ã«ã¢ãã¬ã¹"
name: "åå"
password: "ãã¹ã¯ã¼ã"
password_confirmation: "ãã¹ã¯ã¼ã確èª"
computer_asset:
developer_name: "ã¡ã¼ã«ã¼"
product_name: "製åå"
model_number: "åçª"
+ utilization: "å©ç¨æ
å ±"
utilization:
user_id: "å©ç¨è
"
description: "åè"
- started_on: "å©ç¨éå§æ¥"
+ started_on: "éå§æ¥"
parent_id: "æ¥ç¶å
"
-
errors:
template:
header: "" # {{count}} errors prohibited this user from being saved
body: "" # There were problems with the following fields
messages:
blank: "ãæå®ãã¦ãã ãã"
too_short: "ã®é·ããè¶³ãã¾ãã"
models:
user:
attributes:
group_id:
blank: "ãæå®ãã¦ãã ãã"
+ computer_asset:
+ attributes:
+ utilization:
+ invalid: "ãæ£ããããã¾ãã"
diff --git a/db/migrate/20090115081929_create_initial_schema.rb b/db/migrate/20090115081929_create_initial_schema.rb
index febe12f..f398ef0 100644
--- a/db/migrate/20090115081929_create_initial_schema.rb
+++ b/db/migrate/20090115081929_create_initial_schema.rb
@@ -1,70 +1,70 @@
class CreateInitialSchema < ActiveRecord::Migration
def self.up
create_table "groups", :force => true do |t|
t.string :name
t.timestamps
end
create_table "users", :force => true do |t|
t.column :login, :string, :limit => 40
t.column :name, :string, :limit => 100, :default => '', :null => true
t.column :email, :string, :limit => 100
t.column :crypted_password, :string, :limit => 40
t.column :salt, :string, :limit => 40
t.column :created_at, :datetime
t.column :updated_at, :datetime
t.column :remember_token, :string, :limit => 40
t.column :remember_token_expires_at, :datetime
t.references :group, :null => false
end
add_index :users, :login, :unique => true
add_index :users, :group_id
create_table :developers do |t|
t.string :name, :null => false
t.timestamps
end
add_index :developers, :name, :unique => true
create_table :computer_models do |t|
t.timestamps
end
create_table :computer_assets do |t|
t.references :developer
- t.string :model_number, :null => false
+ t.string :model_number
t.string :product_name, :null => false
t.references :group, :null => false
t.string :asset_number
t.timestamps
end
create_table :utilizations, :revision => true do |t|
t.references :computer_asset, :null => false
t.references :user
t.references :group, :null => false
t.text :description
t.date :started_on
t.integer :parent_id, :references => :utilizations
t.timestamps
end
# TODO: extend create_table so that reviisons table is automaticaly created
# create_table :utilization_revisions, :primary_key => false do |t|
# t.integer :id, :null => false
# t.integer :revision, :null => false
# t.references :computer_asset, :user, :null => false
# t.string :host_name
# t.timestamps
# end
# add_index :utilization_revisions, [:id, :revision], :unique => true
end
def self.down
drop_table :utilizations
drop_table :computer_assets
drop_table :computer_models
drop_table :developers
drop_table :users
drop_table :groups
end
end
|
hiroshi/inventory
|
de3de476cb84f463da93bb0e498194c14b25f90c
|
implement utilization.children using acts_as_tree
|
diff --git a/app/models/group.rb b/app/models/group.rb
index 9427085..f2aa75a 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1,4 +1,5 @@
class Group < ActiveRecord::Base
has_many :users
has_many :computer_assets
+ has_many :utilizations
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 605599a..49b1fef 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,56 +1,59 @@
require 'digest/sha1'
class User < ActiveRecord::Base
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken
validates_presence_of :login
validates_length_of :login, :within => 3..40
validates_uniqueness_of :login
validates_format_of :login, :with => Authentication.login_regex, :message => Authentication.bad_login_message
# validates_format_of :name, :with => Authentication.name_regex, :message => Authentication.bad_name_message, :allow_nil => true
# validates_length_of :name, :maximum => 100
validates_presence_of :email
validates_length_of :email, :within => 6..100 #[email protected]
validates_uniqueness_of :email
validates_format_of :email, :with => Authentication.email_regex, :message => Authentication.bad_email_message
# HACK HACK HACK -- how to do attr_accessible from here?
# prevents a user from submitting a crafted form that bypasses activation
# anything else you want your user to change should be added here.
attr_accessible :login, :email, :name, :password, :password_confirmation
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
#
# uff. this is really an authorization, not authentication routine.
# We really need a Dispatch Chain here or something.
# This will also let us return a human error message.
#
def self.authenticate(login, password)
return nil if login.blank? || password.blank?
u = find_by_login(login) # need to get the salt
u && u.authenticated?(password) ? u : nil
end
def login=(value)
write_attribute :login, (value ? value.downcase : nil)
end
def email=(value)
write_attribute :email, (value ? value.downcase : nil)
end
# group
belongs_to :group
before_validation :set_group
def set_group
self.create_group if self.group_id.nil?
end
+
+ # :utilizations
+ has_many :utilizations
end
diff --git a/app/models/utilization.rb b/app/models/utilization.rb
index 600accf..8c61aa2 100644
--- a/app/models/utilization.rb
+++ b/app/models/utilization.rb
@@ -1,6 +1,10 @@
class Utilization < ActiveRecord::Base
+ acts_as_tree
belongs_to :computer_asset
belongs_to :user
include Revision::Model
+
+ named_scope :include_asset, :include => :computer_asset
+# named_scope :include_asset_and_user, :include => [:computer_asset, :user]
end
diff --git a/app/views/computer_assets/_index.html.erb b/app/views/computer_assets/_index.html.erb
new file mode 100644
index 0000000..b95836b
--- /dev/null
+++ b/app/views/computer_assets/_index.html.erb
@@ -0,0 +1,18 @@
+<table>
+ <tr>
+ <th> </th>
+ <th><%= h t("activerecord.attributes.computer_asset.product_name") %></th>
+ <th><%= h t("activerecord.attributes.computer_asset.developer_name") %></th>
+ <th><%= h t("activerecord.attributes.computer_asset.model_number") %></th>
+ <th><%= h t("activerecord.attributes.utilization.user_id") %></th>
+ </tr>
+ <% computer_assets.each do |computer_asset| %>
+ <tr class='<%= cycle "", "even" %>'>
+ <td><%= link_to "##{computer_asset.id}", computer_asset_path(computer_asset) %></td>
+ <td><%= h(computer_asset.product_name) %></td>
+ <td><%= h computer_asset.developer_name %></td>
+ <td><%= h computer_asset.model_number %></td>
+ <td><%= h computer_asset.utilization.user.try(:login) %></td>
+ </tr>
+ <% end %>
+</table>
diff --git a/app/views/computer_assets/index.html.erb b/app/views/computer_assets/index.html.erb
index 4c8c1d2..786609b 100644
--- a/app/views/computer_assets/index.html.erb
+++ b/app/views/computer_assets/index.html.erb
@@ -1,21 +1,4 @@
<%= link_to t("computer_assets.new"), new_computer_asset_path %>
-<table>
- <tr>
- <th> </th>
- <th><%= h t("activerecord.attributes.computer_asset.product_name") %></th>
- <th><%= h t("activerecord.attributes.computer_asset.developer_name") %></th>
- <th><%= h t("activerecord.attributes.computer_asset.model_number") %></th>
- <th><%= h t("activerecord.attributes.utilization.user_id") %></th>
- </tr>
- <% @computer_assets.each do |computer_asset| %>
- <tr class='<%= cycle "", "even" %>'>
- <td><%= link_to "##{computer_asset.id}", computer_asset_path(computer_asset) %></td>
- <td><%= h(computer_asset.product_name) %></td>
- <td><%= h computer_asset.developer_name %></td>
- <td><%= h computer_asset.model_number %></td>
- <td><%= h computer_asset.utilization.user.try(:login) %></td>
- </tr>
- <% end %>
-</table>
+<%= render :partial => "index", :locals => {:computer_assets => @computer_assets} %>
diff --git a/app/views/computer_assets/show.html.erb b/app/views/computer_assets/show.html.erb
index 657b8b5..16f40f5 100644
--- a/app/views/computer_assets/show.html.erb
+++ b/app/views/computer_assets/show.html.erb
@@ -1,63 +1,69 @@
<%= link_to t("computer_assets.index"), computer_assets_path %>
<% form_for @computer_asset, :builder => TableFormBuilder do |form| %>
<div class="span-12">
<fieldset>
<legend><%= t("activerecord.models.computer_asset") %></legend>
<table>
<% form.tr :developer_name do |method| %>
<%= text_field_with_auto_complete form.object_name, method %>
<% end %>
<% form.tr :product_name do |method| %>
<%= form.text_field method %>
<% end %>
<% form.tr :model_number do |method| %>
<%= form.text_field method %>
<% end %>
</table>
</fieldset>
</div>
<div class="span-12 last">
<fieldset>
<legend><%= t("activerecord.models.utilization") %></legend>
<table>
<% fields_for @computer_asset.utilization, :builder => TableFormBuilder do |utilization_fields| %>
<% utilization_fields.tr :user_id do |method| %>
<%= utilization_fields.collection_select method, current_user.group.users, :id, :login, :include_blank => true %>
<% end %>
- <% utilization_fields.tr :host_name do |method| %>
- <%= utilization_fields.text_field method %>
- <% end %>
<% utilization_fields.tr :started_on do |method| %>
<%= utilization_fields.text_field method %>
<%= link_to_function t("today"), "$('utilization_started_on').value = '#{Date.today}'" %>
<% end %>
+ <% utilization_fields.tr :parent_id do |method| %>
+ <%= utilization_fields.collection_select method, current_group.utilizations.include_asset.map{|u| [u.id, u.computer_asset.product_name]}, :first, :last, :include_blank => true %>
+ <% end %>
+ <% utilization_fields.tr :description do |method| %>
+ <%= utilization_fields.text_field method %>
+ <% end %>
<% end %>
</table>
</fieldset>
</div>
<div class="clear" />
<%= submit_tag t(@computer_asset.new_record? ? "create" : "update") %>
<% end %>
<hr/>
-<h3>å©ç¨å±¥æ´</h3>
+<h3><%= t("utilizations.children") %></h3>
+<%= render :partial => "index", :locals => {:computer_assets => @computer_asset.utilization.children.map(&:computer_asset)} %>
+
+<h3><%= t("utilizations.revisions") %></h3>
<% if @utilizations %>
<table>
<tr>
<th>revision</th>
<th><%= h t("activerecord.attributes.utilization.user_id") %></th>
- <th><%= h t("activerecord.attributes.utilization.host_name") %></th>
<th><%= h t("activerecord.attributes.utilization.started_on") %></th>
+ <th><%= h t("activerecord.attributes.utilization.description") %></th>
</tr>
<% @utilizations.each do |utilization| %>
<tr class='<%= cycle "", "even" %>'>
<td><%= utilization.revision %></td>
<td><%= h utilization.user.try(:login) %></td>
- <td><%= h utilization.host_name %></td>
<td><%= h utilization.started_on %></td>
+ <td><%= h utilization.description %></td>
</tr>
<% end %>
</table>
<% end %>
diff --git a/config/initializers/smart_delegate.rb b/config/initializers/modules/smart_delegate.rb
similarity index 100%
rename from config/initializers/smart_delegate.rb
rename to config/initializers/modules/smart_delegate.rb
diff --git a/config/initializers/try.rb b/config/initializers/modules/try.rb
similarity index 100%
rename from config/initializers/try.rb
rename to config/initializers/modules/try.rb
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index a0a175d..c23253b 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -1,52 +1,56 @@
ja:
create: ç»é²
update: æ´æ°
today: 仿¥
sessions:
new: ãã°ã¤ã³
users:
new: ã¦ã¼ã¶ã¼ç»é²
computer_assets:
index: æ©æä¸è¦§
new: æ©æç»é²
show: æ©æ
members:
index: å©ç¨è
new: å©ç¨è
ç»é²
+ utilizations:
+ children: ä»å±æ©æ
+ revisions: å©ç¨å±¥æ´
activerecord:
models:
user: "å©ç¨è
"
member: "å©ç¨è
"
computer_asset: "æ©æ"
utilization: "å©ç¨"
attributes:
user:
login: "ãã°ã¤ã³å"
email: "ã¡ã¼ã«ã¢ãã¬ã¹"
name: "åå"
password: "ãã¹ã¯ã¼ã"
password_confirmation: "ãã¹ã¯ã¼ã確èª"
computer_asset:
developer_name: "ã¡ã¼ã«ã¼"
product_name: "製åå"
model_number: "åçª"
utilization:
user_id: "å©ç¨è
"
- host_name: "ãã¹ãå"
+ description: "åè"
started_on: "å©ç¨éå§æ¥"
+ parent_id: "æ¥ç¶å
"
errors:
template:
header: "" # {{count}} errors prohibited this user from being saved
body: "" # There were problems with the following fields
messages:
blank: "ãæå®ãã¦ãã ãã"
too_short: "ã®é·ããè¶³ãã¾ãã"
models:
user:
attributes:
group_id:
blank: "ãæå®ãã¦ãã ãã"
diff --git a/db/migrate/20090115081929_create_initial_schema.rb b/db/migrate/20090115081929_create_initial_schema.rb
index ccf2c15..febe12f 100644
--- a/db/migrate/20090115081929_create_initial_schema.rb
+++ b/db/migrate/20090115081929_create_initial_schema.rb
@@ -1,70 +1,70 @@
class CreateInitialSchema < ActiveRecord::Migration
def self.up
create_table "groups", :force => true do |t|
t.string :name
t.timestamps
end
create_table "users", :force => true do |t|
t.column :login, :string, :limit => 40
t.column :name, :string, :limit => 100, :default => '', :null => true
t.column :email, :string, :limit => 100
t.column :crypted_password, :string, :limit => 40
t.column :salt, :string, :limit => 40
t.column :created_at, :datetime
t.column :updated_at, :datetime
t.column :remember_token, :string, :limit => 40
t.column :remember_token_expires_at, :datetime
t.references :group, :null => false
end
add_index :users, :login, :unique => true
add_index :users, :group_id
create_table :developers do |t|
t.string :name, :null => false
t.timestamps
end
add_index :developers, :name, :unique => true
create_table :computer_models do |t|
t.timestamps
end
create_table :computer_assets do |t|
t.references :developer
t.string :model_number, :null => false
t.string :product_name, :null => false
-
t.references :group, :null => false
t.string :asset_number
-
t.timestamps
end
create_table :utilizations, :revision => true do |t|
t.references :computer_asset, :null => false
t.references :user
- t.string :host_name
+ t.references :group, :null => false
+ t.text :description
t.date :started_on
+ t.integer :parent_id, :references => :utilizations
t.timestamps
end
# TODO: extend create_table so that reviisons table is automaticaly created
# create_table :utilization_revisions, :primary_key => false do |t|
# t.integer :id, :null => false
# t.integer :revision, :null => false
# t.references :computer_asset, :user, :null => false
# t.string :host_name
# t.timestamps
# end
# add_index :utilization_revisions, [:id, :revision], :unique => true
end
def self.down
drop_table :utilizations
drop_table :computer_assets
drop_table :computer_models
drop_table :developers
drop_table :users
drop_table :groups
end
end
diff --git a/vendor/plugins/acts_as_tree/README b/vendor/plugins/acts_as_tree/README
new file mode 100644
index 0000000..a6cc6a9
--- /dev/null
+++ b/vendor/plugins/acts_as_tree/README
@@ -0,0 +1,26 @@
+acts_as_tree
+============
+
+Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
+association. This requires that you have a foreign key column, which by default is called +parent_id+.
+
+ class Category < ActiveRecord::Base
+ acts_as_tree :order => "name"
+ end
+
+ Example:
+ root
+ \_ child1
+ \_ subchild1
+ \_ subchild2
+
+ root = Category.create("name" => "root")
+ child1 = root.children.create("name" => "child1")
+ subchild1 = child1.children.create("name" => "subchild1")
+
+ root.parent # => nil
+ child1.parent # => root
+ root.children # => [child1]
+ root.children.first.children.first # => subchild1
+
+Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_tree/Rakefile b/vendor/plugins/acts_as_tree/Rakefile
new file mode 100644
index 0000000..da091d9
--- /dev/null
+++ b/vendor/plugins/acts_as_tree/Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test acts_as_tree plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for acts_as_tree plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'acts_as_tree'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
diff --git a/vendor/plugins/acts_as_tree/init.rb b/vendor/plugins/acts_as_tree/init.rb
new file mode 100644
index 0000000..0901ddb
--- /dev/null
+++ b/vendor/plugins/acts_as_tree/init.rb
@@ -0,0 +1 @@
+ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree
diff --git a/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb b/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
new file mode 100644
index 0000000..1f00e90
--- /dev/null
+++ b/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
@@ -0,0 +1,96 @@
+module ActiveRecord
+ module Acts
+ module Tree
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ # Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
+ # association. This requires that you have a foreign key column, which by default is called +parent_id+.
+ #
+ # class Category < ActiveRecord::Base
+ # acts_as_tree :order => "name"
+ # end
+ #
+ # Example:
+ # root
+ # \_ child1
+ # \_ subchild1
+ # \_ subchild2
+ #
+ # root = Category.create("name" => "root")
+ # child1 = root.children.create("name" => "child1")
+ # subchild1 = child1.children.create("name" => "subchild1")
+ #
+ # root.parent # => nil
+ # child1.parent # => root
+ # root.children # => [child1]
+ # root.children.first.children.first # => subchild1
+ #
+ # In addition to the parent and children associations, the following instance methods are added to the class
+ # after calling <tt>acts_as_tree</tt>:
+ # * <tt>siblings</tt> - Returns all the children of the parent, excluding the current node (<tt>[subchild2]</tt> when called on <tt>subchild1</tt>)
+ # * <tt>self_and_siblings</tt> - Returns all the children of the parent, including the current node (<tt>[subchild1, subchild2]</tt> when called on <tt>subchild1</tt>)
+ # * <tt>ancestors</tt> - Returns all the ancestors of the current node (<tt>[child1, root]</tt> when called on <tt>subchild2</tt>)
+ # * <tt>root</tt> - Returns the root of the current node (<tt>root</tt> when called on <tt>subchild2</tt>)
+ module ClassMethods
+ # Configuration options are:
+ #
+ # * <tt>foreign_key</tt> - specifies the column name to use for tracking of the tree (default: +parent_id+)
+ # * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet.
+ # * <tt>counter_cache</tt> - keeps a count in a +children_count+ column if set to +true+ (default: +false+).
+ def acts_as_tree(options = {})
+ configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil }
+ configuration.update(options) if options.is_a?(Hash)
+
+ belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache]
+ has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => :destroy
+
+ class_eval <<-EOV
+ include ActiveRecord::Acts::Tree::InstanceMethods
+
+ def self.roots
+ find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
+ end
+
+ def self.root
+ find(:first, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
+ end
+ EOV
+ end
+ end
+
+ module InstanceMethods
+ # Returns list of ancestors, starting from parent until root.
+ #
+ # subchild1.ancestors # => [child1, root]
+ def ancestors
+ node, nodes = self, []
+ nodes << node = node.parent while node.parent
+ nodes
+ end
+
+ # Returns the root node of the tree.
+ def root
+ node = self
+ node = node.parent while node.parent
+ node
+ end
+
+ # Returns all siblings of the current node.
+ #
+ # subchild1.siblings # => [subchild2]
+ def siblings
+ self_and_siblings - [self]
+ end
+
+ # Returns all siblings and a reference to the current node.
+ #
+ # subchild1.self_and_siblings # => [subchild1, subchild2]
+ def self_and_siblings
+ parent ? parent.children : self.class.roots
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/acts_as_tree/test/abstract_unit.rb b/vendor/plugins/acts_as_tree/test/abstract_unit.rb
new file mode 100644
index 0000000..e69de29
diff --git a/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb b/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb
new file mode 100644
index 0000000..018c58e
--- /dev/null
+++ b/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb
@@ -0,0 +1,219 @@
+require 'test/unit'
+
+require 'rubygems'
+require 'active_record'
+
+$:.unshift File.dirname(__FILE__) + '/../lib'
+require File.dirname(__FILE__) + '/../init'
+
+class Test::Unit::TestCase
+ def assert_queries(num = 1)
+ $query_count = 0
+ yield
+ ensure
+ assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed."
+ end
+
+ def assert_no_queries(&block)
+ assert_queries(0, &block)
+ end
+end
+
+ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
+
+# AR keeps printing annoying schema statements
+$stdout = StringIO.new
+
+def setup_db
+ ActiveRecord::Base.logger
+ ActiveRecord::Schema.define(:version => 1) do
+ create_table :mixins do |t|
+ t.column :type, :string
+ t.column :parent_id, :integer
+ end
+ end
+end
+
+def teardown_db
+ ActiveRecord::Base.connection.tables.each do |table|
+ ActiveRecord::Base.connection.drop_table(table)
+ end
+end
+
+class Mixin < ActiveRecord::Base
+end
+
+class TreeMixin < Mixin
+ acts_as_tree :foreign_key => "parent_id", :order => "id"
+end
+
+class TreeMixinWithoutOrder < Mixin
+ acts_as_tree :foreign_key => "parent_id"
+end
+
+class RecursivelyCascadedTreeMixin < Mixin
+ acts_as_tree :foreign_key => "parent_id"
+ has_one :first_child, :class_name => 'RecursivelyCascadedTreeMixin', :foreign_key => :parent_id
+end
+
+class TreeTest < Test::Unit::TestCase
+
+ def setup
+ setup_db
+ @root1 = TreeMixin.create!
+ @root_child1 = TreeMixin.create! :parent_id => @root1.id
+ @child1_child = TreeMixin.create! :parent_id => @root_child1.id
+ @root_child2 = TreeMixin.create! :parent_id => @root1.id
+ @root2 = TreeMixin.create!
+ @root3 = TreeMixin.create!
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_children
+ assert_equal @root1.children, [@root_child1, @root_child2]
+ assert_equal @root_child1.children, [@child1_child]
+ assert_equal @child1_child.children, []
+ assert_equal @root_child2.children, []
+ end
+
+ def test_parent
+ assert_equal @root_child1.parent, @root1
+ assert_equal @root_child1.parent, @root_child2.parent
+ assert_nil @root1.parent
+ end
+
+ def test_delete
+ assert_equal 6, TreeMixin.count
+ @root1.destroy
+ assert_equal 2, TreeMixin.count
+ @root2.destroy
+ @root3.destroy
+ assert_equal 0, TreeMixin.count
+ end
+
+ def test_insert
+ @extra = @root1.children.create
+
+ assert @extra
+
+ assert_equal @extra.parent, @root1
+
+ assert_equal 3, @root1.children.size
+ assert @root1.children.include?(@extra)
+ assert @root1.children.include?(@root_child1)
+ assert @root1.children.include?(@root_child2)
+ end
+
+ def test_ancestors
+ assert_equal [], @root1.ancestors
+ assert_equal [@root1], @root_child1.ancestors
+ assert_equal [@root_child1, @root1], @child1_child.ancestors
+ assert_equal [@root1], @root_child2.ancestors
+ assert_equal [], @root2.ancestors
+ assert_equal [], @root3.ancestors
+ end
+
+ def test_root
+ assert_equal @root1, TreeMixin.root
+ assert_equal @root1, @root1.root
+ assert_equal @root1, @root_child1.root
+ assert_equal @root1, @child1_child.root
+ assert_equal @root1, @root_child2.root
+ assert_equal @root2, @root2.root
+ assert_equal @root3, @root3.root
+ end
+
+ def test_roots
+ assert_equal [@root1, @root2, @root3], TreeMixin.roots
+ end
+
+ def test_siblings
+ assert_equal [@root2, @root3], @root1.siblings
+ assert_equal [@root_child2], @root_child1.siblings
+ assert_equal [], @child1_child.siblings
+ assert_equal [@root_child1], @root_child2.siblings
+ assert_equal [@root1, @root3], @root2.siblings
+ assert_equal [@root1, @root2], @root3.siblings
+ end
+
+ def test_self_and_siblings
+ assert_equal [@root1, @root2, @root3], @root1.self_and_siblings
+ assert_equal [@root_child1, @root_child2], @root_child1.self_and_siblings
+ assert_equal [@child1_child], @child1_child.self_and_siblings
+ assert_equal [@root_child1, @root_child2], @root_child2.self_and_siblings
+ assert_equal [@root1, @root2, @root3], @root2.self_and_siblings
+ assert_equal [@root1, @root2, @root3], @root3.self_and_siblings
+ end
+end
+
+class TreeTestWithEagerLoading < Test::Unit::TestCase
+
+ def setup
+ teardown_db
+ setup_db
+ @root1 = TreeMixin.create!
+ @root_child1 = TreeMixin.create! :parent_id => @root1.id
+ @child1_child = TreeMixin.create! :parent_id => @root_child1.id
+ @root_child2 = TreeMixin.create! :parent_id => @root1.id
+ @root2 = TreeMixin.create!
+ @root3 = TreeMixin.create!
+
+ @rc1 = RecursivelyCascadedTreeMixin.create!
+ @rc2 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc1.id
+ @rc3 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc2.id
+ @rc4 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc3.id
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_eager_association_loading
+ roots = TreeMixin.find(:all, :include => :children, :conditions => "mixins.parent_id IS NULL", :order => "mixins.id")
+ assert_equal [@root1, @root2, @root3], roots
+ assert_no_queries do
+ assert_equal 2, roots[0].children.size
+ assert_equal 0, roots[1].children.size
+ assert_equal 0, roots[2].children.size
+ end
+ end
+
+ def test_eager_association_loading_with_recursive_cascading_three_levels_has_many
+ root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :children => { :children => :children } }, :order => 'mixins.id')
+ assert_equal @rc4, assert_no_queries { root_node.children.first.children.first.children.first }
+ end
+
+ def test_eager_association_loading_with_recursive_cascading_three_levels_has_one
+ root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :first_child => { :first_child => :first_child } }, :order => 'mixins.id')
+ assert_equal @rc4, assert_no_queries { root_node.first_child.first_child.first_child }
+ end
+
+ def test_eager_association_loading_with_recursive_cascading_three_levels_belongs_to
+ leaf_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :parent => { :parent => :parent } }, :order => 'mixins.id DESC')
+ assert_equal @rc1, assert_no_queries { leaf_node.parent.parent.parent }
+ end
+end
+
+class TreeTestWithoutOrder < Test::Unit::TestCase
+
+ def setup
+ setup_db
+ @root1 = TreeMixinWithoutOrder.create!
+ @root2 = TreeMixinWithoutOrder.create!
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_root
+ assert [@root1, @root2].include?(TreeMixinWithoutOrder.root)
+ end
+
+ def test_roots
+ assert_equal [], [@root1, @root2] - TreeMixinWithoutOrder.roots
+ end
+end
diff --git a/vendor/plugins/acts_as_tree/test/database.yml b/vendor/plugins/acts_as_tree/test/database.yml
new file mode 100644
index 0000000..e69de29
diff --git a/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb b/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb
new file mode 100644
index 0000000..e69de29
diff --git a/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml b/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml
new file mode 100644
index 0000000..e69de29
diff --git a/vendor/plugins/acts_as_tree/test/schema.rb b/vendor/plugins/acts_as_tree/test/schema.rb
new file mode 100644
index 0000000..e69de29
|
hiroshi/inventory
|
6eac546b5fb8f6ca2b0efd64234469532186aeda
|
implement user filter on computer_assets#index
|
diff --git a/app/controllers/computer_assets_controller.rb b/app/controllers/computer_assets_controller.rb
index 1bd8fa4..1f2cb92 100644
--- a/app/controllers/computer_assets_controller.rb
+++ b/app/controllers/computer_assets_controller.rb
@@ -1,59 +1,65 @@
class ComputerAssetsController < ApplicationController
before_filter :login_required
before_filter :new_computer_asset, :only => [:new, :create]
before_filter :set_computer_asset, :only => [:show, :update]
# FIXME
skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_computer_asset_developer_name]
def index
- @computer_assets = current_group.computer_assets.find(:all, :include => :developer, :order => "id ASC")
+ # TODO: refactor and generalize as find
+ options = {:include => :developer, :order => "computer_assets.id ASC"}
+ if user_id = params[:user_id]
+ options[:joins] = "LEFT JOIN utilizations u ON u.computer_asset_id = computer_assets.id"
+ options[:conditions] = ["u.user_id = ?", user_id]
+ end
+ @computer_assets = current_group.computer_assets.find(:all, options)
end
def new
render :action => "show"
end
def create
@computer_asset.save!
redirect_to computer_assets_path
end
def show
# @utilizations = Utilization.find(:all, :from => "utilization_revisions", :conditions => ["id = ?", @computer_asset.utilization], :order => "revision DESC")
@utilizations = @computer_asset.utilization.revisions
end
def update
ActiveRecord::Base.transaction do
@computer_asset.update_attributes!(params[:computer_asset])
@computer_asset.utilization.update_attributes!(params[:utilization])
end
redirect_to computer_assets_path
end
# TODO: to be a REST action
def auto_complete_for_computer_asset_developer_name
name = params[:computer_asset]["developer_name"]
# OPTIMIZE: regexp or like can be expensive (cause full table search), instead use fulltext search if possible
# @developers = Developer.find(:all, :conditions => ["name LIKE ?", "%#{name}%"])
@developers = Developer.find(:all, :conditions => ["name ~* ?", name])
if @developers.blank?
render :nothing => true
else
render :inline => "<%= content_tag :ul, @developers.map {|d| content_tag(:li, h(d.name))} %>"
end
end
private
def new_computer_asset
@computer_asset = current_group.computer_assets.build(params[:computer_asset])
# @computer_asset.group_id = current_user.group_id
@computer_asset.build_utilization(params[:utilization])
end
def set_computer_asset
@computer_asset = current_user.group.computer_assets.find_by_id(params[:id]) or raise NotFoundError
end
end
diff --git a/app/views/members/index.html.erb b/app/views/members/index.html.erb
index e983a92..8d2354c 100644
--- a/app/views/members/index.html.erb
+++ b/app/views/members/index.html.erb
@@ -1,8 +1,8 @@
<%= link_to t("members.new"), new_member_path %>
<h2><%= t("members.index") %></h2>
<ul>
<% @users.each do |user| %>
- <li><%= h user.login %></li>
+ <li><%= h user.login %> <%= link_to t("computer_assets.index"), computer_assets_path(:user_id => user) %></li>
<% end %>
</ul>
|
arunthampi/epl.github.com
|
9d34589d431eba8fe69f998e490de0890c394202
|
CDATA Fix
|
diff --git a/.gitignore b/.gitignore
index 8b13789..e43b0f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-
+.DS_Store
diff --git a/iphone/index.html b/iphone/index.html
index dd9165a..094a54b 100644
--- a/iphone/index.html
+++ b/iphone/index.html
@@ -1,37 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>English Premier League</title>
<link rel="stylesheet" href="/iphone/stylesheets/iphone.css" />
<link rel="stylesheet" href="/iphone/stylesheets/table.css" />
<link rel="apple-touch-icon" href="/iphone/images/apple-touch-icon.png" />
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<div id="header">
<h1>EPL Table</h1>
<a href="/iphone" id="backButton">Back</a>
</div>
<ul id="epl_iphone_table">
</ul>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table(true);
TABLE.initialize_teams();
});
+ //]]>
</script>
</body>
</html>
\ No newline at end of file
|
arunthampi/epl.github.com
|
b7d262d0e821591ad891a18809e1db20c0b7d694
|
Do not cache AJAX requests
|
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index 8e0cca6..0194cff 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,114 +1,114 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
EPL.Table = function(is_iphone) {
this.table = [];
this.is_iphone = is_iphone;
if(this.is_iphone) {
$('a#backButton').hide();
}
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
$.ajax({
url: '/js/epl/all_teams.js',
dataType: 'json',
- type: 'GET',
+ type: 'GET', cache: false,
success: function(data) {
for(var i = 0; i < data.length; i++) {
self.table.push(data[i]);
if(self.is_iphone) {
self.write_team_standings_to_iphone_view(data[i], i + 1);
} else {
self.write_team_standings_to_normal_view(data[i], i + 1);
}
}
self.initialize_fixtures_bindings();
}
});
};
EPL.Table.prototype.initialize_fixtures_bindings = function() {
var self = this;
$("a.fixtures").bind("click", function(e) {
var id = e.currentTarget.id;
if(self.is_iphone) {
self.show_fixtures_iphone_view(id);
} else {
self.show_fixtures_normal_view(id);
}
return false;
});
};
EPL.Table.prototype.show_fixtures_normal_view = function(id) {
var self = this;
var html = "<p id=\"fixtures_" + id + "\">";
$.ajax({
url: "/js/epl/teams/fixtures/" + id + ".js",
dataType: 'json',
- type: 'GET',
+ type: 'GET', cache: false,
success: function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<p id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<p><b>" + fixtures[i].competition + "</b></p>";
html += "<p><i>" + fixtures[i].details + "</i></p>";
html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
html += "</p><hr />";
}
html += "</p>";
$('div#long_form_div').replaceWith(html);
}
});
};
EPL.Table.prototype.show_fixtures_iphone_view = function(id) {
var self = this;
// var html = "<li id=\"fixtures_" + id + "\">";
var html = "<ul id=\"epl_iphone_table\">";
$.ajax({
url: "/js/epl/teams/fixtures/" + id + ".js",
dataType: 'json',
- type: 'GET',
+ type: 'GET', cache: false,
success: function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<li id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<p><b>" + fixtures[i].competition + "</b></p>";
html += "<p><i>" + fixtures[i].details + "</i></p>";
html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
html += "</li>";
}
html += "</ul>";
$('ul#epl_iphone_table').replaceWith(html);
$('a#backButton').show();
}
});
};
EPL.Table.prototype.write_team_standings_to_iphone_view = function(team, rank) {
$('#epl_iphone_table').append(
"<a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" +
"<li class=\"arrow\"><p class=\"standing\"><span class=\"rank\">" + rank + "</span><span class=\"name\">" +
team.name + "</span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></a></li>"
);
};
EPL.Table.prototype.write_team_standings_to_normal_view = function(team, rank) {
$('#epl_long_form_table').append(
"<tr>" +
"<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
"<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
"<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
"<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
"<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
"<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
"<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
"<td>" + team.points + "</td>" +
"</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
72c9a99949a9b123ead52ee635619f98d6a80207
|
Use $.ajax instead of $.getJSON
|
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index 0ff4a31..8e0cca6 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,102 +1,114 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
EPL.Table = function(is_iphone) {
this.table = [];
this.is_iphone = is_iphone;
if(this.is_iphone) {
$('a#backButton').hide();
}
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
- $.getJSON("/js/epl/all_teams.js",
- function(data) {
+ $.ajax({
+ url: '/js/epl/all_teams.js',
+ dataType: 'json',
+ type: 'GET',
+ success: function(data) {
for(var i = 0; i < data.length; i++) {
self.table.push(data[i]);
if(self.is_iphone) {
self.write_team_standings_to_iphone_view(data[i], i + 1);
} else {
self.write_team_standings_to_normal_view(data[i], i + 1);
}
}
self.initialize_fixtures_bindings();
- });
+ }
+ });
};
EPL.Table.prototype.initialize_fixtures_bindings = function() {
var self = this;
$("a.fixtures").bind("click", function(e) {
var id = e.currentTarget.id;
if(self.is_iphone) {
self.show_fixtures_iphone_view(id);
} else {
self.show_fixtures_normal_view(id);
}
return false;
});
};
EPL.Table.prototype.show_fixtures_normal_view = function(id) {
var self = this;
var html = "<p id=\"fixtures_" + id + "\">";
- $.getJSON("/js/epl/teams/fixtures/" + id + ".js",
- function(fixtures) {
+ $.ajax({
+ url: "/js/epl/teams/fixtures/" + id + ".js",
+ dataType: 'json',
+ type: 'GET',
+ success: function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<p id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<p><b>" + fixtures[i].competition + "</b></p>";
html += "<p><i>" + fixtures[i].details + "</i></p>";
html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
html += "</p><hr />";
}
html += "</p>";
$('div#long_form_div').replaceWith(html);
- });
+ }
+ });
};
EPL.Table.prototype.show_fixtures_iphone_view = function(id) {
var self = this;
// var html = "<li id=\"fixtures_" + id + "\">";
var html = "<ul id=\"epl_iphone_table\">";
- $.getJSON("/js/epl/teams/fixtures/" + id + ".js",
- function(fixtures) {
+ $.ajax({
+ url: "/js/epl/teams/fixtures/" + id + ".js",
+ dataType: 'json',
+ type: 'GET',
+ success: function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<li id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<p><b>" + fixtures[i].competition + "</b></p>";
html += "<p><i>" + fixtures[i].details + "</i></p>";
html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
html += "</li>";
}
html += "</ul>";
$('ul#epl_iphone_table').replaceWith(html);
$('a#backButton').show();
- });
+ }
+ });
};
EPL.Table.prototype.write_team_standings_to_iphone_view = function(team, rank) {
$('#epl_iphone_table').append(
"<a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" +
"<li class=\"arrow\"><p class=\"standing\"><span class=\"rank\">" + rank + "</span><span class=\"name\">" +
team.name + "</span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></a></li>"
);
};
EPL.Table.prototype.write_team_standings_to_normal_view = function(team, rank) {
$('#epl_long_form_table').append(
"<tr>" +
"<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
"<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
"<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
"<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
"<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
"<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
"<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
"<td>" + team.points + "</td>" +
"</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
69e15b627a451a1b473ae692fc3cfe62f061808a
|
Fixtures details for 29-Jan-2009 1038
|
diff --git a/js/epl/all_teams.js b/js/epl/all_teams.js
index d498b5b..bf05e4d 100644
--- a/js/epl/all_teams.js
+++ b/js/epl/all_teams.js
@@ -1 +1 @@
-[{"name":"Man Utd","away_lost":2,"home_against":4,"goal_difference":29,"home_for":24,"away_drawn":4,"away_for":15,"home_won":9,"points":50,"total_played":22,"id":"man_utd","home_lost":0,"away_against":6,"away_won":6,"home_drawn":1},{"name":"Liverpool","away_lost":1,"home_against":7,"goal_difference":22,"home_for":17,"away_drawn":3,"away_for":19,"home_won":6,"points":47,"total_played":22,"id":"liverpool","home_lost":0,"away_against":7,"away_won":7,"home_drawn":5},{"name":"Aston Villa","away_lost":3,"home_against":12,"goal_difference":14,"home_for":18,"away_drawn":0,"away_for":20,"home_won":5,"points":47,"total_played":23,"id":"aston_villa","home_lost":1,"away_against":12,"away_won":9,"home_drawn":5},{"name":"Chelsea","away_lost":1,"home_against":7,"goal_difference":29,"home_for":19,"away_drawn":2,"away_for":23,"home_won":5,"points":45,"total_played":22,"id":"chelsea","home_lost":2,"away_against":6,"away_won":8,"home_drawn":4},{"name":"Arsenal","away_lost":3,"home_against":11,"goal_difference":13,"home_for":18,"away_drawn":3,"away_for":19,"home_won":7,"points":41,"total_played":22,"id":"arsenal","home_lost":2,"away_against":13,"away_won":5,"home_drawn":2},{"name":"Everton","away_lost":2,"home_against":15,"goal_difference":4,"home_for":14,"away_drawn":2,"away_for":16,"home_won":3,"points":36,"total_played":22,"id":"everton","home_lost":4,"away_against":11,"away_won":7,"home_drawn":4},{"name":"Wigan","away_lost":6,"home_against":10,"goal_difference":2,"home_for":12,"away_drawn":2,"away_for":13,"home_won":6,"points":31,"total_played":22,"id":"wigan_athletic","home_lost":3,"away_against":13,"away_won":3,"home_drawn":2},{"name":"West Ham","away_lost":4,"home_against":16,"goal_difference":-2,"home_for":16,"away_drawn":4,"away_for":13,"home_won":5,"points":29,"total_played":22,"id":"west_ham_utd","home_lost":5,"away_against":15,"away_won":3,"home_drawn":1},{"name":"Hull","away_lost":3,"home_against":23,"goal_difference":-13,"home_for":11,"away_drawn":4,"away_for":18,"home_won":3,"points":27,"total_played":22,"id":"hull_city","home_lost":6,"away_against":19,"away_won":4,"home_drawn":2},{"name":"Fulham","away_lost":6,"home_against":8,"goal_difference":1,"home_for":16,"away_drawn":5,"away_for":3,"home_won":6,"points":26,"total_played":21,"id":"fulham","home_lost":1,"away_against":10,"away_won":0,"home_drawn":3},{"name":"Sunderland","away_lost":5,"home_against":15,"goal_difference":-8,"home_for":13,"away_drawn":3,"away_for":11,"home_won":4,"points":26,"total_played":23,"id":"sunderland","home_lost":6,"away_against":17,"away_won":3,"home_drawn":2},{"name":"Man City","away_lost":5,"home_against":11,"goal_difference":9,"home_for":25,"away_drawn":4,"away_for":14,"home_won":6,"points":25,"total_played":21,"id":"man_city","home_lost":5,"away_against":19,"away_won":1,"home_drawn":0},{"name":"Tottenham","away_lost":7,"home_against":9,"goal_difference":-4,"home_for":11,"away_drawn":2,"away_for":13,"home_won":4,"points":24,"total_played":23,"id":"tottenham_hotspur","home_lost":4,"away_against":19,"away_won":2,"home_drawn":4},{"name":"Portsmouth","away_lost":5,"home_against":18,"goal_difference":-13,"home_for":14,"away_drawn":4,"away_for":8,"home_won":4,"points":24,"total_played":22,"id":"portsmouth","home_lost":5,"away_against":17,"away_won":2,"home_drawn":2},{"name":"Bolton","away_lost":7,"home_against":12,"goal_difference":-8,"home_for":8,"away_drawn":0,"away_for":14,"home_won":3,"points":23,"total_played":22,"id":"bolton_wanderers","home_lost":6,"away_against":18,"away_won":4,"home_drawn":2},{"name":"Newcastle","away_lost":6,"home_against":19,"goal_difference":-9,"home_for":18,"away_drawn":4,"away_for":10,"home_won":4,"points":23,"total_played":22,"id":"newcastle_united","home_lost":3,"away_against":18,"away_won":1,"home_drawn":4},{"name":"Blackburn","away_lost":5,"home_against":17,"goal_difference":-11,"home_for":13,"away_drawn":3,"away_for":12,"home_won":3,"points":21,"total_played":21,"id":"blackburn_rovers","home_lost":5,"away_against":19,"away_won":2,"home_drawn":3},{"name":"Middlesbrough","away_lost":7,"home_against":15,"goal_difference":-15,"home_for":10,"away_drawn":2,"away_for":8,"home_won":3,"points":21,"total_played":22,"id":"middlesbrough","home_lost":4,"away_against":18,"away_won":2,"home_drawn":4},{"name":"Stoke","away_lost":9,"home_against":11,"goal_difference":-18,"home_for":12,"away_drawn":3,"away_for":8,"home_won":5,"points":21,"total_played":23,"id":"stoke_city","home_lost":3,"away_against":27,"away_won":0,"home_drawn":3},{"name":"West Brom","away_lost":9,"home_against":21,"goal_difference":-22,"home_for":16,"away_drawn":1,"away_for":4,"home_won":5,"points":21,"total_played":23,"id":"west_bromwich_albion","home_lost":5,"away_against":21,"away_won":1,"home_drawn":2}]
+[{"name":"Man Utd","away_lost":2,"home_against":4,"goal_difference":29,"home_for":24,"away_drawn":4,"away_for":15,"home_won":9,"points":50,"total_played":22,"id":"man_utd","home_lost":0,"away_against":6,"away_won":6,"home_drawn":1},{"name":"Chelsea","away_lost":1,"home_against":7,"goal_difference":31,"home_for":21,"away_drawn":2,"away_for":23,"home_won":6,"points":48,"total_played":23,"id":"chelsea","home_lost":2,"away_against":6,"away_won":8,"home_drawn":4},{"name":"Liverpool","away_lost":1,"home_against":7,"goal_difference":22,"home_for":17,"away_drawn":4,"away_for":20,"home_won":6,"points":48,"total_played":23,"id":"liverpool","home_lost":0,"away_against":8,"away_won":7,"home_drawn":5},{"name":"Aston Villa","away_lost":3,"home_against":12,"goal_difference":14,"home_for":18,"away_drawn":0,"away_for":20,"home_won":5,"points":47,"total_played":23,"id":"aston_villa","home_lost":1,"away_against":12,"away_won":9,"home_drawn":5},{"name":"Arsenal","away_lost":3,"home_against":11,"goal_difference":13,"home_for":18,"away_drawn":4,"away_for":20,"home_won":7,"points":42,"total_played":23,"id":"arsenal","home_lost":2,"away_against":14,"away_won":5,"home_drawn":2},{"name":"Everton","away_lost":2,"home_against":16,"goal_difference":4,"home_for":15,"away_drawn":2,"away_for":16,"home_won":3,"points":37,"total_played":23,"id":"everton","home_lost":4,"away_against":11,"away_won":7,"home_drawn":5},{"name":"Wigan","away_lost":6,"home_against":11,"goal_difference":2,"home_for":13,"away_drawn":2,"away_for":13,"home_won":6,"points":32,"total_played":23,"id":"wigan_athletic","home_lost":3,"away_against":13,"away_won":3,"home_drawn":3},{"name":"West Ham","away_lost":4,"home_against":16,"goal_difference":0,"home_for":18,"away_drawn":4,"away_for":13,"home_won":6,"points":32,"total_played":23,"id":"west_ham_utd","home_lost":5,"away_against":15,"away_won":3,"home_drawn":1},{"name":"Man City","away_lost":5,"home_against":12,"goal_difference":10,"home_for":27,"away_drawn":4,"away_for":14,"home_won":7,"points":28,"total_played":22,"id":"man_city","home_lost":5,"away_against":19,"away_won":1,"home_drawn":0},{"name":"Hull","away_lost":4,"home_against":23,"goal_difference":-15,"home_for":11,"away_drawn":4,"away_for":18,"home_won":3,"points":27,"total_played":23,"id":"hull_city","home_lost":6,"away_against":21,"away_won":4,"home_drawn":2},{"name":"Fulham","away_lost":6,"home_against":8,"goal_difference":1,"home_for":16,"away_drawn":5,"away_for":3,"home_won":6,"points":26,"total_played":21,"id":"fulham","home_lost":1,"away_against":10,"away_won":0,"home_drawn":3},{"name":"Sunderland","away_lost":5,"home_against":15,"goal_difference":-8,"home_for":13,"away_drawn":3,"away_for":11,"home_won":4,"points":26,"total_played":23,"id":"sunderland","home_lost":6,"away_against":17,"away_won":3,"home_drawn":2},{"name":"Tottenham","away_lost":7,"home_against":9,"goal_difference":-4,"home_for":11,"away_drawn":2,"away_for":13,"home_won":4,"points":24,"total_played":23,"id":"tottenham_hotspur","home_lost":4,"away_against":19,"away_won":2,"home_drawn":4},{"name":"Bolton","away_lost":7,"home_against":12,"goal_difference":-8,"home_for":8,"away_drawn":1,"away_for":16,"home_won":3,"points":24,"total_played":23,"id":"bolton_wanderers","home_lost":6,"away_against":20,"away_won":4,"home_drawn":2},{"name":"Portsmouth","away_lost":5,"home_against":18,"goal_difference":-13,"home_for":14,"away_drawn":4,"away_for":8,"home_won":4,"points":24,"total_played":22,"id":"portsmouth","home_lost":5,"away_against":17,"away_won":2,"home_drawn":2},{"name":"Newcastle","away_lost":7,"home_against":19,"goal_difference":-10,"home_for":18,"away_drawn":4,"away_for":11,"home_won":4,"points":23,"total_played":23,"id":"newcastle_united","home_lost":3,"away_against":20,"away_won":1,"home_drawn":4},{"name":"Blackburn","away_lost":5,"home_against":19,"goal_difference":-11,"home_for":15,"away_drawn":3,"away_for":12,"home_won":3,"points":22,"total_played":22,"id":"blackburn_rovers","home_lost":5,"away_against":19,"away_won":2,"home_drawn":4},{"name":"Middlesbrough","away_lost":8,"home_against":15,"goal_difference":-17,"home_for":10,"away_drawn":2,"away_for":8,"home_won":3,"points":21,"total_played":23,"id":"middlesbrough","home_lost":4,"away_against":20,"away_won":2,"home_drawn":4},{"name":"Stoke","away_lost":9,"home_against":11,"goal_difference":-18,"home_for":12,"away_drawn":3,"away_for":8,"home_won":5,"points":21,"total_played":23,"id":"stoke_city","home_lost":3,"away_against":27,"away_won":0,"home_drawn":3},{"name":"West Brom","away_lost":9,"home_against":21,"goal_difference":-22,"home_for":16,"away_drawn":1,"away_for":4,"home_won":5,"points":21,"total_played":23,"id":"west_bromwich_albion","home_lost":5,"away_against":21,"away_won":1,"home_drawn":2}]
diff --git a/js/epl/teams/fixtures/arsenal.js b/js/epl/teams/fixtures/arsenal.js
index 13050b3..4240d31 100644
--- a/js/epl/teams/fixtures/arsenal.js
+++ b/js/epl/teams/fixtures/arsenal.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Arsenal v Cardiff","date":"03 February 2009","unix_time":1233661500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Arsenal v Roma","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Roma v Arsenal","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237627800,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Arsenal v Cardiff","date":"03 February 2009","unix_time":1233661500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Arsenal v Roma","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Roma v Arsenal","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237627800,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/blackburn_rovers.js b/js/epl/teams/fixtures/blackburn_rovers.js
index 719b994..9d44843 100644
--- a/js/epl/teams/fixtures/blackburn_rovers.js
+++ b/js/epl/teams/fixtures/blackburn_rovers.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Blackburn v Bolton","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Blackburn","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Blackburn v Sunderland","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Blackburn v Aston Villa","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Tottenham","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Blackburn","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Wigan","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Blackburn","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Portsmouth","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Brom","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Middlesbrough v Blackburn","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Blackburn v Sunderland","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Blackburn v Aston Villa","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Tottenham","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Blackburn","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Wigan","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Blackburn","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Portsmouth","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Brom","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/bolton_wanderers.js b/js/epl/teams/fixtures/bolton_wanderers.js
index 0fefa3f..ed5eef1 100644
--- a/js/epl/teams/fixtures/bolton_wanderers.js
+++ b/js/epl/teams/fixtures/bolton_wanderers.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Blackburn v Bolton","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Tottenham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Newcastle","date":"01 March 2009","unix_time":1235883600,"gmt_time":"13:00"},{"competition":"Barclays Premier League","details":"Stoke v Bolton","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Bolton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Middlesbrough","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Bolton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Aston Villa","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Bolton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Sunderland","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Bolton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Bolton v Tottenham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Newcastle","date":"01 March 2009","unix_time":1235883600,"gmt_time":"13:00"},{"competition":"Barclays Premier League","details":"Stoke v Bolton","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Bolton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Middlesbrough","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Bolton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Aston Villa","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Bolton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Sunderland","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Bolton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/chelsea.js b/js/epl/teams/fixtures/chelsea.js
index a7081ef..d8843c5 100644
--- a/js/epl/teams/fixtures/chelsea.js
+++ b/js/epl/teams/fixtures/chelsea.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Watford v Chelsea","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Champions League","details":"Chelsea v Juventus","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Juventus v Chelsea","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"15 March 2009","unix_time":1237095000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Watford v Chelsea","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Champions League","details":"Chelsea v Juventus","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Juventus v Chelsea","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"15 March 2009","unix_time":1237095000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/everton.js b/js/epl/teams/fixtures/everton.js
index 5e997f4..90f9622 100644
--- a/js/epl/teams/fixtures/everton.js
+++ b/js/epl/teams/fixtures/everton.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"31 January 2009","unix_time":1233394200,"gmt_time":"17:30"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233749400,"gmt_time":"20:10"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237610700,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"31 January 2009","unix_time":1233394200,"gmt_time":"17:30"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233749400,"gmt_time":"20:10"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237610700,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/fulham.js b/js/epl/teams/fixtures/fulham.js
index af7c49f..14bbb16 100644
--- a/js/epl/teams/fixtures/fulham.js
+++ b/js/epl/teams/fixtures/fulham.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Swansea v Fulham","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Swansea v Fulham","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"18 February 2009","unix_time":1234958400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/hull_city.js b/js/epl/teams/fixtures/hull_city.js
index c4b1ca1..d0aa495 100644
--- a/js/epl/teams/fixtures/hull_city.js
+++ b/js/epl/teams/fixtures/hull_city.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Sheff Utd v Hull","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"22 March 2009","unix_time":1237699800,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Sheff Utd v Hull","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"22 March 2009","unix_time":1237699800,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/liverpool.js b/js/epl/teams/fixtures/liverpool.js
index cb56a0d..3d3fbeb 100644
--- a/js/epl/teams/fixtures/liverpool.js
+++ b/js/epl/teams/fixtures/liverpool.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233749400,"gmt_time":"20:10"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Real Madrid v Liverpool","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"03 March 2009","unix_time":1236081600,"gmt_time":"20:00"},{"competition":"UEFA Champions League","details":"Liverpool v Real Madrid","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237005900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"22 March 2009","unix_time":1237708800,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233749400,"gmt_time":"20:10"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Real Madrid v Liverpool","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"03 March 2009","unix_time":1236081600,"gmt_time":"20:00"},{"competition":"UEFA Champions League","details":"Liverpool v Real Madrid","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237005900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"22 March 2009","unix_time":1237708800,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/man_city.js b/js/epl/teams/fixtures/man_city.js
index 2fce569..9507f3b 100644
--- a/js/epl/teams/fixtures/man_city.js
+++ b/js/epl/teams/fixtures/man_city.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Man City v Newcastle","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Stoke v Man City","date":"31 January 2009","unix_time":1233377100,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Portsmouth v Man City","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"FC Copenhagen v Man City","date":"19 February 2009","unix_time":1235041500,"gmt_time":"19:05"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"Man City v FC Copenhagen","date":"26 February 2009","unix_time":1235648700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Man City v Aston Villa","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"15 March 2009","unix_time":1237095000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Man City v Sunderland","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v West Brom","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Blackburn","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Bolton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Stoke v Man City","date":"31 January 2009","unix_time":1233377100,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Portsmouth v Man City","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"FC Copenhagen v Man City","date":"19 February 2009","unix_time":1235041500,"gmt_time":"19:05"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"Man City v FC Copenhagen","date":"26 February 2009","unix_time":1235648700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Man City v Aston Villa","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"15 March 2009","unix_time":1237095000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Man City v Sunderland","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v West Brom","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Blackburn","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Bolton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/man_utd.js b/js/epl/teams/fixtures/man_utd.js
index 9bb24c7..a7fbf6e 100644
--- a/js/epl/teams/fixtures/man_utd.js
+++ b/js/epl/teams/fixtures/man_utd.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"31 January 2009","unix_time":1233394200,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Derby\/ Nottm Forest v Man Utd","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"UEFA Champions League","details":"Inter Milan v Man Utd","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Man Utd v Inter Milan","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237005900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"31 January 2009","unix_time":1233394200,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Derby\/ Nottm Forest v Man Utd","date":"15 February 2009","unix_time":1234686600,"gmt_time":"16:30"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"18 February 2009","unix_time":1234958400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"UEFA Champions League","details":"Inter Milan v Man Utd","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Man Utd v Inter Milan","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237005900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/middlesbrough.js b/js/epl/teams/fixtures/middlesbrough.js
index 73abb22..66b2090 100644
--- a/js/epl/teams/fixtures/middlesbrough.js
+++ b/js/epl/teams/fixtures/middlesbrough.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Blackburn","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Portsmouth","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Middlesbrough","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Middlesbrough","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Aston Villa","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Middlesbrough v Blackburn","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Portsmouth","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Middlesbrough","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Middlesbrough","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Aston Villa","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/newcastle_united.js b/js/epl/teams/fixtures/newcastle_united.js
index e73af57..193f9cb 100644
--- a/js/epl/teams/fixtures/newcastle_united.js
+++ b/js/epl/teams/fixtures/newcastle_united.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Man City v Newcastle","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Newcastle v Sunderland","date":"01 February 2009","unix_time":1233466200,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"West Brom v Newcastle","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Bolton v Newcastle","date":"01 March 2009","unix_time":1235883600,"gmt_time":"13:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237627800,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Newcastle","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Portsmouth","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Newcastle","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Newcastle v Sunderland","date":"01 February 2009","unix_time":1233466200,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"West Brom v Newcastle","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Bolton v Newcastle","date":"01 March 2009","unix_time":1235883600,"gmt_time":"13:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237627800,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Newcastle","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Portsmouth","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Newcastle","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/tottenham_hotspur.js b/js/epl/teams/fixtures/tottenham_hotspur.js
index 0f814cb..669f659 100644
--- a/js/epl/teams/fixtures/tottenham_hotspur.js
+++ b/js/epl/teams/fixtures/tottenham_hotspur.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Bolton v Tottenham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"UEFA Cup","details":"Shakhtar Donetsk v Tottenham","date":"19 February 2009","unix_time":1235034000,"gmt_time":"17:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"UEFA Cup","details":"Tottenham v Shakhtar Donetsk","date":"26 February 2009","unix_time":1235649600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland OFF Tottenham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Tottenham","date":"15 March 2009","unix_time":1237104000,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Tottenham","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Brom","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Bolton v Tottenham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"UEFA Cup","details":"Shakhtar Donetsk v Tottenham","date":"19 February 2009","unix_time":1235040300,"gmt_time":"18:45"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"UEFA Cup","details":"Tottenham v Shakhtar Donetsk","date":"26 February 2009","unix_time":1235649600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland OFF Tottenham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Tottenham","date":"15 March 2009","unix_time":1237104000,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Tottenham","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Brom","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/west_ham_utd.js b/js/epl/teams/fixtures/west_ham_utd.js
index fdb78ae..ef3e2fc 100644
--- a/js/epl/teams/fixtures/west_ham_utd.js
+++ b/js/epl/teams/fixtures/west_ham_utd.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"16 March 2009","unix_time":1237204800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"16 March 2009","unix_time":1237204800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/wigan_athletic.js b/js/epl/teams/fixtures/wigan_athletic.js
index 68495d1..520fd08 100644
--- a/js/epl/teams/fixtures/wigan_athletic.js
+++ b/js/epl/teams/fixtures/wigan_athletic.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Aston Villa v Wigan","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Sunderland v Wigan","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"22 March 2009","unix_time":1237699800,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Wigan","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Bolton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Wigan","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Wigan","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Portsmouth","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Aston Villa v Wigan","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Sunderland v Wigan","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"22 March 2009","unix_time":1237699800,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Wigan","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Bolton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Wigan","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Wigan","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Portsmouth","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/plists/epl/all_teams.plist b/plists/epl/all_teams.plist
index 18c4027..18c150c 100644
--- a/plists/epl/all_teams.plist
+++ b/plists/epl/all_teams.plist
@@ -1,646 +1,646 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>away_against</key>
<integer>6</integer>
<key>away_drawn</key>
<integer>4</integer>
<key>away_for</key>
<integer>15</integer>
<key>away_lost</key>
<integer>2</integer>
<key>away_won</key>
<integer>6</integer>
<key>goal_difference</key>
<integer>29</integer>
<key>home_against</key>
<integer>4</integer>
<key>home_drawn</key>
<integer>1</integer>
<key>home_for</key>
<integer>24</integer>
<key>home_lost</key>
<integer>0</integer>
<key>home_won</key>
<integer>9</integer>
<key>id</key>
<string>man_utd</string>
<key>name</key>
<string>Man Utd</string>
<key>points</key>
<integer>50</integer>
<key>total_played</key>
<integer>22</integer>
</dict>
<dict>
<key>away_against</key>
+ <integer>6</integer>
+ <key>away_drawn</key>
+ <integer>2</integer>
+ <key>away_for</key>
+ <integer>23</integer>
+ <key>away_lost</key>
+ <integer>1</integer>
+ <key>away_won</key>
+ <integer>8</integer>
+ <key>goal_difference</key>
+ <integer>31</integer>
+ <key>home_against</key>
<integer>7</integer>
+ <key>home_drawn</key>
+ <integer>4</integer>
+ <key>home_for</key>
+ <integer>21</integer>
+ <key>home_lost</key>
+ <integer>2</integer>
+ <key>home_won</key>
+ <integer>6</integer>
+ <key>id</key>
+ <string>chelsea</string>
+ <key>name</key>
+ <string>Chelsea</string>
+ <key>points</key>
+ <integer>48</integer>
+ <key>total_played</key>
+ <integer>23</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>8</integer>
<key>away_drawn</key>
- <integer>3</integer>
+ <integer>4</integer>
<key>away_for</key>
- <integer>19</integer>
+ <integer>20</integer>
<key>away_lost</key>
<integer>1</integer>
<key>away_won</key>
<integer>7</integer>
<key>goal_difference</key>
<integer>22</integer>
<key>home_against</key>
<integer>7</integer>
<key>home_drawn</key>
<integer>5</integer>
<key>home_for</key>
<integer>17</integer>
<key>home_lost</key>
<integer>0</integer>
<key>home_won</key>
<integer>6</integer>
<key>id</key>
<string>liverpool</string>
<key>name</key>
<string>Liverpool</string>
<key>points</key>
- <integer>47</integer>
+ <integer>48</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>12</integer>
<key>away_drawn</key>
<integer>0</integer>
<key>away_for</key>
<integer>20</integer>
<key>away_lost</key>
<integer>3</integer>
<key>away_won</key>
<integer>9</integer>
<key>goal_difference</key>
<integer>14</integer>
<key>home_against</key>
<integer>12</integer>
<key>home_drawn</key>
<integer>5</integer>
<key>home_for</key>
<integer>18</integer>
<key>home_lost</key>
<integer>1</integer>
<key>home_won</key>
<integer>5</integer>
<key>id</key>
<string>aston_villa</string>
<key>name</key>
<string>Aston Villa</string>
<key>points</key>
<integer>47</integer>
<key>total_played</key>
<integer>23</integer>
</dict>
<dict>
<key>away_against</key>
- <integer>6</integer>
+ <integer>14</integer>
<key>away_drawn</key>
- <integer>2</integer>
- <key>away_for</key>
- <integer>23</integer>
- <key>away_lost</key>
- <integer>1</integer>
- <key>away_won</key>
- <integer>8</integer>
- <key>goal_difference</key>
- <integer>29</integer>
- <key>home_against</key>
- <integer>7</integer>
- <key>home_drawn</key>
<integer>4</integer>
- <key>home_for</key>
- <integer>19</integer>
- <key>home_lost</key>
- <integer>2</integer>
- <key>home_won</key>
- <integer>5</integer>
- <key>id</key>
- <string>chelsea</string>
- <key>name</key>
- <string>Chelsea</string>
- <key>points</key>
- <integer>45</integer>
- <key>total_played</key>
- <integer>22</integer>
- </dict>
- <dict>
- <key>away_against</key>
- <integer>13</integer>
- <key>away_drawn</key>
- <integer>3</integer>
<key>away_for</key>
- <integer>19</integer>
+ <integer>20</integer>
<key>away_lost</key>
<integer>3</integer>
<key>away_won</key>
<integer>5</integer>
<key>goal_difference</key>
<integer>13</integer>
<key>home_against</key>
<integer>11</integer>
<key>home_drawn</key>
<integer>2</integer>
<key>home_for</key>
<integer>18</integer>
<key>home_lost</key>
<integer>2</integer>
<key>home_won</key>
<integer>7</integer>
<key>id</key>
<string>arsenal</string>
<key>name</key>
<string>Arsenal</string>
<key>points</key>
- <integer>41</integer>
+ <integer>42</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>11</integer>
<key>away_drawn</key>
<integer>2</integer>
<key>away_for</key>
<integer>16</integer>
<key>away_lost</key>
<integer>2</integer>
<key>away_won</key>
<integer>7</integer>
<key>goal_difference</key>
<integer>4</integer>
<key>home_against</key>
- <integer>15</integer>
+ <integer>16</integer>
<key>home_drawn</key>
- <integer>4</integer>
+ <integer>5</integer>
<key>home_for</key>
- <integer>14</integer>
+ <integer>15</integer>
<key>home_lost</key>
<integer>4</integer>
<key>home_won</key>
<integer>3</integer>
<key>id</key>
<string>everton</string>
<key>name</key>
<string>Everton</string>
<key>points</key>
- <integer>36</integer>
+ <integer>37</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>13</integer>
<key>away_drawn</key>
<integer>2</integer>
<key>away_for</key>
<integer>13</integer>
<key>away_lost</key>
<integer>6</integer>
<key>away_won</key>
<integer>3</integer>
<key>goal_difference</key>
<integer>2</integer>
<key>home_against</key>
- <integer>10</integer>
+ <integer>11</integer>
<key>home_drawn</key>
- <integer>2</integer>
+ <integer>3</integer>
<key>home_for</key>
- <integer>12</integer>
+ <integer>13</integer>
<key>home_lost</key>
<integer>3</integer>
<key>home_won</key>
<integer>6</integer>
<key>id</key>
<string>wigan_athletic</string>
<key>name</key>
<string>Wigan</string>
<key>points</key>
- <integer>31</integer>
+ <integer>32</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>15</integer>
<key>away_drawn</key>
<integer>4</integer>
<key>away_for</key>
<integer>13</integer>
<key>away_lost</key>
<integer>4</integer>
<key>away_won</key>
<integer>3</integer>
<key>goal_difference</key>
- <integer>-2</integer>
+ <integer>0</integer>
<key>home_against</key>
<integer>16</integer>
<key>home_drawn</key>
<integer>1</integer>
<key>home_for</key>
- <integer>16</integer>
+ <integer>18</integer>
<key>home_lost</key>
<integer>5</integer>
<key>home_won</key>
- <integer>5</integer>
+ <integer>6</integer>
<key>id</key>
<string>west_ham_utd</string>
<key>name</key>
<string>West Ham</string>
<key>points</key>
- <integer>29</integer>
+ <integer>32</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>19</integer>
<key>away_drawn</key>
<integer>4</integer>
<key>away_for</key>
+ <integer>14</integer>
+ <key>away_lost</key>
+ <integer>5</integer>
+ <key>away_won</key>
+ <integer>1</integer>
+ <key>goal_difference</key>
+ <integer>10</integer>
+ <key>home_against</key>
+ <integer>12</integer>
+ <key>home_drawn</key>
+ <integer>0</integer>
+ <key>home_for</key>
+ <integer>27</integer>
+ <key>home_lost</key>
+ <integer>5</integer>
+ <key>home_won</key>
+ <integer>7</integer>
+ <key>id</key>
+ <string>man_city</string>
+ <key>name</key>
+ <string>Man City</string>
+ <key>points</key>
+ <integer>28</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>21</integer>
+ <key>away_drawn</key>
+ <integer>4</integer>
+ <key>away_for</key>
<integer>18</integer>
<key>away_lost</key>
- <integer>3</integer>
+ <integer>4</integer>
<key>away_won</key>
<integer>4</integer>
<key>goal_difference</key>
- <integer>-13</integer>
+ <integer>-15</integer>
<key>home_against</key>
<integer>23</integer>
<key>home_drawn</key>
<integer>2</integer>
<key>home_for</key>
<integer>11</integer>
<key>home_lost</key>
<integer>6</integer>
<key>home_won</key>
<integer>3</integer>
<key>id</key>
<string>hull_city</string>
<key>name</key>
<string>Hull</string>
<key>points</key>
<integer>27</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>10</integer>
<key>away_drawn</key>
<integer>5</integer>
<key>away_for</key>
<integer>3</integer>
<key>away_lost</key>
<integer>6</integer>
<key>away_won</key>
<integer>0</integer>
<key>goal_difference</key>
<integer>1</integer>
<key>home_against</key>
<integer>8</integer>
<key>home_drawn</key>
<integer>3</integer>
<key>home_for</key>
<integer>16</integer>
<key>home_lost</key>
<integer>1</integer>
<key>home_won</key>
<integer>6</integer>
<key>id</key>
<string>fulham</string>
<key>name</key>
<string>Fulham</string>
<key>points</key>
<integer>26</integer>
<key>total_played</key>
<integer>21</integer>
</dict>
<dict>
<key>away_against</key>
<integer>17</integer>
<key>away_drawn</key>
<integer>3</integer>
<key>away_for</key>
<integer>11</integer>
<key>away_lost</key>
<integer>5</integer>
<key>away_won</key>
<integer>3</integer>
<key>goal_difference</key>
<integer>-8</integer>
<key>home_against</key>
<integer>15</integer>
<key>home_drawn</key>
<integer>2</integer>
<key>home_for</key>
<integer>13</integer>
<key>home_lost</key>
<integer>6</integer>
<key>home_won</key>
<integer>4</integer>
<key>id</key>
<string>sunderland</string>
<key>name</key>
<string>Sunderland</string>
<key>points</key>
<integer>26</integer>
<key>total_played</key>
<integer>23</integer>
</dict>
- <dict>
- <key>away_against</key>
- <integer>19</integer>
- <key>away_drawn</key>
- <integer>4</integer>
- <key>away_for</key>
- <integer>14</integer>
- <key>away_lost</key>
- <integer>5</integer>
- <key>away_won</key>
- <integer>1</integer>
- <key>goal_difference</key>
- <integer>9</integer>
- <key>home_against</key>
- <integer>11</integer>
- <key>home_drawn</key>
- <integer>0</integer>
- <key>home_for</key>
- <integer>25</integer>
- <key>home_lost</key>
- <integer>5</integer>
- <key>home_won</key>
- <integer>6</integer>
- <key>id</key>
- <string>man_city</string>
- <key>name</key>
- <string>Man City</string>
- <key>points</key>
- <integer>25</integer>
- <key>total_played</key>
- <integer>21</integer>
- </dict>
<dict>
<key>away_against</key>
<integer>19</integer>
<key>away_drawn</key>
<integer>2</integer>
<key>away_for</key>
<integer>13</integer>
<key>away_lost</key>
<integer>7</integer>
<key>away_won</key>
<integer>2</integer>
<key>goal_difference</key>
<integer>-4</integer>
<key>home_against</key>
<integer>9</integer>
<key>home_drawn</key>
<integer>4</integer>
<key>home_for</key>
<integer>11</integer>
<key>home_lost</key>
<integer>4</integer>
<key>home_won</key>
<integer>4</integer>
<key>id</key>
<string>tottenham_hotspur</string>
<key>name</key>
<string>Tottenham</string>
<key>points</key>
<integer>24</integer>
<key>total_played</key>
<integer>23</integer>
</dict>
<dict>
<key>away_against</key>
- <integer>17</integer>
+ <integer>20</integer>
<key>away_drawn</key>
- <integer>4</integer>
+ <integer>1</integer>
<key>away_for</key>
- <integer>8</integer>
+ <integer>16</integer>
<key>away_lost</key>
- <integer>5</integer>
+ <integer>7</integer>
<key>away_won</key>
- <integer>2</integer>
+ <integer>4</integer>
<key>goal_difference</key>
- <integer>-13</integer>
+ <integer>-8</integer>
<key>home_against</key>
- <integer>18</integer>
+ <integer>12</integer>
<key>home_drawn</key>
<integer>2</integer>
<key>home_for</key>
- <integer>14</integer>
+ <integer>8</integer>
<key>home_lost</key>
- <integer>5</integer>
+ <integer>6</integer>
<key>home_won</key>
- <integer>4</integer>
+ <integer>3</integer>
<key>id</key>
- <string>portsmouth</string>
+ <string>bolton_wanderers</string>
<key>name</key>
- <string>Portsmouth</string>
+ <string>Bolton</string>
<key>points</key>
<integer>24</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
- <integer>18</integer>
+ <integer>17</integer>
<key>away_drawn</key>
- <integer>0</integer>
+ <integer>4</integer>
<key>away_for</key>
- <integer>14</integer>
+ <integer>8</integer>
<key>away_lost</key>
- <integer>7</integer>
+ <integer>5</integer>
<key>away_won</key>
- <integer>4</integer>
+ <integer>2</integer>
<key>goal_difference</key>
- <integer>-8</integer>
+ <integer>-13</integer>
<key>home_against</key>
- <integer>12</integer>
+ <integer>18</integer>
<key>home_drawn</key>
<integer>2</integer>
<key>home_for</key>
- <integer>8</integer>
+ <integer>14</integer>
<key>home_lost</key>
- <integer>6</integer>
+ <integer>5</integer>
<key>home_won</key>
- <integer>3</integer>
+ <integer>4</integer>
<key>id</key>
- <string>bolton_wanderers</string>
+ <string>portsmouth</string>
<key>name</key>
- <string>Bolton</string>
+ <string>Portsmouth</string>
<key>points</key>
- <integer>23</integer>
+ <integer>24</integer>
<key>total_played</key>
<integer>22</integer>
</dict>
<dict>
<key>away_against</key>
- <integer>18</integer>
+ <integer>20</integer>
<key>away_drawn</key>
<integer>4</integer>
<key>away_for</key>
- <integer>10</integer>
+ <integer>11</integer>
<key>away_lost</key>
- <integer>6</integer>
+ <integer>7</integer>
<key>away_won</key>
<integer>1</integer>
<key>goal_difference</key>
- <integer>-9</integer>
+ <integer>-10</integer>
<key>home_against</key>
<integer>19</integer>
<key>home_drawn</key>
<integer>4</integer>
<key>home_for</key>
<integer>18</integer>
<key>home_lost</key>
<integer>3</integer>
<key>home_won</key>
<integer>4</integer>
<key>id</key>
<string>newcastle_united</string>
<key>name</key>
<string>Newcastle</string>
<key>points</key>
<integer>23</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>19</integer>
<key>away_drawn</key>
<integer>3</integer>
<key>away_for</key>
<integer>12</integer>
<key>away_lost</key>
<integer>5</integer>
<key>away_won</key>
<integer>2</integer>
<key>goal_difference</key>
<integer>-11</integer>
<key>home_against</key>
- <integer>17</integer>
+ <integer>19</integer>
<key>home_drawn</key>
- <integer>3</integer>
+ <integer>4</integer>
<key>home_for</key>
- <integer>13</integer>
+ <integer>15</integer>
<key>home_lost</key>
<integer>5</integer>
<key>home_won</key>
<integer>3</integer>
<key>id</key>
<string>blackburn_rovers</string>
<key>name</key>
<string>Blackburn</string>
<key>points</key>
- <integer>21</integer>
+ <integer>22</integer>
<key>total_played</key>
- <integer>21</integer>
+ <integer>22</integer>
</dict>
<dict>
<key>away_against</key>
- <integer>18</integer>
+ <integer>20</integer>
<key>away_drawn</key>
<integer>2</integer>
<key>away_for</key>
<integer>8</integer>
<key>away_lost</key>
- <integer>7</integer>
+ <integer>8</integer>
<key>away_won</key>
<integer>2</integer>
<key>goal_difference</key>
- <integer>-15</integer>
+ <integer>-17</integer>
<key>home_against</key>
<integer>15</integer>
<key>home_drawn</key>
<integer>4</integer>
<key>home_for</key>
<integer>10</integer>
<key>home_lost</key>
<integer>4</integer>
<key>home_won</key>
<integer>3</integer>
<key>id</key>
<string>middlesbrough</string>
<key>name</key>
<string>Middlesbrough</string>
<key>points</key>
<integer>21</integer>
<key>total_played</key>
- <integer>22</integer>
+ <integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>27</integer>
<key>away_drawn</key>
<integer>3</integer>
<key>away_for</key>
<integer>8</integer>
<key>away_lost</key>
<integer>9</integer>
<key>away_won</key>
<integer>0</integer>
<key>goal_difference</key>
<integer>-18</integer>
<key>home_against</key>
<integer>11</integer>
<key>home_drawn</key>
<integer>3</integer>
<key>home_for</key>
<integer>12</integer>
<key>home_lost</key>
<integer>3</integer>
<key>home_won</key>
<integer>5</integer>
<key>id</key>
<string>stoke_city</string>
<key>name</key>
<string>Stoke</string>
<key>points</key>
<integer>21</integer>
<key>total_played</key>
<integer>23</integer>
</dict>
<dict>
<key>away_against</key>
<integer>21</integer>
<key>away_drawn</key>
<integer>1</integer>
<key>away_for</key>
<integer>4</integer>
<key>away_lost</key>
<integer>9</integer>
<key>away_won</key>
<integer>1</integer>
<key>goal_difference</key>
<integer>-22</integer>
<key>home_against</key>
<integer>21</integer>
<key>home_drawn</key>
<integer>2</integer>
<key>home_for</key>
<integer>16</integer>
<key>home_lost</key>
<integer>5</integer>
<key>home_won</key>
<integer>5</integer>
<key>id</key>
<string>west_bromwich_albion</string>
<key>name</key>
<string>West Brom</string>
<key>points</key>
<integer>21</integer>
<key>total_played</key>
<integer>23</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/arsenal.plist b/plists/epl/teams/fixtures/arsenal.plist
index d78e468..13443f3 100644
--- a/plists/epl/teams/fixtures/arsenal.plist
+++ b/plists/epl/teams/fixtures/arsenal.plist
@@ -1,234 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Everton v Arsenal</string>
- <key>gmt_time</key>
- <string>20:00</string>
- <key>unix_time</key>
- <integer>1233144000</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Arsenal v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>03 February 2009</string>
<key>details</key>
<string>Arsenal v Cardiff</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1233661500</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>08 February 2009</string>
<key>details</key>
<string>Tottenham v Arsenal</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1234071000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Arsenal v Sunderland</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235199600</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>24 February 2009</string>
<key>details</key>
<string>Arsenal v Roma</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1235475900</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Arsenal v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>03 March 2009</string>
<key>details</key>
<string>West Brom v Arsenal</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236080700</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>11 March 2009</string>
<key>details</key>
<string>Roma v Arsenal</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236771900</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Arsenal v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Newcastle v Arsenal</string>
<key>gmt_time</key>
<string>17:30</string>
<key>unix_time</key>
<integer>1237627800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Arsenal v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Wigan v Arsenal</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Liverpool v Arsenal</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Arsenal v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Portsmouth v Arsenal</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Arsenal v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Man Utd v Arsenal</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Arsenal v Stoke</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/blackburn_rovers.plist b/plists/epl/teams/fixtures/blackburn_rovers.plist
index 5ce3f9d..821b41b 100644
--- a/plists/epl/teams/fixtures/blackburn_rovers.plist
+++ b/plists/epl/teams/fixtures/blackburn_rovers.plist
@@ -1,222 +1,210 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Blackburn v Bolton</string>
- <key>gmt_time</key>
- <string>20:00</string>
- <key>unix_time</key>
- <integer>1233144000</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Middlesbrough v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>04 February 2009</string>
<key>details</key>
<string>Blackburn v Sunderland</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1233748800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Blackburn v Aston Villa</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Man Utd v Blackburn</string>
<key>gmt_time</key>
<string>17:30</string>
<key>unix_time</key>
<integer>1235208600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Hull v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Blackburn v Everton</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236168000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 March 2009</string>
<key>details</key>
<string>Fulham v Blackburn</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236772800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Arsenal v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Blackburn v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Blackburn v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Liverpool v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Stoke v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Blackburn v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Man City v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Blackburn v Portsmouth</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Chelsea v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Blackburn v West Brom</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/bolton_wanderers.plist b/plists/epl/teams/fixtures/bolton_wanderers.plist
index 5950ff0..dac61f4 100644
--- a/plists/epl/teams/fixtures/bolton_wanderers.plist
+++ b/plists/epl/teams/fixtures/bolton_wanderers.plist
@@ -1,198 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Blackburn v Bolton</string>
- <key>gmt_time</key>
- <string>20:00</string>
- <key>unix_time</key>
- <integer>1233144000</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Bolton v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Everton v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Bolton v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235199600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>01 March 2009</string>
<key>details</key>
<string>Bolton v Newcastle</string>
<key>gmt_time</key>
<string>13:00</string>
<key>unix_time</key>
<integer>1235883600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Stoke v Bolton</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236167100</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Bolton v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>West Brom v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Bolton v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Chelsea v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Portsmouth v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Bolton v Aston Villa</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Wigan v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Bolton v Sunderland</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Bolton v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Man City v Bolton</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/chelsea.plist b/plists/epl/teams/fixtures/chelsea.plist
index 5e62e95..e7d2600 100644
--- a/plists/epl/teams/fixtures/chelsea.plist
+++ b/plists/epl/teams/fixtures/chelsea.plist
@@ -1,234 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Chelsea v Middlesbrough</string>
- <key>gmt_time</key>
- <string>19:45</string>
- <key>unix_time</key>
- <integer>1233143100</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>01 February 2009</string>
<key>details</key>
<string>Liverpool v Chelsea</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1233475200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Chelsea v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>14 February 2009</string>
<key>details</key>
<string>Watford v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1234594800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Aston Villa v Chelsea</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1235191500</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>25 February 2009</string>
<key>details</key>
<string>Chelsea v Juventus</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1235562300</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Chelsea v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>03 March 2009</string>
<key>details</key>
<string>Portsmouth v Chelsea</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236080700</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>10 March 2009</string>
<key>details</key>
<string>Juventus v Chelsea</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236685500</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>15 March 2009</string>
<key>details</key>
<string>Chelsea v Man City</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1237095000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Tottenham v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Newcastle v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Chelsea v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Chelsea v Everton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>West Ham v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Chelsea v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Arsenal v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Chelsea v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Sunderland v Chelsea</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/everton.plist b/plists/epl/teams/fixtures/everton.plist
index 832bfb7..d3858b2 100644
--- a/plists/epl/teams/fixtures/everton.plist
+++ b/plists/epl/teams/fixtures/everton.plist
@@ -1,210 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Everton v Arsenal</string>
- <key>gmt_time</key>
- <string>20:00</string>
- <key>unix_time</key>
- <integer>1233144000</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Man Utd v Everton</string>
<key>gmt_time</key>
<string>17:30</string>
<key>unix_time</key>
<integer>1233394200</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>04 February 2009</string>
<key>details</key>
<string>Everton v Liverpool</string>
<key>gmt_time</key>
<string>20:10</string>
<key>unix_time</key>
<integer>1233749400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Everton v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 February 2009</string>
<key>details</key>
<string>Newcastle v Everton</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1235289600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Everton v West Brom</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1235796300</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Blackburn v Everton</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236168000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Everton v Stoke</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Portsmouth v Everton</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1237610700</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>05 April 2009</string>
<key>details</key>
<string>Everton v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238914800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Aston Villa v Everton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Chelsea v Everton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Everton v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Sunderland v Everton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Everton v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Everton v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Fulham v Everton</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/fulham.plist b/plists/epl/teams/fixtures/fulham.plist
index 7115618..ed34899 100644
--- a/plists/epl/teams/fixtures/fulham.plist
+++ b/plists/epl/teams/fixtures/fulham.plist
@@ -1,222 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Fulham v Portsmouth</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Wigan v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>14 February 2009</string>
<key>details</key>
<string>Swansea v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1234594800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
- <string>17 February 2009</string>
+ <string>18 February 2009</string>
<key>details</key>
<string>Man Utd v Fulham</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
- <integer>1234872000</integer>
+ <integer>1234958400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 February 2009</string>
<key>details</key>
<string>Fulham v West Brom</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1235280600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Arsenal v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Fulham v Hull</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236168000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 March 2009</string>
<key>details</key>
<string>Fulham v Blackburn</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236772800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Bolton v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Fulham v Man Utd</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Fulham v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Man City v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Middlesbrough v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Fulham v Stoke</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Chelsea v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Fulham v Aston Villa</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Newcastle v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Fulham v Everton</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/hull_city.plist b/plists/epl/teams/fixtures/hull_city.plist
index 111f3f0..0af9bf1 100644
--- a/plists/epl/teams/fixtures/hull_city.plist
+++ b/plists/epl/teams/fixtures/hull_city.plist
@@ -1,210 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>West Ham v Hull</string>
- <key>gmt_time</key>
- <string>20:00</string>
- <key>unix_time</key>
- <integer>1233144000</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Hull v West Brom</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Chelsea v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>14 February 2009</string>
<key>details</key>
<string>Sheff Utd v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1234594800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>23 February 2009</string>
<key>details</key>
<string>Hull v Tottenham</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1235390400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Hull v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Fulham v Hull</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236168000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Hull v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 March 2009</string>
<key>details</key>
<string>Wigan v Hull</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1237699800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Hull v Portsmouth</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Middlesbrough v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Sunderland v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Hull v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Aston Villa v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Hull v Stoke</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Bolton v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Hull v Man Utd</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/liverpool.plist b/plists/epl/teams/fixtures/liverpool.plist
index b0edebe..c67caf6 100644
--- a/plists/epl/teams/fixtures/liverpool.plist
+++ b/plists/epl/teams/fixtures/liverpool.plist
@@ -1,234 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Wigan v Liverpool</string>
- <key>gmt_time</key>
- <string>19:45</string>
- <key>unix_time</key>
- <integer>1233143100</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>01 February 2009</string>
<key>details</key>
<string>Liverpool v Chelsea</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1233475200</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>04 February 2009</string>
<key>details</key>
<string>Everton v Liverpool</string>
<key>gmt_time</key>
<string>20:10</string>
<key>unix_time</key>
<integer>1233749400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Portsmouth v Liverpool</string>
<key>gmt_time</key>
<string>17:30</string>
<key>unix_time</key>
<integer>1233999000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 February 2009</string>
<key>details</key>
<string>Liverpool v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235286000</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>25 February 2009</string>
<key>details</key>
<string>Real Madrid v Liverpool</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1235562300</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Middlesbrough v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>03 March 2009</string>
<key>details</key>
<string>Liverpool v Sunderland</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236081600</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>10 March 2009</string>
<key>details</key>
<string>Liverpool v Real Madrid</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236685500</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Man Utd v Liverpool</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1237005900</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 March 2009</string>
<key>details</key>
<string>Liverpool v Aston Villa</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1237708800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Fulham v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Liverpool v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Liverpool v Arsenal</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Hull v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Liverpool v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>West Ham v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>West Brom v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Liverpool v Tottenham</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/man_city.plist b/plists/epl/teams/fixtures/man_city.plist
index 2301a95..220e67c 100644
--- a/plists/epl/teams/fixtures/man_city.plist
+++ b/plists/epl/teams/fixtures/man_city.plist
@@ -1,234 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Man City v Newcastle</string>
- <key>gmt_time</key>
- <string>19:45</string>
- <key>unix_time</key>
- <integer>1233143100</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Stoke v Man City</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1233377100</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Man City v Middlesbrough</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1233981900</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 February 2009</string>
<key>details</key>
<string>Portsmouth v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1234594800</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Cup</string>
<key>date</key>
<string>19 February 2009</string>
<key>details</key>
<string>FC Copenhagen v Man City</string>
<key>gmt_time</key>
<string>19:05</string>
<key>unix_time</key>
<integer>1235041500</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 February 2009</string>
<key>details</key>
<string>Liverpool v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235286000</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Cup</string>
<key>date</key>
<string>26 February 2009</string>
<key>details</key>
<string>Man City v FC Copenhagen</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1235648700</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>01 March 2009</string>
<key>details</key>
<string>West Ham v Man City</string>
<key>gmt_time</key>
<string>12:30</string>
<key>unix_time</key>
<integer>1235881800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Man City v Aston Villa</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236167100</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>15 March 2009</string>
<key>details</key>
<string>Chelsea v Man City</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1237095000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Man City v Sunderland</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Arsenal v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Man City v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Man City v West Brom</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Everton v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Man City v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Man Utd v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Tottenham v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Man City v Bolton</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/man_utd.plist b/plists/epl/teams/fixtures/man_utd.plist
index acc3a82..49b748a 100644
--- a/plists/epl/teams/fixtures/man_utd.plist
+++ b/plists/epl/teams/fixtures/man_utd.plist
@@ -1,246 +1,246 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Man Utd v Everton</string>
<key>gmt_time</key>
<string>17:30</string>
<key>unix_time</key>
<integer>1233394200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>08 February 2009</string>
<key>details</key>
<string>West Ham v Man Utd</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1234080000</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
- <string>14 February 2009</string>
+ <string>15 February 2009</string>
<key>details</key>
<string>Derby/ Nottm Forest v Man Utd</string>
<key>gmt_time</key>
- <string>15:00</string>
+ <string>16:30</string>
<key>unix_time</key>
- <integer>1234594800</integer>
+ <integer>1234686600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
- <string>17 February 2009</string>
+ <string>18 February 2009</string>
<key>details</key>
<string>Man Utd v Fulham</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
- <integer>1234872000</integer>
+ <integer>1234958400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Man Utd v Blackburn</string>
<key>gmt_time</key>
<string>17:30</string>
<key>unix_time</key>
<integer>1235208600</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>24 February 2009</string>
<key>details</key>
<string>Inter Milan v Man Utd</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1235475900</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Man Utd OFF Portsmouth</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Carling Cup</string>
<key>date</key>
<string>01 March 2009</string>
<key>details</key>
<string>Man Utd v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235890800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Newcastle v Man Utd</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236167100</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Champions League</string>
<key>date</key>
<string>11 March 2009</string>
<key>details</key>
<string>Man Utd v Inter Milan</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236771900</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Man Utd v Liverpool</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1237005900</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Fulham v Man Utd</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Man Utd v Aston Villa</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Sunderland v Man Utd</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Wigan v Man Utd</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Man Utd v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Middlesbrough v Man Utd</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Man Utd v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Man Utd v Arsenal</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Hull v Man Utd</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/middlesbrough.plist b/plists/epl/teams/fixtures/middlesbrough.plist
index de61b58..e40416f 100644
--- a/plists/epl/teams/fixtures/middlesbrough.plist
+++ b/plists/epl/teams/fixtures/middlesbrough.plist
@@ -1,210 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Chelsea v Middlesbrough</string>
- <key>gmt_time</key>
- <string>19:45</string>
- <key>unix_time</key>
- <integer>1233143100</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Middlesbrough v Blackburn</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Man City v Middlesbrough</string>
<key>gmt_time</key>
<string>12:45</string>
<key>unix_time</key>
<integer>1233981900</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>14 February 2009</string>
<key>details</key>
<string>West Ham v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1234594800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Middlesbrough v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235199600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Middlesbrough v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Tottenham v Middlesbrough</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236168000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Middlesbrough v Portsmouth</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Stoke v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Bolton v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Middlesbrough v Hull</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Middlesbrough v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Arsenal v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Middlesbrough v Man Utd</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Newcastle v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Middlesbrough v Aston Villa</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>West Ham v Middlesbrough</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/newcastle_united.plist b/plists/epl/teams/fixtures/newcastle_united.plist
index 5611138..3fcb06d 100644
--- a/plists/epl/teams/fixtures/newcastle_united.plist
+++ b/plists/epl/teams/fixtures/newcastle_united.plist
@@ -1,198 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Man City v Newcastle</string>
- <key>gmt_time</key>
- <string>19:45</string>
- <key>unix_time</key>
- <integer>1233143100</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>01 February 2009</string>
<key>details</key>
<string>Newcastle v Sunderland</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1233466200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>West Brom v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 February 2009</string>
<key>details</key>
<string>Newcastle v Everton</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1235289600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>01 March 2009</string>
<key>details</key>
<string>Bolton v Newcastle</string>
<key>gmt_time</key>
<string>13:00</string>
<key>unix_time</key>
<integer>1235883600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Newcastle v Man Utd</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236167100</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Hull v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Newcastle v Arsenal</string>
<key>gmt_time</key>
<string>17:30</string>
<key>unix_time</key>
<integer>1237627800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Newcastle v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Stoke v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Tottenham v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Newcastle v Portsmouth</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Liverpool v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Newcastle v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Newcastle v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Aston Villa v Newcastle</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/tottenham_hotspur.plist b/plists/epl/teams/fixtures/tottenham_hotspur.plist
index 2be00c1..d688aa7 100644
--- a/plists/epl/teams/fixtures/tottenham_hotspur.plist
+++ b/plists/epl/teams/fixtures/tottenham_hotspur.plist
@@ -1,222 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Bolton v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>08 February 2009</string>
<key>details</key>
<string>Tottenham v Arsenal</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1234071000</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Cup</string>
<key>date</key>
<string>19 February 2009</string>
<key>details</key>
<string>Shakhtar Donetsk v Tottenham</string>
<key>gmt_time</key>
- <string>17:00</string>
+ <string>18:45</string>
<key>unix_time</key>
- <integer>1235034000</integer>
+ <integer>1235040300</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>23 February 2009</string>
<key>details</key>
<string>Hull v Tottenham</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1235390400</integer>
</dict>
<dict>
<key>competition</key>
<string>UEFA Cup</string>
<key>date</key>
<string>26 February 2009</string>
<key>details</key>
<string>Tottenham v Shakhtar Donetsk</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1235649600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Sunderland OFF Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Carling Cup</string>
<key>date</key>
<string>01 March 2009</string>
<key>details</key>
<string>Man Utd v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235890800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Tottenham v Middlesbrough</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1236168000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>15 March 2009</string>
<key>details</key>
<string>Aston Villa v Tottenham</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1237104000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Tottenham v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>Blackburn v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Tottenham v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Tottenham v Newcastle</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Man Utd v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Tottenham v West Brom</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>Everton v Tottenham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Tottenham v Man City</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Liverpool v Tottenham</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/west_ham_utd.plist b/plists/epl/teams/fixtures/west_ham_utd.plist
index 7cc4731..d6bb719 100644
--- a/plists/epl/teams/fixtures/west_ham_utd.plist
+++ b/plists/epl/teams/fixtures/west_ham_utd.plist
@@ -1,210 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>West Ham v Hull</string>
- <key>gmt_time</key>
- <string>20:00</string>
- <key>unix_time</key>
- <integer>1233144000</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Arsenal v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>08 February 2009</string>
<key>details</key>
<string>West Ham v Man Utd</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1234080000</integer>
</dict>
<dict>
<key>competition</key>
<string>The FA Cup sponsored by E.ON</string>
<key>date</key>
<string>14 February 2009</string>
<key>details</key>
<string>West Ham v Middlesbrough</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1234594800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Bolton v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235199600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>01 March 2009</string>
<key>details</key>
<string>West Ham v Man City</string>
<key>gmt_time</key>
<string>12:30</string>
<key>unix_time</key>
<integer>1235881800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Wigan v West Ham</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236167100</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 March 2009</string>
<key>details</key>
<string>West Ham v West Brom</string>
<key>gmt_time</key>
<string>20:00</string>
<key>unix_time</key>
<integer>1237204800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 March 2009</string>
<key>details</key>
<string>Blackburn v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237618800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 April 2009</string>
<key>details</key>
<string>West Ham v Sunderland</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238828400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Tottenham v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Aston Villa v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>West Ham v Chelsea</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Stoke v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>West Ham v Liverpool</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Everton v West Ham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>West Ham v Middlesbrough</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
diff --git a/plists/epl/teams/fixtures/wigan_athletic.plist b/plists/epl/teams/fixtures/wigan_athletic.plist
index 7f00c25..d27acfc 100644
--- a/plists/epl/teams/fixtures/wigan_athletic.plist
+++ b/plists/epl/teams/fixtures/wigan_athletic.plist
@@ -1,198 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
- <dict>
- <key>competition</key>
- <string>Barclays Premier League</string>
- <key>date</key>
- <string>28 January 2009</string>
- <key>details</key>
- <string>Wigan v Liverpool</string>
- <key>gmt_time</key>
- <string>19:45</string>
- <key>unix_time</key>
- <integer>1233143100</integer>
- </dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>31 January 2009</string>
<key>details</key>
<string>Aston Villa v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233385200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>07 February 2009</string>
<key>details</key>
<string>Wigan v Fulham</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1233990000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>21 February 2009</string>
<key>details</key>
<string>Middlesbrough v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235199600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>28 February 2009</string>
<key>details</key>
<string>Chelsea v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1235804400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>04 March 2009</string>
<key>details</key>
<string>Wigan v West Ham</string>
<key>gmt_time</key>
<string>19:45</string>
<key>unix_time</key>
<integer>1236167100</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>14 March 2009</string>
<key>details</key>
<string>Sunderland v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1237014000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>22 March 2009</string>
<key>details</key>
<string>Wigan v Hull</string>
<key>gmt_time</key>
<string>13:30</string>
<key>unix_time</key>
<integer>1237699800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>05 April 2009</string>
<key>details</key>
<string>Everton v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1238914800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>11 April 2009</string>
<key>details</key>
<string>Wigan v Arsenal</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1239433200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>18 April 2009</string>
<key>details</key>
<string>Wigan v Man Utd</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240038000</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>25 April 2009</string>
<key>details</key>
<string>Blackburn v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1240642800</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>02 May 2009</string>
<key>details</key>
<string>Wigan v Bolton</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241247600</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>09 May 2009</string>
<key>details</key>
<string>West Brom v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1241852400</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>16 May 2009</string>
<key>details</key>
<string>Stoke v Wigan</string>
<key>gmt_time</key>
<string>15:00</string>
<key>unix_time</key>
<integer>1242457200</integer>
</dict>
<dict>
<key>competition</key>
<string>Barclays Premier League</string>
<key>date</key>
<string>24 May 2009</string>
<key>details</key>
<string>Wigan v Portsmouth</string>
<key>gmt_time</key>
<string>16:00</string>
<key>unix_time</key>
<integer>1243152000</integer>
</dict>
</array>
</plist>
|
arunthampi/epl.github.com
|
df10859db307915933288bfe25e63c4e0c25717c
|
Add plists for iPhone API
|
diff --git a/.gitignore b/.gitignore
index 86042ab..8b13789 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-*.plist
+
diff --git a/plists/epl/all_teams.plist b/plists/epl/all_teams.plist
new file mode 100644
index 0000000..18c4027
--- /dev/null
+++ b/plists/epl/all_teams.plist
@@ -0,0 +1,646 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>away_against</key>
+ <integer>6</integer>
+ <key>away_drawn</key>
+ <integer>4</integer>
+ <key>away_for</key>
+ <integer>15</integer>
+ <key>away_lost</key>
+ <integer>2</integer>
+ <key>away_won</key>
+ <integer>6</integer>
+ <key>goal_difference</key>
+ <integer>29</integer>
+ <key>home_against</key>
+ <integer>4</integer>
+ <key>home_drawn</key>
+ <integer>1</integer>
+ <key>home_for</key>
+ <integer>24</integer>
+ <key>home_lost</key>
+ <integer>0</integer>
+ <key>home_won</key>
+ <integer>9</integer>
+ <key>id</key>
+ <string>man_utd</string>
+ <key>name</key>
+ <string>Man Utd</string>
+ <key>points</key>
+ <integer>50</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>7</integer>
+ <key>away_drawn</key>
+ <integer>3</integer>
+ <key>away_for</key>
+ <integer>19</integer>
+ <key>away_lost</key>
+ <integer>1</integer>
+ <key>away_won</key>
+ <integer>7</integer>
+ <key>goal_difference</key>
+ <integer>22</integer>
+ <key>home_against</key>
+ <integer>7</integer>
+ <key>home_drawn</key>
+ <integer>5</integer>
+ <key>home_for</key>
+ <integer>17</integer>
+ <key>home_lost</key>
+ <integer>0</integer>
+ <key>home_won</key>
+ <integer>6</integer>
+ <key>id</key>
+ <string>liverpool</string>
+ <key>name</key>
+ <string>Liverpool</string>
+ <key>points</key>
+ <integer>47</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>12</integer>
+ <key>away_drawn</key>
+ <integer>0</integer>
+ <key>away_for</key>
+ <integer>20</integer>
+ <key>away_lost</key>
+ <integer>3</integer>
+ <key>away_won</key>
+ <integer>9</integer>
+ <key>goal_difference</key>
+ <integer>14</integer>
+ <key>home_against</key>
+ <integer>12</integer>
+ <key>home_drawn</key>
+ <integer>5</integer>
+ <key>home_for</key>
+ <integer>18</integer>
+ <key>home_lost</key>
+ <integer>1</integer>
+ <key>home_won</key>
+ <integer>5</integer>
+ <key>id</key>
+ <string>aston_villa</string>
+ <key>name</key>
+ <string>Aston Villa</string>
+ <key>points</key>
+ <integer>47</integer>
+ <key>total_played</key>
+ <integer>23</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>6</integer>
+ <key>away_drawn</key>
+ <integer>2</integer>
+ <key>away_for</key>
+ <integer>23</integer>
+ <key>away_lost</key>
+ <integer>1</integer>
+ <key>away_won</key>
+ <integer>8</integer>
+ <key>goal_difference</key>
+ <integer>29</integer>
+ <key>home_against</key>
+ <integer>7</integer>
+ <key>home_drawn</key>
+ <integer>4</integer>
+ <key>home_for</key>
+ <integer>19</integer>
+ <key>home_lost</key>
+ <integer>2</integer>
+ <key>home_won</key>
+ <integer>5</integer>
+ <key>id</key>
+ <string>chelsea</string>
+ <key>name</key>
+ <string>Chelsea</string>
+ <key>points</key>
+ <integer>45</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>13</integer>
+ <key>away_drawn</key>
+ <integer>3</integer>
+ <key>away_for</key>
+ <integer>19</integer>
+ <key>away_lost</key>
+ <integer>3</integer>
+ <key>away_won</key>
+ <integer>5</integer>
+ <key>goal_difference</key>
+ <integer>13</integer>
+ <key>home_against</key>
+ <integer>11</integer>
+ <key>home_drawn</key>
+ <integer>2</integer>
+ <key>home_for</key>
+ <integer>18</integer>
+ <key>home_lost</key>
+ <integer>2</integer>
+ <key>home_won</key>
+ <integer>7</integer>
+ <key>id</key>
+ <string>arsenal</string>
+ <key>name</key>
+ <string>Arsenal</string>
+ <key>points</key>
+ <integer>41</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>11</integer>
+ <key>away_drawn</key>
+ <integer>2</integer>
+ <key>away_for</key>
+ <integer>16</integer>
+ <key>away_lost</key>
+ <integer>2</integer>
+ <key>away_won</key>
+ <integer>7</integer>
+ <key>goal_difference</key>
+ <integer>4</integer>
+ <key>home_against</key>
+ <integer>15</integer>
+ <key>home_drawn</key>
+ <integer>4</integer>
+ <key>home_for</key>
+ <integer>14</integer>
+ <key>home_lost</key>
+ <integer>4</integer>
+ <key>home_won</key>
+ <integer>3</integer>
+ <key>id</key>
+ <string>everton</string>
+ <key>name</key>
+ <string>Everton</string>
+ <key>points</key>
+ <integer>36</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>13</integer>
+ <key>away_drawn</key>
+ <integer>2</integer>
+ <key>away_for</key>
+ <integer>13</integer>
+ <key>away_lost</key>
+ <integer>6</integer>
+ <key>away_won</key>
+ <integer>3</integer>
+ <key>goal_difference</key>
+ <integer>2</integer>
+ <key>home_against</key>
+ <integer>10</integer>
+ <key>home_drawn</key>
+ <integer>2</integer>
+ <key>home_for</key>
+ <integer>12</integer>
+ <key>home_lost</key>
+ <integer>3</integer>
+ <key>home_won</key>
+ <integer>6</integer>
+ <key>id</key>
+ <string>wigan_athletic</string>
+ <key>name</key>
+ <string>Wigan</string>
+ <key>points</key>
+ <integer>31</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>15</integer>
+ <key>away_drawn</key>
+ <integer>4</integer>
+ <key>away_for</key>
+ <integer>13</integer>
+ <key>away_lost</key>
+ <integer>4</integer>
+ <key>away_won</key>
+ <integer>3</integer>
+ <key>goal_difference</key>
+ <integer>-2</integer>
+ <key>home_against</key>
+ <integer>16</integer>
+ <key>home_drawn</key>
+ <integer>1</integer>
+ <key>home_for</key>
+ <integer>16</integer>
+ <key>home_lost</key>
+ <integer>5</integer>
+ <key>home_won</key>
+ <integer>5</integer>
+ <key>id</key>
+ <string>west_ham_utd</string>
+ <key>name</key>
+ <string>West Ham</string>
+ <key>points</key>
+ <integer>29</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>19</integer>
+ <key>away_drawn</key>
+ <integer>4</integer>
+ <key>away_for</key>
+ <integer>18</integer>
+ <key>away_lost</key>
+ <integer>3</integer>
+ <key>away_won</key>
+ <integer>4</integer>
+ <key>goal_difference</key>
+ <integer>-13</integer>
+ <key>home_against</key>
+ <integer>23</integer>
+ <key>home_drawn</key>
+ <integer>2</integer>
+ <key>home_for</key>
+ <integer>11</integer>
+ <key>home_lost</key>
+ <integer>6</integer>
+ <key>home_won</key>
+ <integer>3</integer>
+ <key>id</key>
+ <string>hull_city</string>
+ <key>name</key>
+ <string>Hull</string>
+ <key>points</key>
+ <integer>27</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>10</integer>
+ <key>away_drawn</key>
+ <integer>5</integer>
+ <key>away_for</key>
+ <integer>3</integer>
+ <key>away_lost</key>
+ <integer>6</integer>
+ <key>away_won</key>
+ <integer>0</integer>
+ <key>goal_difference</key>
+ <integer>1</integer>
+ <key>home_against</key>
+ <integer>8</integer>
+ <key>home_drawn</key>
+ <integer>3</integer>
+ <key>home_for</key>
+ <integer>16</integer>
+ <key>home_lost</key>
+ <integer>1</integer>
+ <key>home_won</key>
+ <integer>6</integer>
+ <key>id</key>
+ <string>fulham</string>
+ <key>name</key>
+ <string>Fulham</string>
+ <key>points</key>
+ <integer>26</integer>
+ <key>total_played</key>
+ <integer>21</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>17</integer>
+ <key>away_drawn</key>
+ <integer>3</integer>
+ <key>away_for</key>
+ <integer>11</integer>
+ <key>away_lost</key>
+ <integer>5</integer>
+ <key>away_won</key>
+ <integer>3</integer>
+ <key>goal_difference</key>
+ <integer>-8</integer>
+ <key>home_against</key>
+ <integer>15</integer>
+ <key>home_drawn</key>
+ <integer>2</integer>
+ <key>home_for</key>
+ <integer>13</integer>
+ <key>home_lost</key>
+ <integer>6</integer>
+ <key>home_won</key>
+ <integer>4</integer>
+ <key>id</key>
+ <string>sunderland</string>
+ <key>name</key>
+ <string>Sunderland</string>
+ <key>points</key>
+ <integer>26</integer>
+ <key>total_played</key>
+ <integer>23</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>19</integer>
+ <key>away_drawn</key>
+ <integer>4</integer>
+ <key>away_for</key>
+ <integer>14</integer>
+ <key>away_lost</key>
+ <integer>5</integer>
+ <key>away_won</key>
+ <integer>1</integer>
+ <key>goal_difference</key>
+ <integer>9</integer>
+ <key>home_against</key>
+ <integer>11</integer>
+ <key>home_drawn</key>
+ <integer>0</integer>
+ <key>home_for</key>
+ <integer>25</integer>
+ <key>home_lost</key>
+ <integer>5</integer>
+ <key>home_won</key>
+ <integer>6</integer>
+ <key>id</key>
+ <string>man_city</string>
+ <key>name</key>
+ <string>Man City</string>
+ <key>points</key>
+ <integer>25</integer>
+ <key>total_played</key>
+ <integer>21</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>19</integer>
+ <key>away_drawn</key>
+ <integer>2</integer>
+ <key>away_for</key>
+ <integer>13</integer>
+ <key>away_lost</key>
+ <integer>7</integer>
+ <key>away_won</key>
+ <integer>2</integer>
+ <key>goal_difference</key>
+ <integer>-4</integer>
+ <key>home_against</key>
+ <integer>9</integer>
+ <key>home_drawn</key>
+ <integer>4</integer>
+ <key>home_for</key>
+ <integer>11</integer>
+ <key>home_lost</key>
+ <integer>4</integer>
+ <key>home_won</key>
+ <integer>4</integer>
+ <key>id</key>
+ <string>tottenham_hotspur</string>
+ <key>name</key>
+ <string>Tottenham</string>
+ <key>points</key>
+ <integer>24</integer>
+ <key>total_played</key>
+ <integer>23</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>17</integer>
+ <key>away_drawn</key>
+ <integer>4</integer>
+ <key>away_for</key>
+ <integer>8</integer>
+ <key>away_lost</key>
+ <integer>5</integer>
+ <key>away_won</key>
+ <integer>2</integer>
+ <key>goal_difference</key>
+ <integer>-13</integer>
+ <key>home_against</key>
+ <integer>18</integer>
+ <key>home_drawn</key>
+ <integer>2</integer>
+ <key>home_for</key>
+ <integer>14</integer>
+ <key>home_lost</key>
+ <integer>5</integer>
+ <key>home_won</key>
+ <integer>4</integer>
+ <key>id</key>
+ <string>portsmouth</string>
+ <key>name</key>
+ <string>Portsmouth</string>
+ <key>points</key>
+ <integer>24</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>18</integer>
+ <key>away_drawn</key>
+ <integer>0</integer>
+ <key>away_for</key>
+ <integer>14</integer>
+ <key>away_lost</key>
+ <integer>7</integer>
+ <key>away_won</key>
+ <integer>4</integer>
+ <key>goal_difference</key>
+ <integer>-8</integer>
+ <key>home_against</key>
+ <integer>12</integer>
+ <key>home_drawn</key>
+ <integer>2</integer>
+ <key>home_for</key>
+ <integer>8</integer>
+ <key>home_lost</key>
+ <integer>6</integer>
+ <key>home_won</key>
+ <integer>3</integer>
+ <key>id</key>
+ <string>bolton_wanderers</string>
+ <key>name</key>
+ <string>Bolton</string>
+ <key>points</key>
+ <integer>23</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>18</integer>
+ <key>away_drawn</key>
+ <integer>4</integer>
+ <key>away_for</key>
+ <integer>10</integer>
+ <key>away_lost</key>
+ <integer>6</integer>
+ <key>away_won</key>
+ <integer>1</integer>
+ <key>goal_difference</key>
+ <integer>-9</integer>
+ <key>home_against</key>
+ <integer>19</integer>
+ <key>home_drawn</key>
+ <integer>4</integer>
+ <key>home_for</key>
+ <integer>18</integer>
+ <key>home_lost</key>
+ <integer>3</integer>
+ <key>home_won</key>
+ <integer>4</integer>
+ <key>id</key>
+ <string>newcastle_united</string>
+ <key>name</key>
+ <string>Newcastle</string>
+ <key>points</key>
+ <integer>23</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>19</integer>
+ <key>away_drawn</key>
+ <integer>3</integer>
+ <key>away_for</key>
+ <integer>12</integer>
+ <key>away_lost</key>
+ <integer>5</integer>
+ <key>away_won</key>
+ <integer>2</integer>
+ <key>goal_difference</key>
+ <integer>-11</integer>
+ <key>home_against</key>
+ <integer>17</integer>
+ <key>home_drawn</key>
+ <integer>3</integer>
+ <key>home_for</key>
+ <integer>13</integer>
+ <key>home_lost</key>
+ <integer>5</integer>
+ <key>home_won</key>
+ <integer>3</integer>
+ <key>id</key>
+ <string>blackburn_rovers</string>
+ <key>name</key>
+ <string>Blackburn</string>
+ <key>points</key>
+ <integer>21</integer>
+ <key>total_played</key>
+ <integer>21</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>18</integer>
+ <key>away_drawn</key>
+ <integer>2</integer>
+ <key>away_for</key>
+ <integer>8</integer>
+ <key>away_lost</key>
+ <integer>7</integer>
+ <key>away_won</key>
+ <integer>2</integer>
+ <key>goal_difference</key>
+ <integer>-15</integer>
+ <key>home_against</key>
+ <integer>15</integer>
+ <key>home_drawn</key>
+ <integer>4</integer>
+ <key>home_for</key>
+ <integer>10</integer>
+ <key>home_lost</key>
+ <integer>4</integer>
+ <key>home_won</key>
+ <integer>3</integer>
+ <key>id</key>
+ <string>middlesbrough</string>
+ <key>name</key>
+ <string>Middlesbrough</string>
+ <key>points</key>
+ <integer>21</integer>
+ <key>total_played</key>
+ <integer>22</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>27</integer>
+ <key>away_drawn</key>
+ <integer>3</integer>
+ <key>away_for</key>
+ <integer>8</integer>
+ <key>away_lost</key>
+ <integer>9</integer>
+ <key>away_won</key>
+ <integer>0</integer>
+ <key>goal_difference</key>
+ <integer>-18</integer>
+ <key>home_against</key>
+ <integer>11</integer>
+ <key>home_drawn</key>
+ <integer>3</integer>
+ <key>home_for</key>
+ <integer>12</integer>
+ <key>home_lost</key>
+ <integer>3</integer>
+ <key>home_won</key>
+ <integer>5</integer>
+ <key>id</key>
+ <string>stoke_city</string>
+ <key>name</key>
+ <string>Stoke</string>
+ <key>points</key>
+ <integer>21</integer>
+ <key>total_played</key>
+ <integer>23</integer>
+ </dict>
+ <dict>
+ <key>away_against</key>
+ <integer>21</integer>
+ <key>away_drawn</key>
+ <integer>1</integer>
+ <key>away_for</key>
+ <integer>4</integer>
+ <key>away_lost</key>
+ <integer>9</integer>
+ <key>away_won</key>
+ <integer>1</integer>
+ <key>goal_difference</key>
+ <integer>-22</integer>
+ <key>home_against</key>
+ <integer>21</integer>
+ <key>home_drawn</key>
+ <integer>2</integer>
+ <key>home_for</key>
+ <integer>16</integer>
+ <key>home_lost</key>
+ <integer>5</integer>
+ <key>home_won</key>
+ <integer>5</integer>
+ <key>id</key>
+ <string>west_bromwich_albion</string>
+ <key>name</key>
+ <string>West Brom</string>
+ <key>points</key>
+ <integer>21</integer>
+ <key>total_played</key>
+ <integer>23</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/arsenal.plist b/plists/epl/teams/fixtures/arsenal.plist
new file mode 100644
index 0000000..d78e468
--- /dev/null
+++ b/plists/epl/teams/fixtures/arsenal.plist
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Everton v Arsenal</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233144000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Arsenal v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>03 February 2009</string>
+ <key>details</key>
+ <string>Arsenal v Cardiff</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233661500</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>08 February 2009</string>
+ <key>details</key>
+ <string>Tottenham v Arsenal</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1234071000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Arsenal v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>24 February 2009</string>
+ <key>details</key>
+ <string>Arsenal v Roma</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1235475900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Arsenal v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>03 March 2009</string>
+ <key>details</key>
+ <string>West Brom v Arsenal</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236080700</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>11 March 2009</string>
+ <key>details</key>
+ <string>Roma v Arsenal</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236771900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Arsenal v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Newcastle v Arsenal</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1237627800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Arsenal v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Wigan v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Liverpool v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Arsenal v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Arsenal v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Man Utd v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Arsenal v Stoke</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/aston_villa.plist b/plists/epl/teams/fixtures/aston_villa.plist
new file mode 100644
index 0000000..554702e
--- /dev/null
+++ b/plists/epl/teams/fixtures/aston_villa.plist
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>04 February 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Doncaster</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233747900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Blackburn v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Cup</string>
+ <key>date</key>
+ <string>18 February 2009</string>
+ <key>details</key>
+ <string>Aston Villa v CSKA Moscow</string>
+ <key>gmt_time</key>
+ <string>19:00</string>
+ <key>unix_time</key>
+ <integer>1234954800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Chelsea</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1235191500</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Cup</string>
+ <key>date</key>
+ <string>26 February 2009</string>
+ <key>details</key>
+ <string>CSKA Moscow v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>17:00</string>
+ <key>unix_time</key>
+ <integer>1235638800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235890800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Man City v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>15 March 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Tottenham</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1237104000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 March 2009</string>
+ <key>details</key>
+ <string>Liverpool v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1237708800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Man Utd v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Everton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Aston Villa v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Bolton v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Fulham v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Newcastle</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/blackburn_rovers.plist b/plists/epl/teams/fixtures/blackburn_rovers.plist
new file mode 100644
index 0000000..5ce3f9d
--- /dev/null
+++ b/plists/epl/teams/fixtures/blackburn_rovers.plist
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Blackburn v Bolton</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233144000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>04 February 2009</string>
+ <key>details</key>
+ <string>Blackburn v Sunderland</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233748800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Blackburn v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Man Utd v Blackburn</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1235208600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Hull v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Blackburn v Everton</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236168000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 March 2009</string>
+ <key>details</key>
+ <string>Fulham v Blackburn</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236772800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Arsenal v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Blackburn v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Blackburn v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Liverpool v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Stoke v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Blackburn v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Man City v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Blackburn v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Chelsea v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Blackburn v West Brom</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/bolton_wanderers.plist b/plists/epl/teams/fixtures/bolton_wanderers.plist
new file mode 100644
index 0000000..5950ff0
--- /dev/null
+++ b/plists/epl/teams/fixtures/bolton_wanderers.plist
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Blackburn v Bolton</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233144000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Bolton v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Everton v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Bolton v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>Bolton v Newcastle</string>
+ <key>gmt_time</key>
+ <string>13:00</string>
+ <key>unix_time</key>
+ <integer>1235883600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Stoke v Bolton</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Bolton v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>West Brom v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Bolton v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Chelsea v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Bolton v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Wigan v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Bolton v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Bolton v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Man City v Bolton</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/chelsea.plist b/plists/epl/teams/fixtures/chelsea.plist
new file mode 100644
index 0000000..5e62e95
--- /dev/null
+++ b/plists/epl/teams/fixtures/chelsea.plist
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Chelsea v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233143100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 February 2009</string>
+ <key>details</key>
+ <string>Liverpool v Chelsea</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1233475200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Chelsea v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>Watford v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Chelsea</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1235191500</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>25 February 2009</string>
+ <key>details</key>
+ <string>Chelsea v Juventus</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1235562300</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Chelsea v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>03 March 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Chelsea</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236080700</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>10 March 2009</string>
+ <key>details</key>
+ <string>Juventus v Chelsea</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236685500</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>15 March 2009</string>
+ <key>details</key>
+ <string>Chelsea v Man City</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1237095000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Tottenham v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Newcastle v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Chelsea v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Chelsea v Everton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>West Ham v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Chelsea v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Arsenal v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Chelsea v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Sunderland v Chelsea</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/everton.plist b/plists/epl/teams/fixtures/everton.plist
new file mode 100644
index 0000000..832bfb7
--- /dev/null
+++ b/plists/epl/teams/fixtures/everton.plist
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Everton v Arsenal</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233144000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Man Utd v Everton</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1233394200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>04 February 2009</string>
+ <key>details</key>
+ <string>Everton v Liverpool</string>
+ <key>gmt_time</key>
+ <string>20:10</string>
+ <key>unix_time</key>
+ <integer>1233749400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Everton v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 February 2009</string>
+ <key>details</key>
+ <string>Newcastle v Everton</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1235289600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Everton v West Brom</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1235796300</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Blackburn v Everton</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236168000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Everton v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Everton</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1237610700</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>05 April 2009</string>
+ <key>details</key>
+ <string>Everton v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238914800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Everton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Chelsea v Everton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Everton v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Sunderland v Everton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Everton v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Everton v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Fulham v Everton</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/fulham.plist b/plists/epl/teams/fixtures/fulham.plist
new file mode 100644
index 0000000..7115618
--- /dev/null
+++ b/plists/epl/teams/fixtures/fulham.plist
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Fulham v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Wigan v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>Swansea v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>17 February 2009</string>
+ <key>details</key>
+ <string>Man Utd v Fulham</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1234872000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 February 2009</string>
+ <key>details</key>
+ <string>Fulham v West Brom</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1235280600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Arsenal v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Fulham v Hull</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236168000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 March 2009</string>
+ <key>details</key>
+ <string>Fulham v Blackburn</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236772800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Bolton v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Fulham v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Fulham v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Man City v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Fulham v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Chelsea v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Fulham v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Newcastle v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Fulham v Everton</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/hull_city.plist b/plists/epl/teams/fixtures/hull_city.plist
new file mode 100644
index 0000000..111f3f0
--- /dev/null
+++ b/plists/epl/teams/fixtures/hull_city.plist
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>West Ham v Hull</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233144000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Hull v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Chelsea v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>Sheff Utd v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>23 February 2009</string>
+ <key>details</key>
+ <string>Hull v Tottenham</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1235390400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Hull v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Fulham v Hull</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236168000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Hull v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 March 2009</string>
+ <key>details</key>
+ <string>Wigan v Hull</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1237699800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Hull v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Sunderland v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Hull v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Hull v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Bolton v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Hull v Man Utd</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/liverpool.plist b/plists/epl/teams/fixtures/liverpool.plist
new file mode 100644
index 0000000..b0edebe
--- /dev/null
+++ b/plists/epl/teams/fixtures/liverpool.plist
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Wigan v Liverpool</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233143100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 February 2009</string>
+ <key>details</key>
+ <string>Liverpool v Chelsea</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1233475200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>04 February 2009</string>
+ <key>details</key>
+ <string>Everton v Liverpool</string>
+ <key>gmt_time</key>
+ <string>20:10</string>
+ <key>unix_time</key>
+ <integer>1233749400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Liverpool</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1233999000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 February 2009</string>
+ <key>details</key>
+ <string>Liverpool v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235286000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>25 February 2009</string>
+ <key>details</key>
+ <string>Real Madrid v Liverpool</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1235562300</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>03 March 2009</string>
+ <key>details</key>
+ <string>Liverpool v Sunderland</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236081600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>10 March 2009</string>
+ <key>details</key>
+ <string>Liverpool v Real Madrid</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236685500</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Man Utd v Liverpool</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1237005900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 March 2009</string>
+ <key>details</key>
+ <string>Liverpool v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1237708800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Fulham v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Liverpool v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Liverpool v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Hull v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Liverpool v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>West Ham v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>West Brom v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Liverpool v Tottenham</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/man_city.plist b/plists/epl/teams/fixtures/man_city.plist
new file mode 100644
index 0000000..2301a95
--- /dev/null
+++ b/plists/epl/teams/fixtures/man_city.plist
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Man City v Newcastle</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233143100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Stoke v Man City</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1233377100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Man City v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1233981900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Cup</string>
+ <key>date</key>
+ <string>19 February 2009</string>
+ <key>details</key>
+ <string>FC Copenhagen v Man City</string>
+ <key>gmt_time</key>
+ <string>19:05</string>
+ <key>unix_time</key>
+ <integer>1235041500</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 February 2009</string>
+ <key>details</key>
+ <string>Liverpool v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235286000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Cup</string>
+ <key>date</key>
+ <string>26 February 2009</string>
+ <key>details</key>
+ <string>Man City v FC Copenhagen</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1235648700</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>West Ham v Man City</string>
+ <key>gmt_time</key>
+ <string>12:30</string>
+ <key>unix_time</key>
+ <integer>1235881800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Man City v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>15 March 2009</string>
+ <key>details</key>
+ <string>Chelsea v Man City</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1237095000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Man City v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Arsenal v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Man City v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Man City v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Everton v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Man City v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Man Utd v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Tottenham v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Man City v Bolton</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/man_utd.plist b/plists/epl/teams/fixtures/man_utd.plist
new file mode 100644
index 0000000..acc3a82
--- /dev/null
+++ b/plists/epl/teams/fixtures/man_utd.plist
@@ -0,0 +1,246 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Man Utd v Everton</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1233394200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>08 February 2009</string>
+ <key>details</key>
+ <string>West Ham v Man Utd</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1234080000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>Derby/ Nottm Forest v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>17 February 2009</string>
+ <key>details</key>
+ <string>Man Utd v Fulham</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1234872000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Man Utd v Blackburn</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1235208600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>24 February 2009</string>
+ <key>details</key>
+ <string>Inter Milan v Man Utd</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1235475900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Man Utd OFF Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Carling Cup</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>Man Utd v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235890800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Newcastle v Man Utd</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Champions League</string>
+ <key>date</key>
+ <string>11 March 2009</string>
+ <key>details</key>
+ <string>Man Utd v Inter Milan</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236771900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Man Utd v Liverpool</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1237005900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Fulham v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Man Utd v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Sunderland v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Wigan v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Man Utd v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Man Utd v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Man Utd v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Hull v Man Utd</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/middlesbrough.plist b/plists/epl/teams/fixtures/middlesbrough.plist
new file mode 100644
index 0000000..de61b58
--- /dev/null
+++ b/plists/epl/teams/fixtures/middlesbrough.plist
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Chelsea v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233143100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Man City v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1233981900</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>West Ham v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Tottenham v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236168000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Stoke v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Bolton v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Arsenal v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Newcastle v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Aston Villa</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>West Ham v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/newcastle_united.plist b/plists/epl/teams/fixtures/newcastle_united.plist
new file mode 100644
index 0000000..5611138
--- /dev/null
+++ b/plists/epl/teams/fixtures/newcastle_united.plist
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Man City v Newcastle</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233143100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 February 2009</string>
+ <key>details</key>
+ <string>Newcastle v Sunderland</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1233466200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>West Brom v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 February 2009</string>
+ <key>details</key>
+ <string>Newcastle v Everton</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1235289600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>Bolton v Newcastle</string>
+ <key>gmt_time</key>
+ <string>13:00</string>
+ <key>unix_time</key>
+ <integer>1235883600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Newcastle v Man Utd</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Hull v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Newcastle v Arsenal</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1237627800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Newcastle v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Stoke v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Tottenham v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Newcastle v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Liverpool v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Newcastle v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Newcastle v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Newcastle</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/portsmouth.plist b/plists/epl/teams/fixtures/portsmouth.plist
new file mode 100644
index 0000000..cfa4100
--- /dev/null
+++ b/plists/epl/teams/fixtures/portsmouth.plist
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Fulham v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Liverpool</string>
+ <key>gmt_time</key>
+ <string>17:30</string>
+ <key>unix_time</key>
+ <integer>1233999000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Stoke v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Man Utd OFF Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>03 March 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Chelsea</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236080700</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Everton</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1237610700</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Hull v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Portsmouth v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Newcastle v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Blackburn v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Wigan v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/stoke_city.plist b/plists/epl/teams/fixtures/stoke_city.plist
new file mode 100644
index 0000000..0850e96
--- /dev/null
+++ b/plists/epl/teams/fixtures/stoke_city.plist
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Stoke v Man City</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1233377100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Sunderland v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Stoke v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235890800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Stoke v Bolton</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Everton v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Stoke v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>West Brom v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Stoke v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Stoke v Blackburn</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Fulham v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Stoke v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Hull v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Stoke v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Arsenal v Stoke</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/sunderland.plist b/plists/epl/teams/fixtures/sunderland.plist
new file mode 100644
index 0000000..4568b65
--- /dev/null
+++ b/plists/epl/teams/fixtures/sunderland.plist
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 February 2009</string>
+ <key>details</key>
+ <string>Newcastle v Sunderland</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1233466200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>04 February 2009</string>
+ <key>details</key>
+ <string>Blackburn v Sunderland</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233748800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Sunderland v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Arsenal v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Sunderland OFF Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>03 March 2009</string>
+ <key>details</key>
+ <string>Liverpool v Sunderland</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236081600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Sunderland v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Man City v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>West Ham v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Sunderland v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Sunderland v Hull</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>West Brom v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Sunderland v Everton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Bolton v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Portsmouth v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Sunderland v Chelsea</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/tottenham_hotspur.plist b/plists/epl/teams/fixtures/tottenham_hotspur.plist
new file mode 100644
index 0000000..2be00c1
--- /dev/null
+++ b/plists/epl/teams/fixtures/tottenham_hotspur.plist
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Bolton v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>08 February 2009</string>
+ <key>details</key>
+ <string>Tottenham v Arsenal</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1234071000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Cup</string>
+ <key>date</key>
+ <string>19 February 2009</string>
+ <key>details</key>
+ <string>Shakhtar Donetsk v Tottenham</string>
+ <key>gmt_time</key>
+ <string>17:00</string>
+ <key>unix_time</key>
+ <integer>1235034000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>23 February 2009</string>
+ <key>details</key>
+ <string>Hull v Tottenham</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1235390400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>UEFA Cup</string>
+ <key>date</key>
+ <string>26 February 2009</string>
+ <key>details</key>
+ <string>Tottenham v Shakhtar Donetsk</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1235649600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Sunderland OFF Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Carling Cup</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>Man Utd v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235890800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Tottenham v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1236168000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>15 March 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Tottenham</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1237104000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Tottenham v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>Blackburn v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Tottenham v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Tottenham v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Man Utd v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Tottenham v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>Everton v Tottenham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Tottenham v Man City</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Liverpool v Tottenham</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/west_bromwich_albion.plist b/plists/epl/teams/fixtures/west_bromwich_albion.plist
new file mode 100644
index 0000000..664e57a
--- /dev/null
+++ b/plists/epl/teams/fixtures/west_bromwich_albion.plist
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Hull v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>03 February 2009</string>
+ <key>details</key>
+ <string>Burnley v West Brom</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233661500</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>West Brom v Newcastle</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 February 2009</string>
+ <key>details</key>
+ <string>Fulham v West Brom</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1235280600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Everton v West Brom</string>
+ <key>gmt_time</key>
+ <string>12:45</string>
+ <key>unix_time</key>
+ <integer>1235796300</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>03 March 2009</string>
+ <key>details</key>
+ <string>West Brom v Arsenal</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236080700</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 March 2009</string>
+ <key>details</key>
+ <string>West Ham v West Brom</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1237204800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>West Brom v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>West Brom v Stoke</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Portsmouth v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Man City v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>West Brom v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Tottenham v West Brom</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>West Brom v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>West Brom v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Blackburn v West Brom</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/west_ham_utd.plist b/plists/epl/teams/fixtures/west_ham_utd.plist
new file mode 100644
index 0000000..7cc4731
--- /dev/null
+++ b/plists/epl/teams/fixtures/west_ham_utd.plist
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>West Ham v Hull</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1233144000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Arsenal v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>08 February 2009</string>
+ <key>details</key>
+ <string>West Ham v Man Utd</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1234080000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>The FA Cup sponsored by E.ON</string>
+ <key>date</key>
+ <string>14 February 2009</string>
+ <key>details</key>
+ <string>West Ham v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1234594800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Bolton v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>01 March 2009</string>
+ <key>details</key>
+ <string>West Ham v Man City</string>
+ <key>gmt_time</key>
+ <string>12:30</string>
+ <key>unix_time</key>
+ <integer>1235881800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Wigan v West Ham</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 March 2009</string>
+ <key>details</key>
+ <string>West Ham v West Brom</string>
+ <key>gmt_time</key>
+ <string>20:00</string>
+ <key>unix_time</key>
+ <integer>1237204800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 March 2009</string>
+ <key>details</key>
+ <string>Blackburn v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237618800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 April 2009</string>
+ <key>details</key>
+ <string>West Ham v Sunderland</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238828400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Tottenham v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Aston Villa v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>West Ham v Chelsea</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Stoke v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>West Ham v Liverpool</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Everton v West Ham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>West Ham v Middlesbrough</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
diff --git a/plists/epl/teams/fixtures/wigan_athletic.plist b/plists/epl/teams/fixtures/wigan_athletic.plist
new file mode 100644
index 0000000..7f00c25
--- /dev/null
+++ b/plists/epl/teams/fixtures/wigan_athletic.plist
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 January 2009</string>
+ <key>details</key>
+ <string>Wigan v Liverpool</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1233143100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>31 January 2009</string>
+ <key>details</key>
+ <string>Aston Villa v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233385200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>07 February 2009</string>
+ <key>details</key>
+ <string>Wigan v Fulham</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1233990000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>21 February 2009</string>
+ <key>details</key>
+ <string>Middlesbrough v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235199600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>28 February 2009</string>
+ <key>details</key>
+ <string>Chelsea v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1235804400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>04 March 2009</string>
+ <key>details</key>
+ <string>Wigan v West Ham</string>
+ <key>gmt_time</key>
+ <string>19:45</string>
+ <key>unix_time</key>
+ <integer>1236167100</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>14 March 2009</string>
+ <key>details</key>
+ <string>Sunderland v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1237014000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>22 March 2009</string>
+ <key>details</key>
+ <string>Wigan v Hull</string>
+ <key>gmt_time</key>
+ <string>13:30</string>
+ <key>unix_time</key>
+ <integer>1237699800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>05 April 2009</string>
+ <key>details</key>
+ <string>Everton v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1238914800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>11 April 2009</string>
+ <key>details</key>
+ <string>Wigan v Arsenal</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1239433200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>18 April 2009</string>
+ <key>details</key>
+ <string>Wigan v Man Utd</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240038000</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>25 April 2009</string>
+ <key>details</key>
+ <string>Blackburn v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1240642800</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>02 May 2009</string>
+ <key>details</key>
+ <string>Wigan v Bolton</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241247600</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>09 May 2009</string>
+ <key>details</key>
+ <string>West Brom v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1241852400</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>16 May 2009</string>
+ <key>details</key>
+ <string>Stoke v Wigan</string>
+ <key>gmt_time</key>
+ <string>15:00</string>
+ <key>unix_time</key>
+ <integer>1242457200</integer>
+ </dict>
+ <dict>
+ <key>competition</key>
+ <string>Barclays Premier League</string>
+ <key>date</key>
+ <string>24 May 2009</string>
+ <key>details</key>
+ <string>Wigan v Portsmouth</string>
+ <key>gmt_time</key>
+ <string>16:00</string>
+ <key>unix_time</key>
+ <integer>1243152000</integer>
+ </dict>
+</array>
+</plist>
|
arunthampi/epl.github.com
|
0e1142e323c0fa66a704efd8ee74eab21d3f2efa
|
Fixtures details for 28-Jan-2009 0830
|
diff --git a/js/epl/all_teams.js b/js/epl/all_teams.js
index 326706a..d498b5b 100644
--- a/js/epl/all_teams.js
+++ b/js/epl/all_teams.js
@@ -1 +1 @@
-[{"name":"Man Utd","away_lost":2,"home_against":4,"goal_difference":24,"home_for":24,"away_drawn":4,"away_for":10,"home_won":9,"points":47,"total_played":21,"id":"man_utd","home_lost":0,"away_against":6,"away_won":5,"home_drawn":1},{"name":"Liverpool","away_lost":1,"home_against":7,"goal_difference":22,"home_for":17,"away_drawn":3,"away_for":19,"home_won":6,"points":47,"total_played":22,"id":"liverpool","home_lost":0,"away_against":7,"away_won":7,"home_drawn":5},{"name":"Chelsea","away_lost":1,"home_against":7,"goal_difference":29,"home_for":19,"away_drawn":2,"away_for":23,"home_won":5,"points":45,"total_played":22,"id":"chelsea","home_lost":2,"away_against":6,"away_won":8,"home_drawn":4},{"name":"Aston Villa","away_lost":3,"home_against":12,"goal_difference":13,"home_for":18,"away_drawn":0,"away_for":19,"home_won":5,"points":44,"total_played":22,"id":"aston_villa","home_lost":1,"away_against":12,"away_won":8,"home_drawn":5},{"name":"Arsenal","away_lost":3,"home_against":11,"goal_difference":13,"home_for":18,"away_drawn":3,"away_for":19,"home_won":7,"points":41,"total_played":22,"id":"arsenal","home_lost":2,"away_against":13,"away_won":5,"home_drawn":2},{"name":"Everton","away_lost":2,"home_against":15,"goal_difference":4,"home_for":14,"away_drawn":2,"away_for":16,"home_won":3,"points":36,"total_played":22,"id":"everton","home_lost":4,"away_against":11,"away_won":7,"home_drawn":4},{"name":"Wigan","away_lost":6,"home_against":10,"goal_difference":2,"home_for":12,"away_drawn":2,"away_for":13,"home_won":6,"points":31,"total_played":22,"id":"wigan_athletic","home_lost":3,"away_against":13,"away_won":3,"home_drawn":2},{"name":"West Ham","away_lost":4,"home_against":16,"goal_difference":-2,"home_for":16,"away_drawn":4,"away_for":13,"home_won":5,"points":29,"total_played":22,"id":"west_ham_utd","home_lost":5,"away_against":15,"away_won":3,"home_drawn":1},{"name":"Hull","away_lost":3,"home_against":23,"goal_difference":-13,"home_for":11,"away_drawn":4,"away_for":18,"home_won":3,"points":27,"total_played":22,"id":"hull_city","home_lost":6,"away_against":19,"away_won":4,"home_drawn":2},{"name":"Fulham","away_lost":5,"home_against":8,"goal_difference":2,"home_for":16,"away_drawn":5,"away_for":3,"home_won":6,"points":26,"total_played":20,"id":"fulham","home_lost":1,"away_against":9,"away_won":0,"home_drawn":3},{"name":"Man City","away_lost":5,"home_against":11,"goal_difference":9,"home_for":25,"away_drawn":4,"away_for":14,"home_won":6,"points":25,"total_played":21,"id":"man_city","home_lost":5,"away_against":19,"away_won":1,"home_drawn":0},{"name":"Portsmouth","away_lost":5,"home_against":17,"goal_difference":-12,"home_for":14,"away_drawn":4,"away_for":8,"home_won":4,"points":24,"total_played":21,"id":"portsmouth","home_lost":4,"away_against":17,"away_won":2,"home_drawn":2},{"name":"Bolton","away_lost":7,"home_against":12,"goal_difference":-8,"home_for":8,"away_drawn":0,"away_for":14,"home_won":3,"points":23,"total_played":22,"id":"bolton_wanderers","home_lost":6,"away_against":18,"away_won":4,"home_drawn":2},{"name":"Newcastle","away_lost":6,"home_against":19,"goal_difference":-9,"home_for":18,"away_drawn":4,"away_for":10,"home_won":4,"points":23,"total_played":22,"id":"newcastle_united","home_lost":3,"away_against":18,"away_won":1,"home_drawn":4},{"name":"Sunderland","away_lost":5,"home_against":15,"goal_difference":-9,"home_for":12,"away_drawn":3,"away_for":11,"home_won":3,"points":23,"total_played":22,"id":"sunderland","home_lost":6,"away_against":17,"away_won":3,"home_drawn":2},{"name":"Tottenham","away_lost":7,"home_against":8,"goal_difference":-6,"home_for":8,"away_drawn":2,"away_for":13,"home_won":3,"points":21,"total_played":22,"id":"tottenham_hotspur","home_lost":4,"away_against":19,"away_won":2,"home_drawn":4},{"name":"Blackburn","away_lost":5,"home_against":17,"goal_difference":-11,"home_for":13,"away_drawn":3,"away_for":12,"home_won":3,"points":21,"total_played":21,"id":"blackburn_rovers","home_lost":5,"away_against":19,"away_won":2,"home_drawn":3},{"name":"Middlesbrough","away_lost":7,"home_against":15,"goal_difference":-15,"home_for":10,"away_drawn":2,"away_for":8,"home_won":3,"points":21,"total_played":22,"id":"middlesbrough","home_lost":4,"away_against":18,"away_won":2,"home_drawn":4},{"name":"Stoke","away_lost":8,"home_against":11,"goal_difference":-16,"home_for":12,"away_drawn":3,"away_for":7,"home_won":5,"points":21,"total_played":22,"id":"stoke_city","home_lost":3,"away_against":24,"away_won":0,"home_drawn":3},{"name":"West Brom","away_lost":9,"home_against":16,"goal_difference":-17,"home_for":16,"away_drawn":1,"away_for":4,"home_won":5,"points":21,"total_played":22,"id":"west_bromwich_albion","home_lost":4,"away_against":21,"away_won":1,"home_drawn":2}]
+[{"name":"Man Utd","away_lost":2,"home_against":4,"goal_difference":29,"home_for":24,"away_drawn":4,"away_for":15,"home_won":9,"points":50,"total_played":22,"id":"man_utd","home_lost":0,"away_against":6,"away_won":6,"home_drawn":1},{"name":"Liverpool","away_lost":1,"home_against":7,"goal_difference":22,"home_for":17,"away_drawn":3,"away_for":19,"home_won":6,"points":47,"total_played":22,"id":"liverpool","home_lost":0,"away_against":7,"away_won":7,"home_drawn":5},{"name":"Aston Villa","away_lost":3,"home_against":12,"goal_difference":14,"home_for":18,"away_drawn":0,"away_for":20,"home_won":5,"points":47,"total_played":23,"id":"aston_villa","home_lost":1,"away_against":12,"away_won":9,"home_drawn":5},{"name":"Chelsea","away_lost":1,"home_against":7,"goal_difference":29,"home_for":19,"away_drawn":2,"away_for":23,"home_won":5,"points":45,"total_played":22,"id":"chelsea","home_lost":2,"away_against":6,"away_won":8,"home_drawn":4},{"name":"Arsenal","away_lost":3,"home_against":11,"goal_difference":13,"home_for":18,"away_drawn":3,"away_for":19,"home_won":7,"points":41,"total_played":22,"id":"arsenal","home_lost":2,"away_against":13,"away_won":5,"home_drawn":2},{"name":"Everton","away_lost":2,"home_against":15,"goal_difference":4,"home_for":14,"away_drawn":2,"away_for":16,"home_won":3,"points":36,"total_played":22,"id":"everton","home_lost":4,"away_against":11,"away_won":7,"home_drawn":4},{"name":"Wigan","away_lost":6,"home_against":10,"goal_difference":2,"home_for":12,"away_drawn":2,"away_for":13,"home_won":6,"points":31,"total_played":22,"id":"wigan_athletic","home_lost":3,"away_against":13,"away_won":3,"home_drawn":2},{"name":"West Ham","away_lost":4,"home_against":16,"goal_difference":-2,"home_for":16,"away_drawn":4,"away_for":13,"home_won":5,"points":29,"total_played":22,"id":"west_ham_utd","home_lost":5,"away_against":15,"away_won":3,"home_drawn":1},{"name":"Hull","away_lost":3,"home_against":23,"goal_difference":-13,"home_for":11,"away_drawn":4,"away_for":18,"home_won":3,"points":27,"total_played":22,"id":"hull_city","home_lost":6,"away_against":19,"away_won":4,"home_drawn":2},{"name":"Fulham","away_lost":6,"home_against":8,"goal_difference":1,"home_for":16,"away_drawn":5,"away_for":3,"home_won":6,"points":26,"total_played":21,"id":"fulham","home_lost":1,"away_against":10,"away_won":0,"home_drawn":3},{"name":"Sunderland","away_lost":5,"home_against":15,"goal_difference":-8,"home_for":13,"away_drawn":3,"away_for":11,"home_won":4,"points":26,"total_played":23,"id":"sunderland","home_lost":6,"away_against":17,"away_won":3,"home_drawn":2},{"name":"Man City","away_lost":5,"home_against":11,"goal_difference":9,"home_for":25,"away_drawn":4,"away_for":14,"home_won":6,"points":25,"total_played":21,"id":"man_city","home_lost":5,"away_against":19,"away_won":1,"home_drawn":0},{"name":"Tottenham","away_lost":7,"home_against":9,"goal_difference":-4,"home_for":11,"away_drawn":2,"away_for":13,"home_won":4,"points":24,"total_played":23,"id":"tottenham_hotspur","home_lost":4,"away_against":19,"away_won":2,"home_drawn":4},{"name":"Portsmouth","away_lost":5,"home_against":18,"goal_difference":-13,"home_for":14,"away_drawn":4,"away_for":8,"home_won":4,"points":24,"total_played":22,"id":"portsmouth","home_lost":5,"away_against":17,"away_won":2,"home_drawn":2},{"name":"Bolton","away_lost":7,"home_against":12,"goal_difference":-8,"home_for":8,"away_drawn":0,"away_for":14,"home_won":3,"points":23,"total_played":22,"id":"bolton_wanderers","home_lost":6,"away_against":18,"away_won":4,"home_drawn":2},{"name":"Newcastle","away_lost":6,"home_against":19,"goal_difference":-9,"home_for":18,"away_drawn":4,"away_for":10,"home_won":4,"points":23,"total_played":22,"id":"newcastle_united","home_lost":3,"away_against":18,"away_won":1,"home_drawn":4},{"name":"Blackburn","away_lost":5,"home_against":17,"goal_difference":-11,"home_for":13,"away_drawn":3,"away_for":12,"home_won":3,"points":21,"total_played":21,"id":"blackburn_rovers","home_lost":5,"away_against":19,"away_won":2,"home_drawn":3},{"name":"Middlesbrough","away_lost":7,"home_against":15,"goal_difference":-15,"home_for":10,"away_drawn":2,"away_for":8,"home_won":3,"points":21,"total_played":22,"id":"middlesbrough","home_lost":4,"away_against":18,"away_won":2,"home_drawn":4},{"name":"Stoke","away_lost":9,"home_against":11,"goal_difference":-18,"home_for":12,"away_drawn":3,"away_for":8,"home_won":5,"points":21,"total_played":23,"id":"stoke_city","home_lost":3,"away_against":27,"away_won":0,"home_drawn":3},{"name":"West Brom","away_lost":9,"home_against":21,"goal_difference":-22,"home_for":16,"away_drawn":1,"away_for":4,"home_won":5,"points":21,"total_played":23,"id":"west_bromwich_albion","home_lost":5,"away_against":21,"away_won":1,"home_drawn":2}]
diff --git a/js/epl/teams/fixtures/arsenal.js b/js/epl/teams/fixtures/arsenal.js
index 19175be..13050b3 100644
--- a/js/epl/teams/fixtures/arsenal.js
+++ b/js/epl/teams/fixtures/arsenal.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Arsenal v Cardiff","date":"03 February 2009","unix_time":1233661500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Arsenal v Roma","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Roma v Arsenal","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Arsenal v Cardiff","date":"03 February 2009","unix_time":1233661500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Arsenal v Roma","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Roma v Arsenal","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237627800,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/aston_villa.js b/js/epl/teams/fixtures/aston_villa.js
index 86c78d6..b0eb8f7 100644
--- a/js/epl/teams/fixtures/aston_villa.js
+++ b/js/epl/teams/fixtures/aston_villa.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Portsmouth v Aston Villa","date":"27 January 2009","unix_time":1233057600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Wigan","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Aston Villa v Doncaster","date":"04 February 2009","unix_time":1233747900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Blackburn v Aston Villa","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"Aston Villa v CSKA Moscow","date":"18 February 2009","unix_time":1234954800,"gmt_time":"19:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Cup","details":"CSKA Moscow v Aston Villa","date":"26 February 2009","unix_time":1235638800,"gmt_time":"17:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Stoke","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Aston Villa","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Aston Villa v Tottenham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Aston Villa","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Aston Villa","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Newcastle","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Aston Villa v Wigan","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Aston Villa v Doncaster","date":"04 February 2009","unix_time":1233747900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Blackburn v Aston Villa","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"Aston Villa v CSKA Moscow","date":"18 February 2009","unix_time":1234954800,"gmt_time":"19:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Cup","details":"CSKA Moscow v Aston Villa","date":"26 February 2009","unix_time":1235638800,"gmt_time":"17:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Stoke","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Aston Villa","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Aston Villa v Tottenham","date":"15 March 2009","unix_time":1237104000,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"22 March 2009","unix_time":1237708800,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Aston Villa","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Aston Villa","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Newcastle","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/chelsea.js b/js/epl/teams/fixtures/chelsea.js
index 829f117..a7081ef 100644
--- a/js/epl/teams/fixtures/chelsea.js
+++ b/js/epl/teams/fixtures/chelsea.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Watford v Chelsea","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Champions League","details":"Chelsea v Juventus","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Juventus v Chelsea","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Watford v Chelsea","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Champions League","details":"Chelsea v Juventus","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Juventus v Chelsea","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"15 March 2009","unix_time":1237095000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/everton.js b/js/epl/teams/fixtures/everton.js
index fc2688b..5e997f4 100644
--- a/js/epl/teams/fixtures/everton.js
+++ b/js/epl/teams/fixtures/everton.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"02 February 2009","unix_time":1233576000,"gmt_time":"20:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"31 January 2009","unix_time":1233394200,"gmt_time":"17:30"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233749400,"gmt_time":"20:10"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237610700,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/fulham.js b/js/epl/teams/fixtures/fulham.js
index 288ed0c..af7c49f 100644
--- a/js/epl/teams/fixtures/fulham.js
+++ b/js/epl/teams/fixtures/fulham.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Sunderland v Fulham","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Swansea v Fulham","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Swansea v Fulham","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/hull_city.js b/js/epl/teams/fixtures/hull_city.js
index ad89850..c4b1ca1 100644
--- a/js/epl/teams/fixtures/hull_city.js
+++ b/js/epl/teams/fixtures/hull_city.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Sheff Utd v Hull","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Sheff Utd v Hull","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"22 March 2009","unix_time":1237699800,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/liverpool.js b/js/epl/teams/fixtures/liverpool.js
index 17dab37..cb56a0d 100644
--- a/js/epl/teams/fixtures/liverpool.js
+++ b/js/epl/teams/fixtures/liverpool.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Real Madrid v Liverpool","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"UEFA Champions League","details":"Liverpool v Real Madrid","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233749400,"gmt_time":"20:10"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Real Madrid v Liverpool","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"03 March 2009","unix_time":1236081600,"gmt_time":"20:00"},{"competition":"UEFA Champions League","details":"Liverpool v Real Madrid","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237005900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"22 March 2009","unix_time":1237708800,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/man_city.js b/js/epl/teams/fixtures/man_city.js
index d42b39d..2fce569 100644
--- a/js/epl/teams/fixtures/man_city.js
+++ b/js/epl/teams/fixtures/man_city.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Man City v Newcastle","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Stoke v Man City","date":"31 January 2009","unix_time":1233377100,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"UEFA Cup","details":"FC Copenhagen v Man City","date":"19 February 2009","unix_time":1235041500,"gmt_time":"19:05"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"Man City v FC Copenhagen","date":"26 February 2009","unix_time":1235648700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Man City v Aston Villa","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Sunderland","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v West Brom","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Blackburn","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Bolton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Man City v Newcastle","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Stoke v Man City","date":"31 January 2009","unix_time":1233377100,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Portsmouth v Man City","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"FC Copenhagen v Man City","date":"19 February 2009","unix_time":1235041500,"gmt_time":"19:05"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Cup","details":"Man City v FC Copenhagen","date":"26 February 2009","unix_time":1235648700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Man City v Aston Villa","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"15 March 2009","unix_time":1237095000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Man City v Sunderland","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v West Brom","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Blackburn","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Bolton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/man_utd.js b/js/epl/teams/fixtures/man_utd.js
index e1c6141..9bb24c7 100644
--- a/js/epl/teams/fixtures/man_utd.js
+++ b/js/epl/teams/fixtures/man_utd.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Brom v Man Utd","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"02 February 2009","unix_time":1233576000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Derby\/ Nottm Forest v Man Utd","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"UEFA Champions League","details":"Inter Milan v Man Utd","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Man Utd v Inter Milan","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"31 January 2009","unix_time":1233394200,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Derby\/ Nottm Forest v Man Utd","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"UEFA Champions League","details":"Inter Milan v Man Utd","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Man Utd v Inter Milan","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237005900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/newcastle_united.js b/js/epl/teams/fixtures/newcastle_united.js
index 8ad7db1..e73af57 100644
--- a/js/epl/teams/fixtures/newcastle_united.js
+++ b/js/epl/teams/fixtures/newcastle_united.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Man City v Newcastle","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Newcastle v Sunderland","date":"01 February 2009","unix_time":1233466200,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"West Brom v Newcastle","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Bolton v Newcastle","date":"01 March 2009","unix_time":1235883600,"gmt_time":"13:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Newcastle","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Portsmouth","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Newcastle","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Man City v Newcastle","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Newcastle v Sunderland","date":"01 February 2009","unix_time":1233466200,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"West Brom v Newcastle","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Bolton v Newcastle","date":"01 March 2009","unix_time":1235883600,"gmt_time":"13:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237627800,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Newcastle","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Portsmouth","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Newcastle","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/portsmouth.js b/js/epl/teams/fixtures/portsmouth.js
index 19cd487..e80b78c 100644
--- a/js/epl/teams/fixtures/portsmouth.js
+++ b/js/epl/teams/fixtures/portsmouth.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Portsmouth v Aston Villa","date":"27 January 2009","unix_time":1233057600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Stoke v Portsmouth","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Portsmouth","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v West Brom","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Bolton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Portsmouth","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Portsmouth","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Sunderland","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Portsmouth","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Portsmouth v Man City","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Portsmouth","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Portsmouth","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237610700,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v West Brom","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Bolton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Portsmouth","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Portsmouth","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Sunderland","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Portsmouth","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/stoke_city.js b/js/epl/teams/fixtures/stoke_city.js
index e88fba9..98cdebc 100644
--- a/js/epl/teams/fixtures/stoke_city.js
+++ b/js/epl/teams/fixtures/stoke_city.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Tottenham v Stoke","date":"27 January 2009","unix_time":1233057600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Stoke v Man City","date":"31 January 2009","unix_time":1233377100,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Sunderland v Stoke","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Portsmouth","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Stoke","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Bolton","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Middlesbrough","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Stoke","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Newcastle","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Blackburn","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Wigan","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Stoke v Man City","date":"31 January 2009","unix_time":1233377100,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Sunderland v Stoke","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Portsmouth","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Stoke","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Bolton","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Middlesbrough","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Stoke","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Newcastle","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Blackburn","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Wigan","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/sunderland.js b/js/epl/teams/fixtures/sunderland.js
index a514bd6..0fd1a7e 100644
--- a/js/epl/teams/fixtures/sunderland.js
+++ b/js/epl/teams/fixtures/sunderland.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Sunderland v Fulham","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Newcastle v Sunderland","date":"01 February 2009","unix_time":1233466200,"gmt_time":"13:30"},{"competition":"The FA Cup sponsored by E.ON","details":"Blackburn v Sunderland","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland v Stoke","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland OFF Tottenham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland v Wigan","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Sunderland","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Sunderland","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Sunderland","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Sunderland","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Newcastle v Sunderland","date":"01 February 2009","unix_time":1233466200,"gmt_time":"13:30"},{"competition":"The FA Cup sponsored by E.ON","details":"Blackburn v Sunderland","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland v Stoke","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland OFF Tottenham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"03 March 2009","unix_time":1236081600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland v Wigan","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Sunderland","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Sunderland","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Sunderland","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Sunderland","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/tottenham_hotspur.js b/js/epl/teams/fixtures/tottenham_hotspur.js
index f108925..0f814cb 100644
--- a/js/epl/teams/fixtures/tottenham_hotspur.js
+++ b/js/epl/teams/fixtures/tottenham_hotspur.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Tottenham v Stoke","date":"27 January 2009","unix_time":1233057600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Tottenham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"UEFA Cup","details":"Shakhtar Donetsk v Tottenham","date":"19 February 2009","unix_time":1235034000,"gmt_time":"17:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"UEFA Cup","details":"Tottenham v Shakhtar Donetsk","date":"26 February 2009","unix_time":1235649600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland OFF Tottenham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Tottenham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Tottenham","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Brom","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Bolton v Tottenham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"UEFA Cup","details":"Shakhtar Donetsk v Tottenham","date":"19 February 2009","unix_time":1235034000,"gmt_time":"17:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"UEFA Cup","details":"Tottenham v Shakhtar Donetsk","date":"26 February 2009","unix_time":1235649600,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Sunderland OFF Tottenham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Tottenham","date":"15 March 2009","unix_time":1237104000,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Tottenham","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Newcastle","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Brom","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Man City","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/west_bromwich_albion.js b/js/epl/teams/fixtures/west_bromwich_albion.js
index 3297148..b6cb330 100644
--- a/js/epl/teams/fixtures/west_bromwich_albion.js
+++ b/js/epl/teams/fixtures/west_bromwich_albion.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Brom v Man Utd","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Burnley v West Brom","date":"03 February 2009","unix_time":1233661500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Brom v Newcastle","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Bolton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Stoke","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v West Brom","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v West Brom","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Sunderland","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Brom","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Wigan","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Brom","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Burnley v West Brom","date":"03 February 2009","unix_time":1233661500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Brom v Newcastle","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"16 March 2009","unix_time":1237204800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"West Brom v Bolton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Stoke","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v West Brom","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v West Brom","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Sunderland","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Brom","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Wigan","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Brom","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/west_ham_utd.js b/js/epl/teams/fixtures/west_ham_utd.js
index 76e9f76..fdb78ae 100644
--- a/js/epl/teams/fixtures/west_ham_utd.js
+++ b/js/epl/teams/fixtures/west_ham_utd.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"16 March 2009","unix_time":1237204800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/wigan_athletic.js b/js/epl/teams/fixtures/wigan_athletic.js
index 8a3124f..68495d1 100644
--- a/js/epl/teams/fixtures/wigan_athletic.js
+++ b/js/epl/teams/fixtures/wigan_athletic.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Aston Villa v Wigan","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Sunderland v Wigan","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Wigan","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Bolton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Wigan","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Wigan","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Portsmouth","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Aston Villa v Wigan","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Sunderland v Wigan","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"22 March 2009","unix_time":1237699800,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v Wigan","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Bolton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Wigan","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Wigan","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Portsmouth","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
|
arunthampi/epl.github.com
|
3f046fe1e7e5cda5feb514107d5a12c7c42433a4
|
Adding gitignore
|
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..86042ab
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.plist
|
arunthampi/epl.github.com
|
264ceec940583108a90211fe2f16ffb95d0f19b6
|
Change to 57x57px
|
diff --git a/iphone/images/apple-touch-icon.png b/iphone/images/apple-touch-icon.png
index 07214cd..7d500eb 100644
Binary files a/iphone/images/apple-touch-icon.png and b/iphone/images/apple-touch-icon.png differ
|
arunthampi/epl.github.com
|
8154a5896049ff5855ced929438bc7399ea1a421
|
Add an iPhone/iPod Touch friendly icon
|
diff --git a/iphone/images/apple-touch-icon.png b/iphone/images/apple-touch-icon.png
index 50d8959..07214cd 100644
Binary files a/iphone/images/apple-touch-icon.png and b/iphone/images/apple-touch-icon.png differ
diff --git a/iphone/index.html b/iphone/index.html
index 2547e58..dd9165a 100644
--- a/iphone/index.html
+++ b/iphone/index.html
@@ -1,37 +1,37 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>English Premier League</title>
<link rel="stylesheet" href="/iphone/stylesheets/iphone.css" />
<link rel="stylesheet" href="/iphone/stylesheets/table.css" />
- <link rel="apple-touch-icon" href="iphone/images/apple-touch-icon.png" />
+ <link rel="apple-touch-icon" href="/iphone/images/apple-touch-icon.png" />
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<div id="header">
<h1>EPL Table</h1>
<a href="/iphone" id="backButton">Back</a>
</div>
<ul id="epl_iphone_table">
</ul>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table(true);
TABLE.initialize_teams();
});
</script>
</body>
</html>
\ No newline at end of file
|
arunthampi/epl.github.com
|
dc482fe152f89304abf76f661dfb30f7cc787675
|
Fix JS bug in the normal HTML version
|
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index 57353fb..0ff4a31 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,102 +1,102 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
EPL.Table = function(is_iphone) {
this.table = [];
this.is_iphone = is_iphone;
if(this.is_iphone) {
$('a#backButton').hide();
}
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
$.getJSON("/js/epl/all_teams.js",
function(data) {
for(var i = 0; i < data.length; i++) {
self.table.push(data[i]);
if(self.is_iphone) {
self.write_team_standings_to_iphone_view(data[i], i + 1);
} else {
self.write_team_standings_to_normal_view(data[i], i + 1);
}
}
self.initialize_fixtures_bindings();
});
};
EPL.Table.prototype.initialize_fixtures_bindings = function() {
var self = this;
$("a.fixtures").bind("click", function(e) {
var id = e.currentTarget.id;
if(self.is_iphone) {
self.show_fixtures_iphone_view(id);
} else {
self.show_fixtures_normal_view(id);
}
return false;
});
};
EPL.Table.prototype.show_fixtures_normal_view = function(id) {
var self = this;
- var html = "<span id=\"fixtures_" + id + "\">";
+ var html = "<p id=\"fixtures_" + id + "\">";
$.getJSON("/js/epl/teams/fixtures/" + id + ".js",
function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
- html += "<span id=\"fixtures_" + id + "_" + (i + 1) + "\">";
- html += "<span><b>" + fixtures[i].competition + "</b></span>";
- html += "<span><i>" + fixtures[i].details + "</i></span>";
- html += "<span><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></span>";
- html += "</span><hr />";
+ html += "<p id=\"fixtures_" + id + "_" + (i + 1) + "\">";
+ html += "<p><b>" + fixtures[i].competition + "</b></p>";
+ html += "<p><i>" + fixtures[i].details + "</i></p>";
+ html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
+ html += "</p><hr />";
}
- html += "</span>";
- $('p#long_form_p').replaceWith(html);
+ html += "</p>";
+ $('div#long_form_div').replaceWith(html);
});
};
EPL.Table.prototype.show_fixtures_iphone_view = function(id) {
var self = this;
// var html = "<li id=\"fixtures_" + id + "\">";
var html = "<ul id=\"epl_iphone_table\">";
$.getJSON("/js/epl/teams/fixtures/" + id + ".js",
function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<li id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<p><b>" + fixtures[i].competition + "</b></p>";
html += "<p><i>" + fixtures[i].details + "</i></p>";
html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
html += "</li>";
}
html += "</ul>";
$('ul#epl_iphone_table').replaceWith(html);
$('a#backButton').show();
});
};
EPL.Table.prototype.write_team_standings_to_iphone_view = function(team, rank) {
$('#epl_iphone_table').append(
"<a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" +
"<li class=\"arrow\"><p class=\"standing\"><span class=\"rank\">" + rank + "</span><span class=\"name\">" +
team.name + "</span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></a></li>"
);
};
EPL.Table.prototype.write_team_standings_to_normal_view = function(team, rank) {
$('#epl_long_form_table').append(
"<tr>" +
"<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
"<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
"<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
"<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
"<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
"<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
"<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
"<td>" + team.points + "</td>" +
"</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
e44dee5b002da8cf8397b880cf567eac480bf156
|
New Fixtures Updated 26-Jan-2009
|
diff --git a/js/epl/teams/fixtures/arsenal.js b/js/epl/teams/fixtures/arsenal.js
index 98896c2..1c71ac1 100644
--- a/js/epl/teams/fixtures/arsenal.js
+++ b/js/epl/teams/fixtures/arsenal.js
@@ -1 +1 @@
-[{"competition":"The FA Cup sponsored by E.ON","details":"Cardiff v Arsenal","date":"25 January 2009","unix_time":1232861400,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Arsenal v Roma","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Roma v Arsenal","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"The FA Cup sponsored by E.ON","details":"Cardiff v Arsenal","date":"25 January 2009","unix_time":1232861400,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Arsenal v Cardiff","date":"03 February 2009","unix_time":1233661500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Tottenham v Arsenal","date":"08 February 2009","unix_time":1234071000,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Sunderland","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Arsenal v Roma","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Arsenal","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Roma v Arsenal","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Arsenal v Blackburn","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Arsenal","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Man City","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Arsenal","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Arsenal","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Stoke","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/chelsea.js b/js/epl/teams/fixtures/chelsea.js
index b1df214..829f117 100644
--- a/js/epl/teams/fixtures/chelsea.js
+++ b/js/epl/teams/fixtures/chelsea.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Champions League","details":"Chelsea v Juventus","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Juventus v Chelsea","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Watford v Chelsea","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Chelsea","date":"21 February 2009","unix_time":1235191500,"gmt_time":"12:45"},{"competition":"UEFA Champions League","details":"Chelsea v Juventus","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Wigan","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Chelsea","date":"03 March 2009","unix_time":1236080700,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Juventus v Chelsea","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Chelsea v Man City","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Chelsea","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Chelsea","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Bolton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Chelsea","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Blackburn","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Chelsea","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/everton.js b/js/epl/teams/fixtures/everton.js
index 091717f..ee5e475 100644
--- a/js/epl/teams/fixtures/everton.js
+++ b/js/epl/teams/fixtures/everton.js
@@ -1 +1 @@
-[{"competition":"The FA Cup sponsored by E.ON","details":"Liverpool v Everton","date":"25 January 2009","unix_time":1232870400,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"02 February 2009","unix_time":1233576000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"The FA Cup sponsored by E.ON","details":"Liverpool v Everton","date":"25 January 2009","unix_time":1232870400,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v Arsenal","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"02 February 2009","unix_time":1233576000,"gmt_time":"20:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Bolton","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Everton","date":"22 February 2009","unix_time":1235289600,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Everton v West Brom","date":"28 February 2009","unix_time":1235796300,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Blackburn v Everton","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Everton v Stoke","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Everton","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Wigan","date":"05 April 2009","unix_time":1238914800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Everton","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Everton","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Man City","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Everton","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v Tottenham","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/fulham.js b/js/epl/teams/fixtures/fulham.js
index 3a1c08a..288ed0c 100644
--- a/js/epl/teams/fixtures/fulham.js
+++ b/js/epl/teams/fixtures/fulham.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Sunderland v Fulham","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Sunderland v Fulham","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Fulham v Portsmouth","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Fulham","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Swansea v Fulham","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v West Brom","date":"22 February 2009","unix_time":1235280600,"gmt_time":"13:30"},{"competition":"Barclays Premier League","details":"Arsenal v Fulham","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Fulham v Blackburn","date":"11 March 2009","unix_time":1236772800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Bolton v Fulham","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Fulham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Stoke","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Fulham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Aston Villa","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Fulham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Everton","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/hull_city.js b/js/epl/teams/fixtures/hull_city.js
index 6267ac2..ad89850 100644
--- a/js/epl/teams/fixtures/hull_city.js
+++ b/js/epl/teams/fixtures/hull_city.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v West Brom","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Chelsea v Hull","date":"07 February 2009","unix_time":1233990000,"gmt_time":"15:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Sheff Utd v Hull","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Tottenham","date":"23 February 2009","unix_time":1235390400,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Blackburn","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Hull","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Hull v Newcastle","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Hull","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Portsmouth","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Hull","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v Hull","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Stoke","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Hull","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/liverpool.js b/js/epl/teams/fixtures/liverpool.js
index c421235..1a32f1d 100644
--- a/js/epl/teams/fixtures/liverpool.js
+++ b/js/epl/teams/fixtures/liverpool.js
@@ -1 +1 @@
-[{"competition":"The FA Cup sponsored by E.ON","details":"Liverpool v Everton","date":"25 January 2009","unix_time":1232870400,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Real Madrid v Liverpool","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"UEFA Champions League","details":"Liverpool v Real Madrid","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"The FA Cup sponsored by E.ON","details":"Liverpool v Everton","date":"25 January 2009","unix_time":1232870400,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Wigan v Liverpool","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Liverpool v Chelsea","date":"01 February 2009","unix_time":1233475200,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Everton v Liverpool","date":"04 February 2009","unix_time":1233748800,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Portsmouth v Liverpool","date":"07 February 2009","unix_time":1233999000,"gmt_time":"17:30"},{"competition":"Barclays Premier League","details":"Liverpool v Man City","date":"22 February 2009","unix_time":1235286000,"gmt_time":"15:00"},{"competition":"UEFA Champions League","details":"Real Madrid v Liverpool","date":"25 February 2009","unix_time":1235562300,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Sunderland","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"UEFA Champions League","details":"Liverpool v Real Madrid","date":"10 March 2009","unix_time":1236685500,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Aston Villa","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Liverpool","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Blackburn","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Arsenal","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Liverpool","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Newcastle","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Brom v Liverpool","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Liverpool v Tottenham","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/man_utd.js b/js/epl/teams/fixtures/man_utd.js
index 9b6f70f..e1c6141 100644
--- a/js/epl/teams/fixtures/man_utd.js
+++ b/js/epl/teams/fixtures/man_utd.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Brom v Man Utd","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"02 February 2009","unix_time":1233576000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"UEFA Champions League","details":"Inter Milan v Man Utd","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Man Utd v Inter Milan","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"West Brom v Man Utd","date":"27 January 2009","unix_time":1233056700,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Everton","date":"02 February 2009","unix_time":1233576000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"Derby\/ Nottm Forest v Man Utd","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Fulham","date":"17 February 2009","unix_time":1234872000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Man Utd v Blackburn","date":"21 February 2009","unix_time":1235208600,"gmt_time":"17:30"},{"competition":"UEFA Champions League","details":"Inter Milan v Man Utd","date":"24 February 2009","unix_time":1235475900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd OFF Portsmouth","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Carling Cup","details":"Man Utd v Tottenham","date":"01 March 2009","unix_time":1235890800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Man Utd","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"UEFA Champions League","details":"Man Utd v Inter Milan","date":"11 March 2009","unix_time":1236771900,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Man Utd v Liverpool","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Fulham v Man Utd","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Aston Villa","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Sunderland v Man Utd","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Wigan v Man Utd","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Tottenham","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Man City","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man Utd v Arsenal","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Hull v Man Utd","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/middlesbrough.js b/js/epl/teams/fixtures/middlesbrough.js
index 36c9ea4..73abb22 100644
--- a/js/epl/teams/fixtures/middlesbrough.js
+++ b/js/epl/teams/fixtures/middlesbrough.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Blackburn","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Portsmouth","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Middlesbrough","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Middlesbrough","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Aston Villa","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"Chelsea v Middlesbrough","date":"28 January 2009","unix_time":1233143100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"Middlesbrough v Blackburn","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Man City v Middlesbrough","date":"07 February 2009","unix_time":1233981900,"gmt_time":"12:45"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Wigan","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Liverpool","date":"28 February 2009","unix_time":1235804400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v Middlesbrough","date":"04 March 2009","unix_time":1236168000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Portsmouth","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v Middlesbrough","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v Middlesbrough","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Hull","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Fulham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Arsenal v Middlesbrough","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Man Utd","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Newcastle v Middlesbrough","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Middlesbrough v Aston Villa","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
diff --git a/js/epl/teams/fixtures/west_ham_utd.js b/js/epl/teams/fixtures/west_ham_utd.js
index b098056..76e9f76 100644
--- a/js/epl/teams/fixtures/west_ham_utd.js
+++ b/js/epl/teams/fixtures/west_ham_utd.js
@@ -1 +1 @@
-[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
+[{"competition":"Barclays Premier League","details":"West Ham v Hull","date":"28 January 2009","unix_time":1233144000,"gmt_time":"20:00"},{"competition":"Barclays Premier League","details":"Arsenal v West Ham","date":"31 January 2009","unix_time":1233385200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man Utd","date":"08 February 2009","unix_time":1234080000,"gmt_time":"16:00"},{"competition":"The FA Cup sponsored by E.ON","details":"West Ham v Middlesbrough","date":"14 February 2009","unix_time":1234594800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Bolton v West Ham","date":"21 February 2009","unix_time":1235199600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Man City","date":"01 March 2009","unix_time":1235881800,"gmt_time":"12:30"},{"competition":"Barclays Premier League","details":"Wigan v West Ham","date":"04 March 2009","unix_time":1236167100,"gmt_time":"19:45"},{"competition":"Barclays Premier League","details":"West Ham v West Brom","date":"14 March 2009","unix_time":1237014000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Blackburn v West Ham","date":"21 March 2009","unix_time":1237618800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Sunderland","date":"04 April 2009","unix_time":1238828400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Tottenham v West Ham","date":"11 April 2009","unix_time":1239433200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Aston Villa v West Ham","date":"18 April 2009","unix_time":1240038000,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Chelsea","date":"25 April 2009","unix_time":1240642800,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Stoke v West Ham","date":"02 May 2009","unix_time":1241247600,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Liverpool","date":"09 May 2009","unix_time":1241852400,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"Everton v West Ham","date":"16 May 2009","unix_time":1242457200,"gmt_time":"15:00"},{"competition":"Barclays Premier League","details":"West Ham v Middlesbrough","date":"24 May 2009","unix_time":1243152000,"gmt_time":"16:00"}]
|
arunthampi/epl.github.com
|
ad71fe4ee45ea24ad4359d289a615aa3e16d12e9
|
Use Javascript redirect for iPhone
|
diff --git a/index.html b/index.html
index 01a1d58..9be328f 100644
--- a/index.html
+++ b/index.html
@@ -1,34 +1,42 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>EPL's GitHub</title>
+ <script type="text/javascript">
+//<![CDATA[
+ if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
+ location.replace("/iphone");
+//]]>
+ }
+ </script>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<h3><a href="/">English Premier League</a></h3>
<div id="long_form_div">
<table id="epl_long_form_table">
<tbody>
<tr>
<td></td><td>Team</td><td>P</td><td>HW</td><td>HD</td><td>HL</td><td>HF</td><td>HA</td><td>AW</td><td>AD</td><td>AL</td><td>AF</td><td>AA</td><td>GD</td><td>Points</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table(false);
TABLE.initialize_teams();
});
+//]]>
</script>
</body>
</html>
\ No newline at end of file
|
arunthampi/epl.github.com
|
c3ff59e31a32399acfc6f9a4a8417f2b6f72dbb7
|
Don't do any moving of the viewport
|
diff --git a/iphone/index.html b/iphone/index.html
index 00d4c1e..2547e58 100644
--- a/iphone/index.html
+++ b/iphone/index.html
@@ -1,42 +1,37 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>English Premier League</title>
<link rel="stylesheet" href="/iphone/stylesheets/iphone.css" />
<link rel="stylesheet" href="/iphone/stylesheets/table.css" />
<link rel="apple-touch-icon" href="iphone/images/apple-touch-icon.png" />
- <script type="text/javascript" charset="utf-8">
- window.onload = function() {
- setTimeout(function(){window.scrollTo(0, 1);}, 100);
- }
- </script>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<div id="header">
<h1>EPL Table</h1>
<a href="/iphone" id="backButton">Back</a>
</div>
<ul id="epl_iphone_table">
</ul>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table(true);
TABLE.initialize_teams();
});
</script>
</body>
</html>
\ No newline at end of file
|
arunthampi/epl.github.com
|
b092c55a8ba3ee24d0cb6c15a49b3255b3d7b95f
|
Make the entire row clickable
|
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index 8d6fff8..57353fb 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,101 +1,102 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
EPL.Table = function(is_iphone) {
this.table = [];
this.is_iphone = is_iphone;
if(this.is_iphone) {
$('a#backButton').hide();
}
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
$.getJSON("/js/epl/all_teams.js",
function(data) {
for(var i = 0; i < data.length; i++) {
self.table.push(data[i]);
if(self.is_iphone) {
self.write_team_standings_to_iphone_view(data[i], i + 1);
} else {
self.write_team_standings_to_normal_view(data[i], i + 1);
}
}
self.initialize_fixtures_bindings();
});
};
EPL.Table.prototype.initialize_fixtures_bindings = function() {
var self = this;
$("a.fixtures").bind("click", function(e) {
var id = e.currentTarget.id;
if(self.is_iphone) {
self.show_fixtures_iphone_view(id);
} else {
self.show_fixtures_normal_view(id);
}
return false;
});
};
EPL.Table.prototype.show_fixtures_normal_view = function(id) {
var self = this;
var html = "<span id=\"fixtures_" + id + "\">";
$.getJSON("/js/epl/teams/fixtures/" + id + ".js",
function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<span id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<span><b>" + fixtures[i].competition + "</b></span>";
html += "<span><i>" + fixtures[i].details + "</i></span>";
html += "<span><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></span>";
html += "</span><hr />";
}
html += "</span>";
$('p#long_form_p').replaceWith(html);
});
};
EPL.Table.prototype.show_fixtures_iphone_view = function(id) {
var self = this;
// var html = "<li id=\"fixtures_" + id + "\">";
var html = "<ul id=\"epl_iphone_table\">";
$.getJSON("/js/epl/teams/fixtures/" + id + ".js",
function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<li id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<p><b>" + fixtures[i].competition + "</b></p>";
html += "<p><i>" + fixtures[i].details + "</i></p>";
html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
html += "</li>";
}
html += "</ul>";
$('ul#epl_iphone_table').replaceWith(html);
$('a#backButton').show();
});
};
EPL.Table.prototype.write_team_standings_to_iphone_view = function(team, rank) {
$('#epl_iphone_table').append(
+ "<a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" +
"<li class=\"arrow\"><p class=\"standing\"><span class=\"rank\">" + rank + "</span><span class=\"name\">" +
- "<a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></li>"
+ team.name + "</span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></a></li>"
);
};
EPL.Table.prototype.write_team_standings_to_normal_view = function(team, rank) {
$('#epl_long_form_table').append(
"<tr>" +
"<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
"<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
"<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
"<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
"<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
"<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
"<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
"<td>" + team.points + "</td>" +
"</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
d03c28871aaf9781efa3cc5640fbafc17f2fad34
|
Add support to see fixtures in iPhone mode
|
diff --git a/iphone/index.html b/iphone/index.html
index 48857db..00d4c1e 100644
--- a/iphone/index.html
+++ b/iphone/index.html
@@ -1,41 +1,42 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>English Premier League</title>
<link rel="stylesheet" href="/iphone/stylesheets/iphone.css" />
<link rel="stylesheet" href="/iphone/stylesheets/table.css" />
<link rel="apple-touch-icon" href="iphone/images/apple-touch-icon.png" />
<script type="text/javascript" charset="utf-8">
window.onload = function() {
setTimeout(function(){window.scrollTo(0, 1);}, 100);
}
</script>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<div id="header">
<h1>EPL Table</h1>
+ <a href="/iphone" id="backButton">Back</a>
</div>
<ul id="epl_iphone_table">
</ul>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table(true);
TABLE.initialize_teams();
});
</script>
</body>
</html>
\ No newline at end of file
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index b1d5f56..8d6fff8 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,71 +1,101 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
EPL.Table = function(is_iphone) {
this.table = [];
this.is_iphone = is_iphone;
+ if(this.is_iphone) {
+ $('a#backButton').hide();
+ }
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
$.getJSON("/js/epl/all_teams.js",
function(data) {
for(var i = 0; i < data.length; i++) {
self.table.push(data[i]);
if(self.is_iphone) {
self.write_team_standings_to_iphone_view(data[i], i + 1);
} else {
self.write_team_standings_to_normal_view(data[i], i + 1);
}
}
self.initialize_fixtures_bindings();
});
};
EPL.Table.prototype.initialize_fixtures_bindings = function() {
var self = this;
$("a.fixtures").bind("click", function(e) {
var id = e.currentTarget.id;
- self.show_fixtures_view(id);
+ if(self.is_iphone) {
+ self.show_fixtures_iphone_view(id);
+ } else {
+ self.show_fixtures_normal_view(id);
+ }
return false;
});
};
-EPL.Table.prototype.show_fixtures_view = function(id) {
+EPL.Table.prototype.show_fixtures_normal_view = function(id) {
var self = this;
var html = "<span id=\"fixtures_" + id + "\">";
$.getJSON("/js/epl/teams/fixtures/" + id + ".js",
function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
html += "<span id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<span><b>" + fixtures[i].competition + "</b></span>";
html += "<span><i>" + fixtures[i].details + "</i></span>";
html += "<span><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></span>";
html += "</span><hr />";
}
html += "</span>";
$('p#long_form_p').replaceWith(html);
});
};
+EPL.Table.prototype.show_fixtures_iphone_view = function(id) {
+ var self = this;
+// var html = "<li id=\"fixtures_" + id + "\">";
+ var html = "<ul id=\"epl_iphone_table\">";
+
+ $.getJSON("/js/epl/teams/fixtures/" + id + ".js",
+ function(fixtures) {
+ for(var i = 0; i < fixtures.length; i++) {
+ html += "<li id=\"fixtures_" + id + "_" + (i + 1) + "\">";
+ html += "<p><b>" + fixtures[i].competition + "</b></p>";
+ html += "<p><i>" + fixtures[i].details + "</i></p>";
+ html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
+ html += "</li>";
+ }
+ html += "</ul>";
+
+ $('ul#epl_iphone_table').replaceWith(html);
+ $('a#backButton').show();
+ });
+};
+
+
EPL.Table.prototype.write_team_standings_to_iphone_view = function(team, rank) {
$('#epl_iphone_table').append(
- "<li class=\"arrow\"><p class=\"standing\"><span class=\"rank\">" + rank + "</span><span class=\"name\">" + team.name + "</span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></li>"
+ "<li class=\"arrow\"><p class=\"standing\"><span class=\"rank\">" + rank + "</span><span class=\"name\">" +
+ "<a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></li>"
);
};
EPL.Table.prototype.write_team_standings_to_normal_view = function(team, rank) {
$('#epl_long_form_table').append(
"<tr>" +
"<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
"<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
"<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
"<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
"<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
"<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
"<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
"<td>" + team.points + "</td>" +
"</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
b98f19af33659ee4146771ac40514d4ef7526e80
|
Some adjustments in the CSS
|
diff --git a/iphone/stylesheets/table.css b/iphone/stylesheets/table.css
index c22a2e6..a3b37d8 100644
--- a/iphone/stylesheets/table.css
+++ b/iphone/stylesheets/table.css
@@ -1,28 +1,28 @@
span.rank {
float: left;
width: 8%;
}
span.name {
float: left;
width: 50%;
}
span.played {
float: left;
width: 12%;
}
span.gd {
float: left;
- width: 12%;
+ width: 14%;
}
span.pts {
float: left;
width: 12%;
}
p.standing {
height: 7px;
}
\ No newline at end of file
|
arunthampi/epl.github.com
|
36ba0a3c3573607bbc59eea75ebf9b8365147c3c
|
Fix paths for stylesheets
|
diff --git a/iphone/index.html b/iphone/index.html
index 4e7fdde..48857db 100644
--- a/iphone/index.html
+++ b/iphone/index.html
@@ -1,41 +1,41 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>English Premier League</title>
- <link rel="stylesheet" href="iphone/stylesheets/iphone.css" />
- <link rel="stylesheet" href="iphone/stylesheets/table.css" />
+ <link rel="stylesheet" href="/iphone/stylesheets/iphone.css" />
+ <link rel="stylesheet" href="/iphone/stylesheets/table.css" />
<link rel="apple-touch-icon" href="iphone/images/apple-touch-icon.png" />
<script type="text/javascript" charset="utf-8">
window.onload = function() {
setTimeout(function(){window.scrollTo(0, 1);}, 100);
}
</script>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<div id="header">
<h1>EPL Table</h1>
</div>
<ul id="epl_iphone_table">
</ul>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table(true);
TABLE.initialize_teams();
});
</script>
</body>
</html>
\ No newline at end of file
|
arunthampi/epl.github.com
|
30c7935e29e7723c543ff74d92c2d40e3011e153
|
Add support for iPhone
|
diff --git a/index.html b/index.html
index 26efefd..01a1d58 100644
--- a/index.html
+++ b/index.html
@@ -1,34 +1,34 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>EPL's GitHub</title>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<h3><a href="/">English Premier League</a></h3>
<div id="long_form_div">
<table id="epl_long_form_table">
<tbody>
<tr>
<td></td><td>Team</td><td>P</td><td>HW</td><td>HD</td><td>HL</td><td>HF</td><td>HA</td><td>AW</td><td>AD</td><td>AL</td><td>AF</td><td>AA</td><td>GD</td><td>Points</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
- TABLE = new EPL.Table();
+ TABLE = new EPL.Table(false);
TABLE.initialize_teams();
});
</script>
</body>
</html>
\ No newline at end of file
diff --git a/iphone/images/actionButton.png b/iphone/images/actionButton.png
new file mode 100644
index 0000000..0f92dfd
Binary files /dev/null and b/iphone/images/actionButton.png differ
diff --git a/iphone/images/apple-touch-icon.png b/iphone/images/apple-touch-icon.png
new file mode 100644
index 0000000..50d8959
Binary files /dev/null and b/iphone/images/apple-touch-icon.png differ
diff --git a/iphone/images/backButton.png b/iphone/images/backButton.png
new file mode 100644
index 0000000..e27ea8c
Binary files /dev/null and b/iphone/images/backButton.png differ
diff --git a/iphone/images/banner-1.png b/iphone/images/banner-1.png
new file mode 100644
index 0000000..91727c9
Binary files /dev/null and b/iphone/images/banner-1.png differ
diff --git a/iphone/images/banner-2.png b/iphone/images/banner-2.png
new file mode 100644
index 0000000..2290ba4
Binary files /dev/null and b/iphone/images/banner-2.png differ
diff --git a/iphone/images/banner-3.png b/iphone/images/banner-3.png
new file mode 100644
index 0000000..6637239
Binary files /dev/null and b/iphone/images/banner-3.png differ
diff --git a/iphone/images/bgHeader.png b/iphone/images/bgHeader.png
new file mode 100644
index 0000000..6a54e19
Binary files /dev/null and b/iphone/images/bgHeader.png differ
diff --git a/iphone/images/bgMetal.png b/iphone/images/bgMetal.png
new file mode 100644
index 0000000..99b9b74
Binary files /dev/null and b/iphone/images/bgMetal.png differ
diff --git a/iphone/images/bglight.png b/iphone/images/bglight.png
new file mode 100644
index 0000000..ca2acd9
Binary files /dev/null and b/iphone/images/bglight.png differ
diff --git a/iphone/images/blackbg.png b/iphone/images/blackbg.png
new file mode 100644
index 0000000..5234139
Binary files /dev/null and b/iphone/images/blackbg.png differ
diff --git a/iphone/images/blueButton.png b/iphone/images/blueButton.png
new file mode 100644
index 0000000..0cfbee1
Binary files /dev/null and b/iphone/images/blueButton.png differ
diff --git a/iphone/images/camera-icon-draw.ai b/iphone/images/camera-icon-draw.ai
new file mode 100644
index 0000000..cb6e942
--- /dev/null
+++ b/iphone/images/camera-icon-draw.ai
@@ -0,0 +1,230 @@
+%PDF-1.5
%âãÏÓ
+1 0 obj
<</Metadata 42 0 R/Pages 2 0 R/OCProperties<</D<</RBGroups[]/ON[13 0 R 33 0 R]/Order 32 0 R>>/OCGs[13 0 R 33 0 R]>>/Type/Catalog>>
endobj
42 0 obj
<</Subtype/XML/Length 13984/Type/Metadata>>stream
+<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.1-c036 46.276720, Mon Feb 19 2007 22:13:43 ">
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about=""
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <dc:format>application/pdf</dc:format>
+ </rdf:Description>
+ <rdf:Description rdf:about=""
+ xmlns:xap="http://ns.adobe.com/xap/1.0/"
+ xmlns:xapGImg="http://ns.adobe.com/xap/1.0/g/img/">
+ <xap:CreatorTool>Adobe Illustrator CS3</xap:CreatorTool>
+ <xap:CreateDate>2008-08-27T01:32:58+02:00</xap:CreateDate>
+ <xap:ModifyDate>2008-08-27T01:33:18+02:00</xap:ModifyDate>
+ <xap:MetadataDate>2008-08-27T01:33:18+02:00</xap:MetadataDate>
+ <xap:Thumbnails>
+ <rdf:Alt>
+ <rdf:li rdf:parseType="Resource">
+ <xapGImg:width>256</xapGImg:width>
+ <xapGImg:height>196</xapGImg:height>
+ <xapGImg:format>JPEG</xapGImg:format>
+ <xapGImg:image>/9j/4AAQSkZJRgABAgEASABIAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNA+0AAAAAABAASAAAAAEA
AQBIAAAAAQAB/+4ADkFkb2JlAGTAAAAAAf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoK
DBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8f
Hx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f/8AAEQgAxAEAAwER
AAIRAQMRAf/EAaIAAAAHAQEBAQEAAAAAAAAAAAQFAwIGAQAHCAkKCwEAAgIDAQEBAQEAAAAAAAAA
AQACAwQFBgcICQoLEAACAQMDAgQCBgcDBAIGAnMBAgMRBAAFIRIxQVEGE2EicYEUMpGhBxWxQiPB
UtHhMxZi8CRygvElQzRTkqKyY3PCNUQnk6OzNhdUZHTD0uIIJoMJChgZhJRFRqS0VtNVKBry4/PE
1OT0ZXWFlaW1xdXl9WZ2hpamtsbW5vY3R1dnd4eXp7fH1+f3OEhYaHiImKi4yNjo+Ck5SVlpeYmZ
qbnJ2en5KjpKWmp6ipqqusra6voRAAICAQIDBQUEBQYECAMDbQEAAhEDBCESMUEFURNhIgZxgZEy
obHwFMHR4SNCFVJicvEzJDRDghaSUyWiY7LCB3PSNeJEgxdUkwgJChgZJjZFGidkdFU38qOzwygp
0+PzhJSktMTU5PRldYWVpbXF1eX1RlZmdoaWprbG1ub2R1dnd4eXp7fH1+f3OEhYaHiImKi4yNjo
+DlJWWl5iZmpucnZ6fkqOkpaanqKmqq6ytrq+v/aAAwDAQACEQMRAD8A9U4q7FXYq7FXYq7FXYq7
FWKfmf59tPI3lC61yZBNcAiCwtjUCW4kB4KafsgAs3sD3xV8S+a/O/mnzXfve67qEt3IxqkRYiGM
dljiHwIB7DFUjxV2KuxV2KuxV2KuxV2KuxV2KuxV2KorTtU1LTLtLzTrqazuozVJ4HaNwR4MpBxV
9bf84+/nFdec7G40XXZFbzBp6CRZwAv1m3qFLlRtzRiA1KVqPfFXsOKuxV2KuxV2KuxV2KuxV2Ku
xV2KuxV2KuxV2KuxV8c/85IfmF/ibzmdJs5Q+kaCXt4yp+GS5NBPJ70K8F+VR1xV5JirsVdirsVd
irsVdirsVdirsVdirsVdirsVT7yN5tvvKXmrT9fs6l7OQGWKtBJC3wyxn/WQkex3xV98aRqthq+l
2mqafKJrK9iSe3lHdJByG3Y77jtiqLxV2KuxV2KuxV2KuxV2KqN3fWVlCZ7y4jtoR1lmdY1H+yYg
YqlX+OfJX/Uwab/0mQf814q7/HPkr/qYNN/6TIP+a8Vd/jnyV/1MGm/9JkH/ADXirv8AHPkr/qYN
N/6TIP8AmvFXf458lf8AUwab/wBJkH/NeKsL/N784NB8v+SbybRNVtbvWrsfVbBbWeOZ43kBrMQj
MQI1BIP81B3xV8XEkkkmpO5JxVrFXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FX0j/zjF+adha6
bdeUtevorSK1rdaVPcyLHH6bt+9h5OVFQ7c1HereGKvdf8c+Sv8AqYNN/wCkyD/mvFXf458lf9TB
pv8A0mQf814q7/HPkr/qYNN/6TIP+a8Vd/jnyV/1MGm/9JkH/NeKu/xz5K/6mDTf+kyD/mvFU1tL
6yvYRPZ3EdzCeksLrIp/2SkjFVbFXkv55/nYnka3j0jRwk/mS7jLgv8AElrEdlkdf2nY/YX6TtQF
V8k695j17zBfPf61fzX925J9Sdy1K70QfZRf8lQBiqXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7
FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FUx0HzHr3l++S/wBFv5rC7Qg+pA5WtN6OPsuv+SwI
xV9bfkZ+dieebeTSNYCQeZLSMOSnwpdRDZpEX9l1P21+kbVAVfKXnXzJc+ZfNeq67cMWa+uHkjB/
ZirSJB7JGFUfLFUlxV2KuxV2KuxV2KuxV2KuxV2KuxV2KpjovlzX9cuDb6Np1zqMw+0ltE8pUeLc
AeI9zir0HSf+ca/zY1BVeXTodPRtw13cRg091iMrj6RirJbb/nEXzm1PrWtadFtv6Xryb/7KOPFV
1x/ziJ5vUf6PrenyGh2kWaPft0STFWPar/zjF+a1kGMFraakF3/0W5UV+QnEBxV5/r/k/wA1eXnC
a3pN1p9TRXnidEY/5DkcG+g4qk+KuxV2KuxV2KuxV2KuxV2KuxV2KuxVOvJXmS58tea9K123Yq1j
cJJIB+1FWkqH2eMsp+eKpLirsVdirsVdirsVdirsVdirsVdirKvIv5Z+b/O94YNDsy1vGwW4v5j6
dtF/rSUNT/kqC3tir6S8i/8AOMPkvRFjufMDHX9RFCUkBjtEPgIgav8A7MkH+UYq9esrCxsLZLWx
t4rS1jFI4IEWONR/kqoAGKq+KuxV2KuxVZNBDPE8M8aywyArJG4DKynqCDsRiry3zv8A844fl/5j
SSfT4P0DqTbrPZKBCT/l2+yU/wBTiffFXzb+Yf5N+dPIzmbULcXWlE0j1S1q8O52ElQGjb/WFPAn
FWC4q7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq9u/Jf/nHq78zLDr/mhXtN
Aaj2loDwmux2Y944j49W7bb4q+qdM0vTtKsIdP022jtLK3XhBbwqERVHgB+OKorFXYq7FXYq7FXY
q7FXYqsngguIZIJ41mglUpLFIAyMrChVlOxBGKvmz85f+cbvq8c3mDyPAzRLWS80RdyoG5e2ruR/
xX1/l/lxV86EEGh64q7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq9y/5x8/JNPMcy
eafMcHLQoG/0CzcbXUqHdnB6woe37R26Agqvq5VVVCqAFAoANgAMVbxV2KuxV2KoG91/QrElb7Ub
W1Zd2E80cZHbfkwxVTtPM3lu8YLZ6rZ3LMaAQ3EUhJHb4WOKplirsVdirsVdir5z/wCcifyRiaK4
86eWrfjKlZdbsIhsw6m5jUdCOsgHX7XjVV81Yq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FX
YqzP8pvy9ufPXnC20ock06H/AEjVLhduFuhFQDQ/G5+Ffv7HFX3PY2NnYWUFjZRLBaW0axQQoKKi
IKKo+QGKq+KuxVbLLHFG8srrHFGpZ3YgKqgVJJOwAGKvCfzF/wCcpdG0qSTT/KECateISr6jNUWi
kbfAFKvL8wVXwJxV4H5m/Nj8w/Mrv+lNcuWgfraQN9Xgp4elFwU/NqnFWJEkmp64q7FWReXPzE88
eXHQ6Lrd3aIhBFuJC8Bp4wycoz9K4q9z/L7/AJytjlkjsfO1qsNaKNXs1JSvjNB8RHuU/wCBxV9C
afqFjqNlDfWFxHdWdwoeC4hYOjqe6sNjiqIxV2KtMqspVgCpFCDuCDir4x/P/wDLBfJnmr61p0RX
QNXLTWYH2YZR/ewV8ATyT/JNOxxV5birsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVfZ3/OOn
kRfLPkGC9uI+Oqa7xvbkkUZYiP8AR4/oQ8vmxxV6nirsVWXFxBbwSXFxIsUEKtJLK5CqiKKszE7A
ACpOKvj/APO788r7zjdy6Nokr23leFuJpVXvGU/bk7+nt8CfS29AqryHFXYq7FXYq7FXYq9D/KP8
4dZ8g6oqMXu/L1w3+nadXpXYzQ12WQfc3Q9iFX2jous6brWlWuraZOtzYXkYlt5l6FT4+BB2IO4O
2Ko3FXYqw/8ANjyPF508j6ho4UfXVX6xprn9m5iBKb9ue6H2bFXwe6OjsjqVdSQykUII2IIOKtYq
7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FWR/l15ZPmfzxouhkExXlyguAOvoR1kmI+USNir79RERF
RFCooAVQKAAbAADFW8Vdir55/wCcp/zIltLeDyTpsxSS7QXGsOh3ENf3UBp/ORyYeFOxxV8yYq7F
XYq7FXYq7FXYq7FXu/8Azi9+ZEum663k7UJidO1Qs+ncztFdgVKCvQSqP+CA8Tir6qxV2KuxV8R/
n/5WXy9+Z+qRxJwtdS46jbKNhS4r6lAO3rK4GKvOsVdirsVdirsVdirsVdirsVdirsVdirsVdir2
3/nE7Rlu/P19qUi8l02wf02/llndUB/5Fhxir60xV2KrJ5ooIZJ5mCRRKXkc9FVRUk/IYq/Przl5
juPMvmrVNduCeeoXDyqrdVjJpGn+wjCqPliqTYq7FXYq7FXYq7FXYq7FVayvLmyvIL21kMV1bSJN
BKvVZI2DKw+RGKv0H8q67Dr/AJa0vW4QAmo2sVxwG/FpEBZP9i1VxVNMVdir5w/5y/0ZeHlzWkX4
q3FnM3iPhkiH0fHir5txV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KvpX/nD22QW3mm6p8bPZxBiO
gUTMQD78t/oxV9GYq7FWJ/mxfyWH5aeZrmMkSDT541I6gyoY6/RzxV8FYq7FXYq7FXYq7FXYq7FX
Yq7FX2j/AM42X8l1+Umlo5JNpLcwAnwEzOPuD0xV6hirsVeMf85X2qy/lrazcatb6nA4YDoGimQ1
Ph8X6sVfIuKuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV9O/84fzltH8ywbUjuLZ/f40kH/GmKvoT
FXYqwr86Yml/KrzMqgkiyd9jTZCGP4DFXwnirsVdirsVdirsVdirsVdirsVfY/8Azi/AYvypgcgg
T3lzICTWtGCbeH2MVetYq7FXj/8AzlPMY/yu4UB9bULdN/ZXfb/gMVfH2KuxV2KuxV2KuxV2KuxV
2KuxV2KuxV2KuxV9Af8AOIWqLF5g8w6WT8V3aQ3IHj9WkKH/AKicVfUOKuxVA69pUer6HqOkyGke
oWs1q58FmjMZ/wCJYq/PG7tZ7S6mtLhSk9vI0UqHqroSrD6CMVUsVdirsVdirsVdirsVdirsVfen
5S6C+g/lt5e0yRSk0dossyHqslwTPIp+TyEYqy3FXYq8C/5y81NY/LGg6XX4rm9kuuO3S3iKV8f+
PjFXy3irsVdirsVdirsVdirsVdirsVdirsVdirsVeg/kJ5iGhfmnossjcbe+drCfelRcjhHU+Al4
HFX3BirsVdir5A/5yZ8hSaD52bXraOmma/WbkOiXa09dD/r7Sb9anwxV47irsVdirsVdirsVdirs
VZ7+SfkOTzj58srWWMtpdiwvNTanw+lEQRGf+Mr0T5VPbFX3JirsVdir5E/5yo8xDUfzDi0qNqw6
NaJE61rSef8AfOf+AaMfRirxnFXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYqujkkjkWSNikiEMjA0
IINQQcVffP5beb4fN3krS9dVgZ7iELeKKfDcx/BMtB0+MEj2pirJsVdirH/PnkrSvOfli70HUhSO
cc7ecCrQzrX05V91PUdxUd8VfDPnHyfrflHX7nRNYhMVzAapIK+nNGSeEsTH7SNT+B3BGKpJirsV
dirsVdirsVRujaNqmtapb6Xpdu93f3biOCCMVLE/gABuSdgNzir7e/KT8tLHyD5YXT1KzapdETap
eLWkktKBVrvwjBov0nvirNsVdiqB17WrHQ9FvtYvm4WlhC9xMdqlY1JoK926AeOKvz78wa1ea5rl
/rF4a3WoTyXEtOgMjFuI9lrQe2KoDFXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXt3/OMf5kLo
XmJ/K2oS8NM1pwbV2NFjvacV/wCRwAT5hcVfWeKuxV2KsW/MH8t/LXnnSPqGsQ0mjqbO/jAE8Dkd
UY9VP7SnY/OhxV8j/mL+SXnTyTLJPPbnUNGUkpqtqpaML/xcu7RH/W+HwJxV5/irsVdirsVZf5D/
ACq85+drlV0eyZbLlSbU56x2qUND8dPjI/lQE+2Kvrb8rvyf8ueQbGtsBea1MoW81WRQHYdSkQ39
OOvYHfuTtirPMVdirsVfOH/OVH5kLxi8jadLUnhc60ynpT4oYD+Ejf7HFXzbirsVdirsVdirsVdi
rsVdirsVdirsVdirsVdirsVbVmRgykqymqsNiCO4xV9j/kJ+cEPnLRV0jVZgPM+nRgS8iAbqFdhO
terD/dg8d+9Aq9ZxV2KuxVxAIoemKsE8zfkd+WPmJ2mu9Fitrp9zc2RNs9T1JEdEYnxZTirBLz/n
Ebya8nKz1nUIEJ+xL6Mv0AhI8VWW3/OInlJZK3OuX8sfdY1hjb/gmWT9WKsz8uf84+/lZocizLpI
1G4XpLqDm4H/ACKNIf8AhMVeiRRRQxJFEixxRgKkaAKqqNgABsBiq7FXYq7FWB/m9+aeneQfLrXF
Un1u7BTS7In7T03lcVr6ad/E7d64q+ItQ1C91G+uL++ma4vLqRpridzVndzVmPzOKofFXYq7FXYq
7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FUZo2sanouqW2qaXcPa39o4kt54zRlYbfIgjYg7EbHFX2
N+T3536P56tUsL0pYeZol/fWVaJOFG8tuT18SnVfcb4q9PxV2KuxV2KuxV2KuxV2KuxV2KsH/ND8
2fL3kHTPUu2F1q86k2OlI1JJN6cnND6cYP7RHyqcVfGHm/zfrvm3XZ9a1qczXcxoqjaOKMfZiiXf
ii1/id6nFUlxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxVUt7ie3njuLeRoZ4mDx
SxsVdGU1DKwoQQehGKvoX8sf+cpJbdItL88o08SgJHrUK1kAH/LREv2/9ZN/YnfFX0Vo2u6Nrdil
/pF7Df2cn2ZoHDr8jTofEHfFUdirsVdirsVdirsVUL6/sdPtZLu+uIrW1iHKW4mdY41HizMQBirw
X8y/+cpNPtFl03yQgvLvdG1iZT6EZ3FYY23kI7M3w+zDFXzTqmq6lq2oT6jqVzJd31y3Oe4mYs7H
3J8OgHbFULirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVTPQPM3mDy9ef
XdE1CfT7nYNJA5TkBvxcDZx7MCMVeweWf+csfONiqxa/p9trEY6zxn6pOfclA8R+iMYq9I0j/nKv
8uLtVF/Bf6bLT4+cSyxg+zRMzH/gBirI4P8AnIL8oJk5r5hRexD290hr8miGKrpPz/8AygjQu3mK
IgdQsFyx8OixE4qkGq/85TflhZqfqhvtSffj6EHprX3M7REfdirzvzL/AM5b+YblGi8vaPBpwOwu
bpzcyU8VQCJFPz5Yq8e80ed/Nnmm5Fxr+qT37KS0ccjUiQnr6cS8Y0/2K4qkeKuxV2KuxV2KuxV2
KuxV2KuxV2KuxVWvLWezu57S4XhPbyNFKh7OjFWH3jFVHFXYq7FXYq7FXYq7FXYq7FXYq7FXYq7F
XYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYqrWdrPeXcFpbrznuJFiiQd3dgqj7zir2r/
AJyT/Kq90fX5/OGmwmTRtUf1L8oK/V7pz8Rf/Ilb4g38xI8KqvD8VdirsVdirsVdirsVdirsVdir
sVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdir3D/nGz8qr3WNfg84alCY9G0t/U
sC4p9YukPwlP8iJviLfzADxoq+qr/wCo/Ubj9Iel9R9NvrX1jj6PpUPP1Ofw8ePWu2Kvj780v+VA
/pGb/C/6Q+tb8vqHD9H8/wDJ+sfvOv8AJ8Phirzj/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/
AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq7
/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8A
l8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJY
q7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq7/nXP
+Xz/AJJYq7/nXP8Al8/5JYq7/nXP+Xz/AJJYq7/nXP8Al8/5JYq9H/K3/lQP6Rh/xR+kPrW3H6/w
/R/P/K+r/vOv8/w+OKvsGw+o/Ubf9H+l9R9Nfqv1fj6PpUHD0+Hw8ePSm2Kv/9k=</xapGImg:image>
+ </rdf:li>
+ </rdf:Alt>
+ </xap:Thumbnails>
+ </rdf:Description>
+ <rdf:Description rdf:about=""
+ xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/">
+ <xapMM:DocumentID>uuid:258006696A75DD118BA9ECF03343FED2</xapMM:DocumentID>
+ <xapMM:InstanceID>uuid:58eb0fda-eb1b-d44b-8dab-63c8475080a1</xapMM:InstanceID>
+ <xapMM:DerivedFrom rdf:parseType="Resource"/>
+ </rdf:Description>
+ <rdf:Description rdf:about=""
+ xmlns:xapTPg="http://ns.adobe.com/xap/1.0/t/pg/"
+ xmlns:stDim="http://ns.adobe.com/xap/1.0/sType/Dimensions#"
+ xmlns:xapG="http://ns.adobe.com/xap/1.0/g/">
+ <xapTPg:NPages>1</xapTPg:NPages>
+ <xapTPg:HasVisibleTransparency>False</xapTPg:HasVisibleTransparency>
+ <xapTPg:HasVisibleOverprint>False</xapTPg:HasVisibleOverprint>
+ <xapTPg:MaxPageSize rdf:parseType="Resource">
+ <stDim:w>595.275574</stDim:w>
+ <stDim:h>841.889832</stDim:h>
+ <stDim:unit>Points</stDim:unit>
+ </xapTPg:MaxPageSize>
+ <xapTPg:PlateNames>
+ <rdf:Seq>
+ <rdf:li>Cyan</rdf:li>
+ <rdf:li>Magenta</rdf:li>
+ <rdf:li>Yellow</rdf:li>
+ <rdf:li>Black</rdf:li>
+ </rdf:Seq>
+ </xapTPg:PlateNames>
+ <xapTPg:SwatchGroups>
+ <rdf:Seq>
+ <rdf:li rdf:parseType="Resource">
+ <xapG:groupName>Default Swatch Group</xapG:groupName>
+ <xapG:groupType>0</xapG:groupType>
+ </rdf:li>
+ </rdf:Seq>
+ </xapTPg:SwatchGroups>
+ </rdf:Description>
+ <rdf:Description rdf:about=""
+ xmlns:illustrator="http://ns.adobe.com/illustrator/1.0/">
+ <illustrator:Type>Document</illustrator:Type>
+ </rdf:Description>
+ </rdf:RDF>
+</x:xmpmeta>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<?xpacket end="w"?>
endstream
endobj
2 0 obj
<</Count 1/Type/Pages/Kids[5 0 R]>>
endobj
13 0 obj
<</Intent 14 0 R/Usage 15 0 R/Name(Layer 1)/Type/OCG>>
endobj
33 0 obj
<</Intent 34 0 R/Usage 35 0 R/Name(Layer 1)/Type/OCG>>
endobj
34 0 obj
[/View/Design]
endobj
35 0 obj
<</CreatorInfo<</Subtype/Artwork/Creator(Adobe Illustrator 13.0)>>>>
endobj
14 0 obj
[/View/Design]
endobj
15 0 obj
<</CreatorInfo<</Subtype/Artwork/Creator(Adobe Illustrator 13.0)>>>>
endobj
32 0 obj
[33 0 R]
endobj
5 0 obj
<</Parent 2 0 R/Contents 37 0 R/BleedBox[0.0 0.0 595.276 841.89]/PieceInfo<</Illustrator 26 0 R>>/ArtBox[210.794 383.14 386.018 517.067]/MediaBox[0.0 0.0 595.276 841.89]/Thumb 41 0 R/TrimBox[0.0 0.0 595.276 841.89]/Resources<</Properties<</MC0 33 0 R>>/ExtGState<</GS0 36 0 R>>>>/Type/Page/LastModified(D:20080827013318+02'00')>>
endobj
37 0 obj
<</Length 367/Filter/FlateDecode>>stream
+HdSKNÄ0Ýû¾@<ãü¶B# Ù¤ Ûã|è ªÞsÿ=<ñðp´xs{D¸Å,rÁPqhþxg|KÛûqÃýÅó'\СÕÇ!L) /¢/7¨70É*aÑH"È\
õï&O^4ú¡ Êv,ðÜ]ß»Ú
Ñë³@ÒêbFg=MÞh±ÁoÐ.pV»ò!á
+^ëôk+DÐ{ââÔ^ÈgQñLÑÊdVe2Y SbÄR¿´ôHÓº6&ë¶4Ñ<KØ1)d?S»¡s°^~¡kVmð Ê|ÀB«º{3®6wÖÑìZ+äºa@õÓlÝϸé9¬÷«Ñ,ð
+§ÿ&:ò«sAëq»b+ÁöC;0°E®Õt ©-Y?ØÑ{ÉÃ}¸Fß´ýÝþ\'ø` ¬û¨Ã
endstream
endobj
41 0 obj
<</Length 128/Filter[/ASCII85Decode/FlateDecode]/BitsPerComponent 8/ColorSpace 39 0 R/Width 74/Height 105>>stream
+8;Z]_Yml4+&4"WoDZ<jAa$LFCXc>1Mo3R%`r"&q<"onY).SaQKM,HGb$`-bWif_a:
+c'OHO<_s^TD!A6l5F0I;.;m+HBlAs^.ohIE1A=s5T9edA.KBGK]Pe_hQ/.YU~>
endstream
endobj
36 0 obj
<</OPM 1/BM/Normal/CA 1.0/OP false/SMask/None/ca 1.0/AIS false/op false/Type/ExtGState/SA true>>
endobj
39 0 obj
[/Indexed/DeviceRGB 255 40 0 R]
endobj
40 0 obj
<</Length 428/Filter[/ASCII85Decode/FlateDecode]>>stream
+8;X]O>EqN@%''O_@%e@?J;%+8(9e>X=MR6S?i^YgA3=].HDXF.R$lIL@"pJ+EP(%0
+b]6ajmNZn*!='OQZeQ^Y*,=]?C.B+\Ulg9dhD*"iC[;*=3`oP1[!S^)?1)IZ4dup`
+E1r!/,*0[*9.aFIR2&b-C#s<Xl5FH@[<=!#6V)uDBXnIr.F>oRZ7Dl%MLY\.?d>Mn
+6%Q2oYfNRF$$+ON<+]RUJmC0I<jlL.oXisZ;SYU[/7#<&37rclQKqeJe#,UF7Rgb1
+VNWFKf>nDZ4OTs0S!saG>GGKUlQ*Q?45:CI&4J'_2j<etJICj7e7nPMb=O6S7UOH<
+PO7r\I.Hu&e0d&E<.')fERr/l+*W,)q^D*ai5<uuLX.7g/>$XKrcYp0n+Xl_nU*O(
+l[$6Nn+Z_Nq0]s7hs]`XX1nZ8&94a\~>
endstream
endobj
26 0 obj
<</Private 27 0 R/LastModified(D:20080827013318+02'00')>>
endobj
27 0 obj
<</RoundtripVersion 13/CreatorVersion 13/ContainerVersion 11/AIMetaData 28 0 R/AIPrivateData1 29 0 R/AIPrivateData2 30 0 R/NumBlock 2/RoundtripStreamType 1>>
endobj
28 0 obj
<</Length 931>>stream
+%!PS-Adobe-3.0
%%Creator: Adobe Illustrator(R) 13.0
%%AI8_CreatorVersion: 13.0.0
%%For: (Diego Lafuente) ()
%%Title: (camera-icon-draw.ai)
%%CreationDate: 8/27/08 1:33 AM
%%BoundingBox: 210 383 387 518
%%HiResBoundingBox: 210.7944 383.1396 386.0176 517.0674
%%DocumentProcessColors: Cyan Magenta Yellow Black
%AI5_FileFormat 9.0
%AI12_BuildNumber: 386
%AI3_ColorUsage: Color
%AI7_ImageSettings: 0
%%RGBProcessColor: 0 0 0 ([Registration])
%AI3_TemplateBox: 298.5 420.3896 298.5 420.3896
%AI3_TileBox: 18.1377 40.9443 577.1377 823.9448
%AI3_DocumentPreview: None
%AI5_ArtSize: 595.2756 841.8898
%AI5_RulerUnits: 2
%AI9_ColorModel: 1
%AI5_ArtFlags: 0 0 0 1 0 0 1 0 0
%AI5_TargetResolution: 800
%AI5_NumLayers: 1
%AI9_OpenToView: -87 724.5562 1.5 1230 885 26 1 0 6 75 0 0 1 1 0 0 1
%AI5_OpenViewLayers: 7
%%PageOrigin:0 0
%AI7_GridSettings: 72 8 72 8 1 0 0.8 0.8 0.8 0.9 0.9 0.9
%AI9_Flatten: 1
%AI12_CMSettings: 00.MS
%%EndComments
endstream
endobj
29 0 obj
<</Length 13866>>stream
+%%BoundingBox: 210 383 387 518
%%HiResBoundingBox: 210.7944 383.1396 386.0176 517.0674
%AI7_Thumbnail: 128 100 8
%%BeginData: 13714 Hex Bytes
%0000330000660000990000CC0033000033330033660033990033CC0033FF
%0066000066330066660066990066CC0066FF009900009933009966009999
%0099CC0099FF00CC0000CC3300CC6600CC9900CCCC00CCFF00FF3300FF66
%00FF9900FFCC3300003300333300663300993300CC3300FF333300333333
%3333663333993333CC3333FF3366003366333366663366993366CC3366FF
%3399003399333399663399993399CC3399FF33CC0033CC3333CC6633CC99
%33CCCC33CCFF33FF0033FF3333FF6633FF9933FFCC33FFFF660000660033
%6600666600996600CC6600FF6633006633336633666633996633CC6633FF
%6666006666336666666666996666CC6666FF669900669933669966669999
%6699CC6699FF66CC0066CC3366CC6666CC9966CCCC66CCFF66FF0066FF33
%66FF6666FF9966FFCC66FFFF9900009900339900669900999900CC9900FF
%9933009933339933669933999933CC9933FF996600996633996666996699
%9966CC9966FF9999009999339999669999999999CC9999FF99CC0099CC33
%99CC6699CC9999CCCC99CCFF99FF0099FF3399FF6699FF9999FFCC99FFFF
%CC0000CC0033CC0066CC0099CC00CCCC00FFCC3300CC3333CC3366CC3399
%CC33CCCC33FFCC6600CC6633CC6666CC6699CC66CCCC66FFCC9900CC9933
%CC9966CC9999CC99CCCC99FFCCCC00CCCC33CCCC66CCCC99CCCCCCCCCCFF
%CCFF00CCFF33CCFF66CCFF99CCFFCCCCFFFFFF0033FF0066FF0099FF00CC
%FF3300FF3333FF3366FF3399FF33CCFF33FFFF6600FF6633FF6666FF6699
%FF66CCFF66FFFF9900FF9933FF9966FF9999FF99CCFF99FFFFCC00FFCC33
%FFCC66FFCC99FFCCCCFFCCFFFFFF33FFFF66FFFF99FFFFCC110000001100
%000011111111220000002200000022222222440000004400000044444444
%550000005500000055555555770000007700000077777777880000008800
%000088888888AA000000AA000000AAAAAAAABB000000BB000000BBBBBBBB
%DD000000DD000000DDDDDDDDEE000000EE000000EEEEEEEE0000000000FF
%00FF0000FFFFFF0000FF00FFFFFF00FFFFFF
%524C45FD25FF7DFD352752FD47FFA82727F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F8F827FD46FFFD3B27FD44FF7DF8F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F8F87DFD43FF52F8FD3927
%F852FD42FF7DF827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F87DFD41FFFD3F27FD40FF5227F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F8F852FD3FFFFD3F27F827
%FD3EFF7DF827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F87DFD3DFFFD4327FD26FFFD16A85227F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8F8
%52FFFD15A8FD0CFF7D52FD73277DFD08FFA827F8F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F8277DFD05FF7DF8FD7727F8277D
%FFFFFFA8F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F8277DFFFFFD7C27F827FF7D27F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F87D52F8FD3527
%F827F8272752527D527DFD04522727F827F8FD352752F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F8F8F85252A8A8FD0AFFA87D7D5227F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F8FD3227F82727527D
%FD14FFA87D52F8FD3227F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%52FD1AFFA82727F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F8FD31277DA8FD
%1DFF7D52F8FD2E27F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F82752A8FD21FFA8
%27F8F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F8FD2C27F852A8FD25FF52FD2C27F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F852A8FD27FF7D27F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8FD
%2A27F87DFD2AFFA852F8FD2827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F87DFD2CFFA852
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F8FD2827F8A8FD2FFF52F8FD2627F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F8A8FD31FF52F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F8FD2627F87DFD33FF27F8FD2427F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F852FD34FFA827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F8FD2427F852FD16FFA8A87D7D5252527D
%7DA8A8FD15FF7DFD2427F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827A8FD13FFA87D2727F827F827F827
%F8F8F827277DA8FD13FF5227F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F8FD24277DFD12FFA85227F8FD0B27F8
%27F82752FD13FFFD2327F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F82727FD11FFA852F827F827F827F827F827
%F827F827F827F827F8F8F87DFD11FFA8F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F8FD2227F8A8FD10FF7D27F8
%FD1527F852FD11FF52F8FD2027F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F852FD10FF5227F827F827F827F827
%F827F827F827F827F827F827F827F827F827A8FD0FFF7D27F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F8FD2027F827
%A8FD0FFF7D27F8FD1927F827A8FD0FFF52FD2027F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F82727FD0FFF5227F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827A8FD
%0EFFA8F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F8FD2027F8A8FD0EFF7DFD1F27F852FD0FFF52F8FD1E27F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827A8FD
%0DFFA827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F87DFD0EFF7D27F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F8FD202752FD0EFF52F8FD2127F8A8FD0EFFF8
%FD1E27F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F8A8FD0DFFA8F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F8F827FD0EFF52F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F8FD1E27F827FD0EFF52FD25
%27A8FD0DFF7DFD1E27F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F82727FD0DFFA827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F852FD0DFFA8F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F8FD1E27F8
%7DFD0DFF7DF8FD2627FD0EFF27F8FD1C27F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F8277DFD0DFF2727F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%F87DFD0DFF2727F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F8FD1F27A8FD0CFFA8FD2727F87DFD0DFF52F8FD1C27F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827A8FD0CFF7D
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F82727FD0DFF52F8F827F827F827F827F827F827F827
%F827F827F827F827F827F827F8FD1F27FD0DFF52FD2927A8FD0CFF7DF8FD
%1C27F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827A8FD0CFF52F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F8A8FD0CFF7D27F827F827F827
%F827F827F827F827F827F827F827F827F827F827F8FD1F27FD0DFF52FD29
%27A8FD0CFFA8F8FD1C27F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F852FD0DFF52F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F8A8FD0CFF7D
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F8FD1E
%2752FD0DFF52FD2727F827A8FD0CFFA8F8FD1C27F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F852FD0DFF52F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F8A8FD0CFF7D27F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F8FD1F27FD0DFF52FD2927A8FD0CFFA8F8FD1C27F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827FD0DFF
%7DF827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F82727FD0DFF7DF8F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F8FD1F27FD0DFF7D27F8FD2527F852FD0D
%FF7DF8FD1C27F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F8277DFD0DFF2727F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F8F852FD0DFF2727F827F827
%F827F827F827F827F827F827F827F827F827F827F827F8FD1E27F8A8FD0D
%FF52F8FD2527F8A8FD0DFF52FD1D27F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F8F852FD0DFF7DF8F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827FD
%0DFFA8F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F8FD1E27F852FD0EFFFD262752FD0DFF7D27F8FD1C27F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F8A8FD0DFF7DF8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F82727FD0EFF52F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F8FD20277DFD0EFF27F8FD2127F87DFD0EFFFD1F27F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%52FD0EFF7DF8F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827FD0EFF7D27F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F8FD2127FD0FFF52FD2127A8FD0EFF7DF8
%FD1E27F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F82752FD0FFF27F8F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F8F852FD0FFF2727F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F8FD2227FD10FFFD1E2752FD0FFF7D
%FD2027F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F87DFD0FFFA8F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F8F852FD0FFFA827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F8FD2327FD11FFFD1827F8277DFD10
%FF7DF8FD2027F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F82752FD11FF5227F827F827F827F827F827F827F827
%F827F827F827F8277DFD11FF2727F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F8FD2427A8FD11FFA852F8FD0F27F827
%277DFD12FF52FD2227F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F852FD13FF7D2727F827F827F827F827F8
%27F827F82752A8FD12FFA827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F8FD2427F87DFD14FFA87D52FD0527F8
%27275252A8FD15FF27F8FD2227F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F8A8FD16FFA8A87DA87DA8
%A8FD18FF52F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F8FD2727FD34FF7DF8FD2427F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F8F827
%FD32FFA8F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F8FD282752FD30FFA8FD2727F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F8F827FD2EFFA8F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F8FD2A2752FD2CFFA8F8FD2827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F82727A8FD29FF7DF827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F827F8FD2D27
%7DFD26FFA852F8FD2A27F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F827F827F827F827F827F852A8FD23FF
%7D27F827F827F827F827F827F827F827F827F827F827F827F827F827F827
%F827F827F827F827F827F827F827F8FD2E27F8277DFD20FFA852FD2E27F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827277DA8FD1BFF7D52F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F8FD3227F82752FD17FFA8A85227F8FD3027F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F8F8F8527DA8A8FD0FFFA8
%A85227F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F8FD3627F827F8
%52527D7DA8A8FFA8FFA8FFA8A87D7D2727F827F8FD3427F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F8272727F82727
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%FD3E27F8272727F8FD3E27F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F8FD812752F8F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F852A8
%F8FD7D277DFF52F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F82727FFFFA827F8FD7A27FD04FF7D27F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F827F827F827F8
%27F827F827F827F827F827F827F827F827F827F827F827F8F8F8A8FD05FF
%A852F8272727F8272727F8272727F8272727F8272727F8272727F8272727
%F8272727F8272727F8272727F8272727F8272727F8272727F8272727F827
%2727F8272727F8272727F8272727F8272727F8272727F8272727F8272727
%F8272727F8272727F8272727F8272727F8272727F8272727F8272727F827
%52A8FD08FFA85252FD7127527DFD04FFFF
%%EndData
endstream
endobj
30 0 obj
<</Length 21485>>stream
+%AI12_CompressedDataxݽ÷zòº²8üÝ ÷ ½ÚôÞk@F(¦ÖÚïùã\û'ÉݸQÖ³öù=ûYï¶<#FÓ4#YLí'7Ý OÀ
K$F7¢§ÆÚz}¤$|dvqÐ
+4ÊÕ¢C¦áARËÝ6^¡eøµ½¸$æ;cc4;Ûá0ÚàUwyXàåd´!Èg9Ùm=Srô·w´t°¸°âè ZE}þñx `Ì5Áûüî¸.·óüî?q£Çh ü1ð(x]]>´7aC/
Áa/GÂàGà»ânrÜ^¶ÉÝ ¨Ân½#©¸±ðg´56Gsðfdëõîoc~=¬`ü¡ay¹&ÀP7£1Ç«áþaþ¸\O1h pÁÇ!Ø£ ( þ
Gµ
xÒ!Ð]Òî¹ö<Dÿ³¿?ó%@O
¶Klök@*z¨±¨7dú1o
+Æ)þÉ´=Fmñ( F$bb^@1Тþ |¥Ûót!þZÇ»-A>G:Ëÿà ÅB^$6F¸7Eé÷ÏÇ5Aö¶Ë>ÑDhî¦ÄtR^ÐØÑÿpþ_ºAwDÎÕÝúx@\ÅWÈÑNN#hímw÷zêLñ½¡PØoÄ%p 3F£!£?ÁJ
@ vLJLS\ÎÛ8ӳȰB.§üÔEüÆ(ýæ
+þ±ÿѽ>-ÓkÀ2
¦0o³0¶ÓÂniOA¶s¿l±ÞÍéwÜßè
øü¸§{~Á4µÉåÂ4<¢7Ña{}¯*ämg;^ÞíÑaØN)°DégôO#ýxÚXþEÐÏÀ2Ý;TáuÉÑ 5¶Æ?Ää >fðuË¡
¨3d"yòH-ÝÝnÍõOüë&ó=
íÿ;p´ÑÛÖ¦ô)&¦XÿuX@keàå3ôÂh½^ÎÉÑ~±È!yÏa¢ß¬qà¿G?Ùÿ×Á6ãÝzImxn<iÈÃr²&:¨±ÑV$f@I ȶëÝ^ÐIîÉh;5öGä^
4¦Ùr;+g»Í*`cg1Ú¨»Eµìè`ãõh;"è9À¿@EýÁ(}ºLÑo &;üYÁWßîþޢƸÁþ(7:®£ïØ+F·Á×YK°M0cËqªþïu<Ña~ ôÃh0£?°P©
qæ«×ÕzàÇðãüñýmÆ÷OÌ8O_
üÔà£)0} àÿÑHÀÐùqh£=ZC ¾·Çú{+µBа_ÿÇpb´'vëîÙh pÂ)8&jpÉ´ãý^SÌÿÇ<$3}eÍ#`¡ý
8þZN 5FäÙß°Ñ÷LÖFû~4: sYÑòÅhߨýgQûÝAÒj$ýX¾@lî^úQy2ÙIúI,¨1w<ìÏ# ;H`¿I ¡÷`ÝFj¹9®Ñtrý@à` Æ»95N EG¿÷½6À¶+ÀüÍz^{"ãã`zîËä¡Ð?âð&`èCþì[øÏáÏ¡¯Ýº¥H*DI@¨é_£õmS
+í¶@qÉ4tÿ§Îx6\q µûÈ M!aë1é¥cÜÏIÇøÖ»ÉêÛòFÓåèqÕÑë×åh¼&ô0¾æLþ_Zèñ¿t/uØô_æb8¼É:ì6ÿ®$ûçø0N
U:zÙñ_ /ÿE]ùaR³¿ÿµñ¿¼¨õrò]ã7æÄX3[i¬b9_èY]\ËWãaôÖÔßËéa¡gLLÃwHH4¦9¤ÿèZ
ÿöP¸}ÑüÑ3?ÿöh8ïSiãÝ
bv ããzFuúÍâG¯³;m ýëè§»â0CèÚ~Ä®ìÇý ¬èá.AcIhÇì;ãÚÁ3ãnk í D°Æ®[çhÔ XßR¿Úïlw<çt$IL¼u<ìAuðáP(R¼qÐJ~A³9ÚRûÉÐ
åÔHq±Ms`'.äú£ÊmýôMÏK²fg¹¸h"Ú$Aä_±Küç`,MÑx¹^þp³Æm¹¨ÚF36FÛùq4'íÝ:û{.ÁüÀ po» öcYR³ÙGtF>Áõx«µG$xjË0ØAØaù¶°!JñA:ÅD
;Ç1À]ÞmÔ3d´:!!¨ui3&àãl¹&¸¸\Ëþb9YÈ´äf3Î8ìÙ9ÙýE{O¥Ô?¬{0ÑÐûè9&uºê_·^n #u w+Bgã`ùXÆ6%Ñ"õüELëÆ£õh;á$ ødGN)«êÙè{ÜD¯EB °K©Ý16`/àþÜxA«.eà7-¦ó]¾óBFMTÈì7æjZýg äãu´ïg7öõå©T¢KíÁ²iNû,mFû1 òÊ¡$À)öNâFëî<ìÆpsÉtJH
déH·1á¾;òBî)¦y
MPBÀé¦UdºqÅé¾vªö{ÒKÇo' ¶ÒÛ.¸
ØAHÛ ¼hЯÔJè7ÙÄdjÿ1Éå_pæ¤Tú=¯ß19IO ;"GÔ)O¦³ê}<(êÛ)À5éݯÕ:FN½;rîUí<Óæ¯1/mEMFk
¥Ùî/£Fûõä2§Ðm&[J¤ Íh2ÖÄåÊùfå¥à¦F`S6r·Wîòl{ðN×¢)mCÉ* ò®ðY«ô
òpiª6Ùs ÿR7dëövTÚ¬ñ ²NLMI;j1ÂàUl+¨ù¶À°H<a«ÿì½"=(GlÐêpå»ýd§ÑR:j0=c¦I>W_Àää8n'ºj=ÚnÙZyEZiIáÉF 8ì=oÇkìcca´ìÔøaïô[íñ/¿z =m½I Þ%ë2Ô`O
$2jOàS5«P"eµ1ágL{~ô|³BÊ·º;µêNO÷UÒyKÚ Äì ¯åZ¡HD½%Éë°(&¿¹¶t¨ESwîf38h5[HÉÚdSZη#í*ÛMí µh6°°j»5^6#ÒmÈS+[VùÌLÀPé*lÉy6c%¬®w$45Î]ìÈÿaØC¡Õ~G-E°¬ÐÃõh¯mm0íT,¤m-ÜÒ·~hõ?z¾SvyãL_¼~y{6KÊbkP¾ëÐY÷@£)ÈlÒ2=`Pb<")âòvXMù £1'"t´%E®Vk¡+6ßÈ%îµÆ\¯u´ôZGkpS°õöäl·U[¸ÈÂRÚé'6QBJ
òåZÎõ!hIÑRèpâ¨Ê·£C hõʪÚþa!¥tg²ù£&ûø»ÃBÞqϱͮ;.ÌQÛîø(q¹EQ"( Y¡"o
+uȵ×cÛ`0ªÀ£
Á(a@ 5Õ@µÃÚ£¡*Ã^í¨ÓiB
X@HÝØØÚCX±ÃÅÙ,ßbé"í;ºt~\ù%ïÈu
+µZ4T$ î/õÝì§lÑ«û!`myòY²²YÄç[ÓCÙä¶Û
+Ë2{ÕRø>íUÒÍ`&Þø°5³äq)üͨï1*þçnÌM|yÙ¤{Oe©ºßg°d
É6z8äçÕ§F6$:
e*=)z½¶ù ªÆt ðEeK<òV9>óÁ7;·Ù5¨\sX¸Òáûc¹4÷ó?k[ß`)ΰ±,0s$6¼<½äºï2Ra»øg6¹*fãwã*º-Dz½2,XåïaëX}ö#ùuvýåÂ"òÈñm-NðÆo6±õi8 ËTákþµYµiÍ÷D̹ç~K÷áu4=,±»kRì
EpHæ,«+ÿèþve¶^¹@éûEb2à_KWiÖXÐqÌ7Ków|ùõ0ͯ-t}sõößM<,K8ñòÍm'¶+ÕLø"Ô2ñQ³@Ôp×*s'Åê-b#"ý 6/¾_¼²{ÜD~ioèl¡¼ïܱæ¥ö¾OG
+»/Wòeú÷ï?ØôÖ;ïá¼ûá§-¤S:¿r=k¾Lþyß,úFIkÙäz#!0|ñ
&6¾«Ñß®t9Éüìêtó»ôMóü5Àº¯+.¹ýÅÌ<ÅÀé§éÏãI®Ã ^+b°Fù®|p{ê6"èYÈ/© ßÂ?\·øã*Î|õßÒhd3çÃãÞS¬myíåZ
|»8ë,³¿ñ¹ÁºCoáé[i»^òÁ×\«\üé˰/1ÛXæåÂ̦¿#çéÇíünê¹VÃY/Ó:MÐ4ïÙ?ì½O®ÌËèP:eÝÃ]®ûp8MBYØx%M,¨X9ÂÁ`)½M-sÿw2SÄÊÙ bäw²\Üát»ò»Øt®ÄN,;4çdÔQ EH§F%7|ÀÇ$]ûÄwÙ>«{sX²ûæw¿tGÄäcDÙnÝ;
+ðóªäjxË<§0ØA Ó)M!fÁ¢ÚXÁÐî
ù¢DEÞs.òæïKç ]]¿`ßUJ÷8&7%±Q/,¹nsê&+æ\oQKA»Ê 2¦äÇü`ósí²£½N¡7¿+]ùö,ü¸À¨&³r©äÃÖ8^¼úâFH¾ï½3ÿsnòëíË.×]¼º°/¹wþ²ÕyÏ=Ï6ðÙ§5v5´´tg¶jôv· ¥`éåµÊp þÙ
³óÔ+ðßÅqpÑÏõ,JÜÎ{£?kOI4^ ,üûÝ̯ìûe9YÁíÙþöì it@XãØøX²§~û¼¦¼l?Dæ {Dçä}ôÛ¨Q3 ±'÷¡<~\¿ç:ßæm,÷MV^ÐäûH5¿¹Î±äߢÆ@,9[éÙ®Oß i¶çÙÜ¿z¹Õd.A.àB#ÿJc<
ãxwÛîYÿÂ`á[¢§ðgÂúýwþ'ø6EÍ"(ÀgyX.é)GBâ³ø¶/Á&IÔþ,,\÷ò°Ñ#ÆñAd¹Î§¹/¨ ìMunuÄ`Aä;iW]ø,ñX)Ø.K¢¼
û}ïÑ02<)QsÔ=Ûyâ#AÑÃL}ñDÉLí!ý
$
ÑILÿã0WdúKZ{Jè.£¿84RñO-äWbE¶Ü¨xV%z8ùX)z¬hå°äHñc[rD¬T)ba"ÄÅ 2âÞ8Ì4OK¢ÆüªÌÏhVÓ<×¢æ9¥àzØæÍ¤è³öØóIÎ/ä2Ãcr
[ç±!=%Ü¢¥%êãs8;Zè/üp¨óð7±éçÌu_êÛrÖFt¥?óF,·ºrÞ(7ñ²ÉéZ+Êj{X.ÅU¶ß_Ãli²úµÒªL`NmewFhv¸úȾءA-Î=múµk^Ǽ-ì>ûb³Ç
+ãó[±^ÿ͹çm±í|c`Á®³\Å
|ø#¶&=ßåôïÎñÐ}iâîúòa·ß#ðñüx^$¥*o[AKéáã ÃXaÑÀuÀ5
¾ml]ÞÍhóìÀk|æÙùÏ9Ø/`)k=ôvs¢Ã5ÒÎ×±ú8õÀ¡Ñ.³È÷ýZñJtí%«Ìô,+Æ>z}È#3§êÿ-Ï9Ò¬?Uý(Öóa@àç²ïÎüåóÌa(*"2tú"íÓặXûx²Ï!n[¼¬Ý\«WìV'Í|G
+épØÉ-J~¿#ëß`áíÿÓbee!ÀòzJ Æüå>TöwãXÌ>Á6¤0\gu¯ç¿øä9Óòg{¦ã©v Ö*¨áôûßV÷
Å):<²³ÿéÃõµ_5]ÀiÏÜCÇà+¿ò§LüÙ±øt³Æà4=|äp¾,}x9(ò×§ó¾\ÚÁªô[b(ÍYn³ï=4òOí,ÐÍ#ÓÑãÀ{zì¼@_}Ñÿ 04ÞY±Èê8nc½w]¡Z)Á̬J î[c6X8,gIrÑÆýBÀ2oèݰY¬PÀníóÕ|ðÇpw2æàý+KÔ=Ünð×»Ì!_¬äÎwÕ²ÓáqÕþ{ºÚé¹\:L8Ò@69þÚfûO.k|áê,òý >Hç FÕS| ß4r©¦[rëWLßêõsV¤aFkýø £úêt®^à
+îf
%µÃ¨çý{(ý$uxù°O& ¹ÙÕ æK}Äñ¨ ØüeÇ }ÈÕøÆTýqZnbnùìwÀOÏ`ÅBõVF)í¥tô¬
+Åo+ÁЩÚöå×Þg ílÙa°Ð{ÑÏÒðËò:?7eó_vNc-8¾R7l¶ JÄjPçÌKcßÛRlà ý|wF_7æÀRôûXwÓ-#É@(}µÆC`$ À9JöÚcO@üõ£´-À ÜgµXÛ,ßó¡WoîÉÙç».àYT,ÏH~
OI¡©B+¯X{o8¡±ñ éìÈu>Úµ;åá½uPzå×Q³»ø`wØqÃ}dIÌ-+À±»ÄÌÜYÈ
%úL\ÎðL¨Þà\íù¯ìùpà07ÀÏMáC£ü89ÔõzD¯l&¬ö^I2 8ý"´ÍÙ,¾´=5IçΪSnh¢v!ÁøÜ½¨5zqF'¤Iør¬P-þ8O,KîÝ$cÏuBåÏÊæà´Áv?¬9á¢{
+èæ6d2á×Já±ðð³{AÞÙüû&9û+°P·¿7XÐÌxÁú¬Ã©òo5Y\7B¼ÌLâ×½©8ë|ï
+Ë;s0v°Û¦k;9ó®µìcÍϵâ¥z6ß-o¦gI{ôÄP&gsÏécqûöÞUBÏØië½ÿ5Èí-' Y8s ýüà;:© ¸$
+ä$¶Êº¹HìÃâìLo«÷åBîs^.dçÏUs
+¯åb¾UN¾IÎù}éÖFådñ è
Ä÷wÙxg£{râ§XCçDs¸¨½Ð;RÚÌCIVÖÍ+©T~ù}K¸
+ AY¢`þ pÇ5û2ë°ÓácÑû<õdã?+qþéïÊÛ³õÂ-×ßô^ó ýDä·}âë%5£Ú:«_UtË¥¤Ãlé^üæ7tè_îúZ½AK)ÛZ©Öõg]8{Øl#X5êó»b)êYòþëPíH¯ÃÆÖ;àÞÎk¹0ËøåÃø/Ð8À@,mbͯ?KÌZ-´
&F,LÇ`'/o6Q¶×¦}è\~@ñZ$_ÐU8ºxÝå 8íhLôUTùɵð| ¸ÙU6Þß×"k¿¦>1ÊýN÷¥\ÈS?Å¡~ý]YtWnlKÐ`öx2IJå"fÌÁ Ûåfvy,òõ¨;°°y¼é
+ MÚµtTÛÓó¢Äø\ð;EÜÝæ0¦üê+Md¨îÙÆî4èÂ4#UÙ5Ú8d¬WêáíA@ u>óëHÖ\ f#37"Î#ÏqÏ,Ir# U_¯÷ßç1ÚÆXÒ&´àaúEn="à®Ä=ܬÁrϻơènýNYKiuäz-Ô/µ4¹OÆDKÑçªÔØø>7£m¬Và¶ÿy[HÆh]ò¢ÉXTlD¿äjÙ\_µvé&Xu3À\öÊa6X8Üýlr]vmp)°òºKø·ðX}#
âJSo1^8i ²?9ÐCyô-ïãIÆ ek_ÈÈð:yrÑ
+u[ß²ýÁóRÀ{*AÄ0ægsúw¬H(3B,-¹èx?¨$pßFU`ëí°ÄìHRÑ»s}/¸aÄ4Køu½Ý)³sÀäcwªÍ¿aäô":@? اïöH²ë¸³`^æÎbÎÒäx7ÌE=Þ;h%ìÔÑÈWÓiø¥÷ùd
+ÕÂâ}z=¬»lò)ðU¬×wÜf±ô3`GÖR6ñÙfgäÉ
ùÝ¿ åßV@çÎö¹çu¨/£×,åx½+Öíïó{±V¡ç!©T8ýë|(N
+£UѹôMNd'®8IÅ ©Q2@û-Òý¾'¡ÃåÌ&¾°ïð/F-¬7*úÛVW*WuÞÍõóàç
+LÓ!+JÒMZ¶Ï'Y±æ¼£# ¬°*ŧÓI7þø5>¿?«0Ù Ìú &Öà>¿*Ú~JoñÄ ÕSÎ=H=9ô·Ë¯ùxåð;çêý|Sø>ÑÚ)p¼%Ýz>u×RÅy À˺ßI÷±8-¹¬^ÏM¹P*WÈc0¡ð]lýid#wþåóòtTñõw?E_éÇD"ÀÂwj¾ÍOrzî³Î`åôü~ -NÙ¨ÃÒÆíûð¤Âʼ
ó°ùÆÈ/Má^þOyνÃPNE.æ
¹ç¹nr>ìé,&Qø Ͳ
¬[«äh6#/)'}Úu¦&
+óp<o@åeY«È 7ÄÑÚêÂØ3K~VOAQ°©û
7þ¸Ù>îËöz>k¿?|&k,ÒÙÙµwû<æÄl]?÷T öú3Oí\·WxîýÇ0ò%sék
/ .±ËÛákñsþq³!(ÉBl°)Ö&v;; çìEßk6±y'ô§HvñHP5ù¤¦²µÒØ»r÷¦
¿X4ýEó{#LíTÈTpâÀª«R($Ì«Jk-}¿Ï ܽ73PêÙßüÊþùmüoK§ÃQM¾@ù¤SÎ×.éó»¿·ôGÒô?¿_.×\áctun¼cKÂZ
+jëËíT9±Té«§ãHP:Ð
+9úsé8ÅßJ©Öaø¥bU¾kî¶»ÉÜm/O"ùcµo¥ã
ªÒ
+BPoPnÙ¹Mèf¿m¡Ê2ø8GþÞ«z¹âwyLvÅ/5rÏ?ìîÎ:%@&¹ÞÓi±²»âu !H8~¯ãtÙÊ?ýµñ
+\®¯Æ_ÇDzåþjK="7!wãÑ>â]õ3¿@ôÀ¼zÈÓíÝz©VË~ÆPÛNÖGéwe/,zúrN½ÖNãû F?EõEµ)¸-¹"¾wÁÆËíÝ#<6û° LibNÆ7þ½ ¶Fjô6Ú
+o¥0ÂÁG|Ìç³G±x=
+ÿýÙ{ÀFÀøQÓàæ£åV¹ ÷é Jö° &qÊFÆõè<öe´ßBÓ:N°{µmÕÆñ`hl[°8 w»~IÛ<Ú«o è ¹Ü«WðË UU6G@x zÒ«ìy¡~õ-[F§q¼ÊzéFÛéÔapçAjìó¯ sW´¡çaIVc)8ùBY¡¶Ï
^bÀÂr3õÙÎóel
+õvló.¹Ü@VêWPg&Ú: êS»/fì
+4Òþí3 HÍ
f¼¥#<
[±õ31@V]dÀrªqå
ª"ä×Ñè.ñv´\ëÐdb³_Ú<ÐÝ©ÇrdJ½Oá=(Úö¼ÄÐ=§3BsMmy
+P
)}Ä>s]Áá:Esý^Þ¨³Z0b;4B¸ $ç;©
ðþ~OèL¬u#PY%Z¯F{úü«%k%·|B[N³ïNIþñ÷5}>¬ cßPOdëµ\éÐwÄyû0«éte üËL>ÅÜ'î/ô"Ètùâ,VYUïS#¸mæÞú]©çðÂäTS&Ïöl°\éUÒäx|Ü%xõ=ó\ÇxÇän¾M¬éÇ|©¡Þºã)Hù©&è\qÌ´¾Ó|4
¿
7o(gño±ê(,$NsîýãC¶£ÒÑj²ï-ïÞ/%òã
+¾Ýr*àÎ\dË` \óàkKÈhÄÌb'I&¨.@â®a¾`ß3*Z>¼ø¿v++6µâsK~bTÀ]éÉæ¥¸òú¨h%ýMü5øzP#ý ?OòH+¯P¼öåEúe~l,´<Òð²^±È#Mì$
[Hy¤mü#xç;y¤²¹¤¡
}dä¯Xs6eÞ§aÅyv<Ê+wûE¤á{K»Ë)!ýÆ*÷o=)ªoäÐV<Y[mì}%ðÇÏ(Ì mÛlòõ!¼8.çt 8ùÓÿðÑ:NgÕûL5.4¸;a¥¯dYihݺ;ðHyN¦ÑÈ/«åEiyÞÚÂY¤Tî3 ´
+(¶{ìäǼ³S¶CJ¿qÃyÿCc¥4`Ϫ¹óB&äXù³ú,;Ò»2°¬|/9¤Vqƾ·ólKa¤&IíÛfÔyBÞ§²3É ido°HÇÚäÒÇ.Aî4V/4ÒÒǪ,é[k¼BrH
ê®úKEV÷OaV´é$H³«a!§ôÝuâ
B¸îù¨O ÷AigI("}ü¨>äåBÉ|/`/¶×¨,ï÷ÇÎ|<Ê"}ià;E¤½¯²FH
±Ö±} «4ãxùêçdö3c§R !Úá0wè+ø#}¶ºy¤ùÏk1éEúyð>!¤P¿uÓvY_±áÓoRi+ë ßsTAîâC´¥OXÀѪ©ÿ5h¤£»CE¼h2ä±ÿH]'¦up|7C°*§Ö)ë·óÙÌ ]ÅMcÅ!ÔoKÛ«b¤^?ÜC¤)ÀÂ×ôq.¤YêD~ìb4Ò½ä×+·l4ÒÏCüAD^GϨ¦ Öw*
+{¸'Ò°þ ¤å£)¹Ì8¤ñ'¯x¤Õ^ÞbM"¤L¯Ñ@H!z¬÷ïThüÞH±?Ƭw¯§@ê?Îdn¼í¹,¤üÛ|ÈäA¯ññ ûþ82%±Úë ðÖÆGTû^î-²ÛdÉð©·áHÙÃ÷'lsW]ìYU&÷vKFZÕä-7ûÕÃ!§ß"ò_׬¦l«_zRx{HÔk÷üÛ:öi°4\®ÐQá}xøMm
+oë³v<òâ}}|ÃYMêwËP¬¹¹ô¾
[{£÷RZámÒþRHö³·ÅygßL.ó
+_WÝÃB¸û!ÿ¶+ÿ¤üÛÇg ¨aÉ¥ðþõg |~
·ßgEDåß>ÛáçþVbÎw»O¿þ¾°òPæíèÕºsGÊJ#^Ë»!ÿõû\Ø~jw²o-ý§éÝô{K©áÁÈ>Ùíð½÷ô½?_k=å7ðí"sÃ
eú´eß¿ãv§%iúFoO(Þ§Îlß9â¿NïÉ=çñíJǪæ$½°êw»À¹f9×LèYõnrû&÷Ëð+Ó®Éþî8¿ÚÐÿ,<õ!°
^Wú³tj·½éd>³¯ÝÚ;úzDÎòfIí½o;
wWîO,7É;¿-Õö0Îy'TÁéû ÿÚÙWB½/Dt|(#½+ybå|¸¥4|¼¤m 1äѾTVL!e¤
+9à u!@Þÿ,ÒÊZLàO!Ò`Ç,$ïSöYtjµÞóHĺ÷È£rÛ^ip0PFzWc¢U)F|¤À¾ÃX éH)´Æ+X\q¬È"QD
+íyÝ<RÚºµfÌ*î¶Bþb&âñ8ÕÕ®uOHÖ¾BË»Vʤ£y®,iÇÌIËïdé¯ÝvW~G=ÒÜþ*@û¯ÃR[ñÖ3 qÓÍüÁá~eÐý,\Om+¶÷ÓïÑst4¾KïíÓ®4jÐç}¢hÿÜs0íýy/âÎüO6
+Ð x±N,däím&%hܶþ²Már±Ðeì!d± 3
¦g-nEWz¨
+( {¥×?PsZ/Ê¢$t &zºÑ?4=éx
³
+h|1g®qÔ&:úçYèË/×rã3X#Dÿ^r3ÈÏ_ óÒmjÍ»Éðô ô6áT'þù«t¶`,gKØ2³,:Ø'6³ý¾êå,¯8 9k̶êYW¢»çä«)?¦ÔénP#DôÜ[©è)}öBÜèÅ¢Ç`ѯ^ú¤*<+u+cÉ®ÊÒGë Ú$ÛÝðwaÐõv%èA×åĶòªt(-`NÔg
M¬ÅhRÜkÚJ¯!¥`ÄhØãG%ä1ѨV4*y1:pïÅjBc@
+¦ôQô$·E|m¯Ul«§)]ùøEdáâÉf·¿)ié'iÜNv© +xßu V(ûwÒu7ºküêXwê«qò¨Ì5RKwÉMÿÃ̾gqàNn:¡¥$Pø#Q[7FwM\7|+%éâäø¯BÏü¿þü[ìA~î¼]Æ
+Nh/)½î%S¾îª²V¯è©@{¬m++(&-QÄÓXª
+ÔÁræü®¢Çó'ùµ:?6©Ï§Ù¥Ø®äû£Ã¤ø÷J]Ê2k_ï*tmª6¿hµL:ýóGrª*Àrò5À¦¶QI½_^`Z~Z¿D{âÏ?HÞª»ÅÄöJ%ÚÙc"[£ùó¯ØqÂ¥R:ß:æûâü°?´ä´òrl^U4¯
[ÞV¨J=ñ+Vå¼êÿ<æëg8ÊônîéL26'~>uô»}6myBJ{£7 04Å¥õ¢cÔ\<IGhKI¶+ZR@OG¤¶åE4ÑZölGXXRYÏóÉé-M.Ä-Ê!ù£MògahÛ^<@!¨Q£wx+g
ܰ;Å.,guêBÀñ`ÉýÔn$ Àø¬çúûãËÄê$7è$zñÀÛ
+ºâ"K^ëóRü6Lä@n õz¬SÉ'ÿ©a3ün ?
Ú3X<è]ânã%Ab
® Ö^(2¾SÉr8ê𺵣KÒ®!Q% ;Ù¬ÞEûý$B0Ça @Ë)Ö}àíwÏ v½á
(ùåÐÃZ¾ ¼±yÀjÕ7XbzôpÔ£3hD鿨oP/aɰÉsb Jñ@¥xrSiÒ05Òu©)-&¾Á¢Ãfæ þt!íX{îò%,¢Ý¾.V±/v"?Ý`½Ô¥:ð>?Ð[z¿òÒht Ó³tÈ ÎéuÒ»H ìë Dß]Fõ`¡áTÕ)ز:óôgËÒöXÕ9ì.qþÕkG}Ý©¯:1'!|õþ¾{$c>ÙÕ¯À|zÖÍcêñV»V&˯äU4k**O°Ç§
GìHÑ~OÁ¹z"(Ò½@&çL½'ð÷ewÏR¢¢ýA¤;[©K Ýjí#KÎÅØW¥Må=>%#⵫óÓ`óÏ9æh½ó%R¬H4j%ÝÖoÁË SÞôau¥Î$̽¥T .BçîÚµßh¬ýÞùM.và\/Ñz·Ù{Ep[gY8ô|}h¢-Ú:·Q8Ûé
8Ài§$©Koâ«×EGZÿ<N9!ËEàϳ Ø9B}E1;Øý ]Ì3ÛoÐ`¹Ú@).}FÔ;«7è[ÎÕ)¬%xºó® Gyå(ä²» ØQ?5]èfbbmؿƾ1éÇ/Ò
×y|ÐÃÒP`ÓÖ ÷QQ< ìêKÌa¾^õÏiÉj±þ5ö½
+£¯Òb}9û^Á¢ G6T×
¬Ý5ý×hC.)án^2XNr_.JG£Ó
¼®&Oñi¶ è×¢;*"%Zêè,hX:,]V&`º¤K
+iETeb[Þ¤¥¥¢Gôªs«í¥ ãcÔª¯ åµÓé¤]_¤4'ëX^ÅäQKEµ¤OVTLcJÅISÈ\Sö÷Ò\z%RêX\ÀÏ¿®Ô}#½)o êWªZórÖî
vÐÍÄÓOVÚÏ$ädQú*0£àõ©$ߪOøttJ-,¬²¸8ÌÄxN
+Á'<Åþlܬk<QÏP®Î`¹M
zÝIÅÐ
5têt´÷z}
zZµà95têtâjÁËkèÔ+èÛÔЩWÐIª/®¡S¯ 3XnSC§^A²;nPC§ÞU?Ý N½N
»¦N½±Ç´kèÄ ÉÊf{9k[5^¹(û{V"½m+©¸ÛuÔK ¬¾+3kÛVPý^@§ö9¹äÊ{|mr¦ÙYt:²9Í4sê,sé¢÷øT¹¯²`µ+çôÏ«µ^t]²£Ý%åÊG0JNKæ`tôÌ¢9}²fà,kQnÏyTg¤Ðk_)ä«t½9:wT¶è¼¡©î\Öf±8ò¼À «_®³ÅnòÛ6R/I³Øí¢T±´QÙ׺¦nÅU3ÐzÿL`â,à³V\â²Ä'©|Ô)³Fw¯ê)§× :ÃðdBËE¦g2u|zKµ}û²Ü^¶Àδ®Ó0É´"W@tÙÕ*ª\Ø/WrëÀÞêæÄ9u|êGèγV3
9W|ÐJ¹4-}È<(tIÅÀN)çÀsS§kþbfø3êø¶êg
ÜQǧY£Ì¢^Xg{Îâw>+SÎ&Ö*WRìCÃk9bÊ[!ghRLø'N4%±Ç.t æUÍFf©+Æ-Uêå¤ÒB /p+»8ýÆê>dÌ:gï$´«âì)áÏî¬×eX²^Ð{ågZ&ÂR¹gètgDÙçQ.qÓ^ûÚäPÞb°½"1ç*hCÍr©ªyÂv¢ÏôRc¯Ø¬iUÅÒCªµ>l¥Ïö°Å«ÄZJªr2RG¹"Jn.²Ç@,zÃ=¦H§]ïrU/³³4:¥NÒ]1°vºX@«2N±KzdXÎvVDF¥Kó´Z
¾Vvº¢8.IÏîÈà$"0Çö>L¯ß]¥ö #"Ãíñi¸
k"2â»ðºíú¡ÉDdøìýehçGddªc¿&çê¤"õ²ú¼s"2
+q~HL{Å96a]¬/K"{<)4?´óÆõËûú-j3=\=c@£AGáê· ê ¡ÉeÎ5²2´ãü$9~Ù×u¥.hIRªµêêÎËeÍPëÍ×S¯«ãuj¥°v*®S>¤JÈÉúRõ æ{$m<³«gdÑÎ y¾ç-êáè|°øÕõp?v~=|ôëá®ÊPÕ]§¡z£z8$¯^Zõp²'*æ^Z'Íb·ÿn['sî(vãz8§Ü N0/¾×ÃÉøb
+Û:0ré¤^¬¬Î@ºs"%G+Ûzr"O²$.[û½ëËë¡Ò © G-3X÷/#qÏé
g!8×ÖØÓPNýfùxmÖS
I󵯺e¶ò` z!hr·ÿÈWzݤ"ªu0\oгÀ^WS\¥Áå¤kÐûËp°¿ÉiÀÚ2Ôç½"8W,C!°¯<룼.b5&>bFë44!¨Óá]|¦iJ«9ÔÔþ-*R?~oX
+Ý®"õã÷©ø]è©£»¦[¾T ç*¹)¨Óuªfodݧs+Rõ-tåóúÐQ94õÜ$#x¢NÜî>Yq»ÆDèk1¥pr즥pÐÓÌèòR8¥y¹m)ÜUqKÝ¥pçùÂIÎ ÿH)lTáæ¥pJñ1þÐzDäüdÂ'qÄy'ÂKí±ÁÍTgløXýìAdL|ù6Ì2|Þæ¸½àõéÚÂQI]U~'1:!ÅÍ.éäAtTF=0 'úÖ8YvfM?tAfdö>ßÊ/¬ïoȯÔ0Õ-®p¥÷=ô÷ÄC§quº©Ý·+þª´AK[¡üúQúmé»"m¢p¯ ü"SìöÖbÁ´È»Ý¿ÚÂð¨,/¼Ý^«ÎàÍ|¸J
ºV[iø^ªý©Tì¦Qa·(#
×j+"
jÏj±â
+;I±[;ä ¡«¦9¤Òb7xAæZ©Â.èP©°»+¼H±r=ÙV@
+ïã³ßJÅnCµb7sXiåéþGzr¥µl>«÷±þ¢È±R©WϪ>°ý¹ÍîèLùtµ0I;z½H[bßÎxNDW|w(ñªy¢¼dQ¨µ{Í[©Èr÷:ôö¤$§j\séúQâ'9WÊ*häªçypÞëÍn»GNöL«n;3
+wrèÙÅÕ;Ó8G\×§zF^ß.S½o:su5»¤y×n¢ëH¥¥vùýqú×ËNë¼|¹tW}ÐiEzϯ¦»4s^5ÀGánUM'WK'>Ì5Õtr1Aõre5\-Ýglc+fÚ_\M'!´¶úFÕtr 4O9»NΩקϩ¦Û§èÊUÓÉÕÒIvFnPM'gwj:¹X;ï½ÞªNå«VÓÉÕÒsGoQM'§´Ñìß´N®KÒ¯¯¦?å,óTG5ÜüÉfC]UMw
+JóNáªémË[VÓE±«éNAÁ³Ôn]Mw)ÅΫ¦ó°7¯¦j«oZM'Àpój:¹Ýø««éäjé¤ÞëõÕtråcâ[TÓÉÕÒIõËõÕtrÄÝuj:\7¨¦«¥S¹ïz0c/ÈÜ/6×01t$t¹C_ániA[·¾¯N®KªÖÅE÷Õ©Zúè¤y³I9*IëÄk:},P<ð
+UÏò:í.Q ëv¹³øI®KtvGMG=½^:É%R¨I:zW¯¨KìÉì=oÄ*A&ÍZ%2'ÐbÊÝQ³&Íø+}&ùù×Ü)KûÃz¯¹S©äÒWH§ëLpõüd梻+ôp»¶¸EÇ5wz"ç_÷£QT¹èNORAí;¶öí<`ŨP ÓsÝËù¬s®öõÕYdâOº_µSÀÐâö«kyöu]¹?¹ÜQùB:ë
+´ù³Îäóß N3÷× «ÂP9CoU$Lø&IduÅÐõܰ
däi=Q{£¨èäÏRÚïåjÞ.TfCun
Õ¹e6TGg6Fbs{£wñiT>:®Þ
+AP7XÎsÊyIε+AÈn¥JaíÌ.L»°Våvia-wD±`åL)u-ÿT@¬p8ËÂS¶ù!0¿®ÌpîR$åáRÇ}¯*F´ÖÒjðLzI'®CÝ;ËtW¹)ïf7B]y³Íb!Ã9kZéºhH»ò1á¼Ö(R|Ñn5s^=§Â=V'G_:*é=g^Ä#Y ê
gîðBÛËyRÈ`ûÕ¬Lѹ¯ºá¯¯¿ãî¢exrÃÝå÷VsÃ5EåcÑu£ò4îònR¤tÇÝÙ£=Úû¤.IÏEgßp§qß«û4¥}ÃÞSÍaÊM
+»t
eïUaíèn¨QkÐ_X;ºËt8¡¢ÊÇÖ~üÊU·{Î
çÜhÜ Î
+k!6ÑIÝÓ£|.0µFp&¤bSÿ¬úv½ï~;<2Ëðõê¸àÞ7åeDf"¦!)ñµÄZL³é¤"LÛ.EÇýõêd,Áª|Õ¦ÖSÄ4$%¾ûå~%,ôÔ[ÄÄÝ)|*¸ E_óY!]êÕ[ƤË0,x=Ãb)x5tNÃp h¢¼sk\ó¯ÅdϬ§OhW¬ÓpôîØÐÞÑxa
N^bÃäohn.¨Þ-xýuc
+©<]UÏÚm z¤êYÆ_½¯<ôÈácËÌIfp]¢×ÍDKñ<èßJd6W
w
+yï¤PÈûê0³³ge-î]ÜÃÖÛ¯ßåêáXö®rÑÝS¼-d%Q=+1i)á
NKÒ´ÊdqÁríuWúbånþI©ÁBßÃ&¬"ýV»æÎ WTÜE bÒî¯FB¡öïήXF¿qÙ"<@1Dàdb#¸sNR'¹]O<ÒwµÊ¿_Öþíº]E¤Ö±*!%ä²÷¾E^ ß+
+H£UÑå
R¤O©@#ߣ¥Ét ýÅaÆOf_¾]B±kÍâþhèt´évleNváë»TãÄY9m§6é¢OÜbfÝéÍSÓÍïEñ¾_GD¹$éWoè
+N
+£TØåØR«ÞUâ¬HRÛ&MAÓ1ur7³¼ÏKR) <yyUV&«væ¼4·§xNʦVĬ)³^t]'«*ÇÏ\/*yZYº?§¹±bqåÝl^Üû2å+¹ô«¯ÞíK,:7î&§Æàìߨé«t]0´ëãc_¥Ûæ\nËúÌs/,KsGK·8Ö êÓôZ 0å,-=ñ1IÒÈØ¿VÍîêcÖ+aÆþã|dá`Áà²bν çú:±Ê]É
ìÅÔ®A'C*Ú§.HíEO|ZQQçEÚw¦è.$ûsÀÏîÙ5VZÆ(Ëvé´þÅ"Ï9Ða»t§tE) XÞËrJιR.¼jþDu¶ÔçfÌðâèý«ùtôK\]«Lóòßs(¦y¿þAúoI±À-)TvR.|jòëå*@½5Òî
+Ät¸ì©J 4ËuÕ ÂÙ¿¼
+P:J5Õª Õk8NöÅ.¬°¢y«4C×ܨGSìÒ*@Ñ¨Ô ÔX)ãõ>òUÊ]ÇJ$ûtNF%±Î¾ï¬Ù.¾O|[Ö?u)\TáöòißÈvKùhÙv:)^ÊvÏ»ïKùä¢p·¿Oõ~ä]ʧ÷þÊ+.åE`§Á
NµzºJnõ»ÅÙPð^¿TrÝìl¨ëîõMZØtA¶ì½~êQ!«îõp¥äV¿KÏÞë§RôÄϼ×Oa[ýÎ:÷^?]|õ½~ê!ÈÕU÷úé¨äºÁ½~t%R8Ó/WÞë§>´Óû+/»×OýV¿n ¹×O}@òªçßë';Mê§_p¯zÆÂYÐbêè-?R,>X}WÝë§®èÐ.Ï
îõS¿Õį̈ïõSwu² Ͼ×O.k¿ÕïêûønPó®ÿ^?u(höop¯ú £ûª{ýÔge*R/º×O~C
½ÕOr;ÃÅ÷ú¦Á oõcó..OaîõSfîºô^?Ù}Î ½¤ëïõSO¸W¤^~¯¨~ëäV¿s®.¼×Oìl×Þ맺Özoq¯úîð÷ñ]qø>¾ëëäoõ;¿Cþ^?õ-bålÛóîõS·äé÷ëïõS¿Õï6UiZùËmîõSßof\z¯ú~WÜÇwFÚ}|W¦ÃÝêwûø4}i§7ÞëwÎU| sݽ~'Å¢[ý¸¡+ïõãØKöV¿KªÒÎ7syìÌ{ýÔÌ_àïßä^¿[Ô½jß맯îõÚ{ý8(:ïF¿ì^¿ór®dîõ»¼»ÕOt?²pWéì'µ[ýTN9;ë^?9Æ'ZìÂ{ýÔNbJÞë§TÔ¢þ§¸]ߪ¼ú^¿óüÊKïõ ®[ý®ÉÞë§ÎA^{ýÔ
Cn'ñÊ{ýÔby|ݽ~ê·úÉØcÝë§fÑ6Ì-îõÓkÃ\w¯x&¥·ú©V×q¯ºrШâÔ}¯ºr`,%¸Ué=Q Ji½pñ!9W*`|´ÞvÑ.¦ârVO¼-JäXÐý,Þ½±½}#y!ÁÌ]ÊØ¨¨0Ø-Í a&û»ãhòølMo 3³Iú©É9'|KÜè7C¹PØE-j¾Ýqd«Ñ3ón~»3ÕS®üì»|
ãæNÿ¾hYm;
±Ø{p§ñ;¬¦yvõý¸¨Xìñ£úûÒÁ÷õYgñ´\÷*¾æñeXqØÃËñ3ý´6mWb¶w½e¤¥c·dÀlºÛ;3/·ÆäÅs5íé_ó¦×¾e[$ÉL¼mr~V&¾µv%&Á,VÆ2i¬Üí±Êýî«´$¹ÌxÈã"m£lîÇ1¸©´Lÿ\©èã;*{ÃJ/!IÍîáªl²T_¦Å·r®QNåRþ
+HúA[þ÷YXk<ØYôÌÀN&³Ûð£©ÿXwÉéñÛkvZ-¯ms4±Î[ÚÊí»SKcÖfØÅiú(y"
ë`Wº+×<&rù 8p>ÕÒ"Åë© \>ßµ(¶
+Í &ÞçÆk!20ÎÎ,õó¿/YßÁYtÅc_¾ä¯fÁ³æCvÖë>æªáïGW,Êcæçiáóá¾FêÏ\%zY£]t¥oÙ]E·åX¶Wk5¼ôO,
åÈÃÉÙ&«ßæ{]yüÃêÔùF¿¨ãÍ0#¿
+3µ[2½;/ËÊö{r0_(è@?Ų;ð3îB?Ñ©MÏ¿àAÁ±ý0'ßå¡ã½Í¾²ól¢a"A¿ëº±í7÷Â)|Q°¹0sXðªO¹W^áyjƽÀ/<æÚ}ñè@#Å+»÷Ì
,tóÊw½òàTöq>ó1*!ôÁ¥
^
7üð§=þ²p°\tñ§t<yúÅÅïyòÒ&áó¡cãñIµ
~2`'oï8rS0ß ìò5;« xÛu£·~G8Î¥ëe±`só¯;;æøÊ&°³%Ȥ*ò0O½WFò>9xË1DÜwO%]½N÷¹ÈçÔN¯&Ç[Çd°0ü;x÷ç6»«÷ûß<{ùÇézßÍO¿XMAK°Os·¿øVÃi¶/NZ!æ¯uÏþ\<¾¡Åî/9FÃÍõ V6µ·=·*=Zô`,e
+&Á_ɬÚgÐÚ/Gíì²ÜËpàÃvH`v a Ùõà@1¥{Ûèå,b·Nüü à[«ôòZ
¤ü`òC¸]®îÁ?#NzÅî:Aú4¿Ì\õÎÜ]-7 Ï_H9v$IÌY/þ.òàaîøwÛ>¸zü$B¿2vÞºëò'èT
ô1]@RǼé^wéëZ
+¤#/ÕÂ÷*7ã>Ï4©ÄprèÂc@(NïññJÏó;oIöÒäÌ¡©râÅ3mXQ-!vHù~Å
®SÆ»×è¼ãöQß)Ò%4sd¦# Pûp{
÷¿ -î
0³øù ¨X6dîÁ³è6x¬oþR£Ëâ-À <½Á¨Z«¼!iBWÑÃR×ýèÊ#
¤ »êy¹g>î0w¨D(Ù½oʳ£FG<|³'¤ lnÑûØüü$XqÀH'8 úzbÆÂÒvÀ7|uÏ?ëޣȬ´nyÉ;êMQýôÞýô9(êÛ;É%É5é¤)´VL¾ÿC¤wüÙPsß±½Ôù;$x'cþÊjDfö
·éK¯GDà/G/ôÏ8¼ I 9iãþålKE"<ïk<*Í Ü-$m[ÊÁËsÿ«iç+ÑD ów}|ÒÀcMèvl¦ õnåðªÂô¹Ö4?T2 ýhS^?S /; áÙú@ör+B}=¢£èx´ë1$å HW¥*1uþ0DU°XüÊa,L%a)EµI P´_¶×îö`§ J~
û+û0üE±qzg£=&uô^ûJ½ (ÍÙp 2
ßÀf)b1U{uÔËìÚ?±3iRUåw,ÁF(-±js0¶|p¼3ô+VÅ·"÷eqei
ÈñaùUÝÁðØE3Xébدiâxì"¡@ïôöã1I/Æã+Wüx!N!bE]«ÇÛÃu+~ü+]®º5òX.U;,ti¢m^8d£ÈÔâ|à/42o>hØ0Þmþu1ÆÑâ|?Æ3¬r$Ä}ZA³êD.3ܪgüVé }* ´½ª^îC#)ô±ÒA;×ÑOlj·ÇÙq'ÿ
ªØY7za° W~[¦f_½ü7þÏãW}ÑÀøùB̬§¬®åqWÊþ `pc¥ácëJ±+`m Tz~¸Ç£CÐ.¸`7ø'p»æá=¾£ñÚ
/j¼^m?cÐÆÁ?SøóÈtæÏaö:ØO
Í$ÀRÀÒAËË` ä£hørÌ
+p¹_Gï£B7Î%tCY]¸×
à<ûu(кÐÓÃx8á^*^Èõ¬ïÂ"Rß纹m2vÌw~1ÉëZ#ѳÿ-ËqÃÍMθë^`yQ Ò
ÏTqÐî^P4 ·ã¤ÿÊ¿ª0r3 L¬Ñ}¥½$><UÚýwæ¢6Æ]¥¹»½cXàuåbÔ«Õ×·¼k[i .*ÅÆE¼6ÐdàAiP¿:ªÂNñªù'M/*nåo^0z]Á=XõâEi-0ùF/3ù¯*Æä]pÉZVöö _MeEÁDwÁ²gºÖD¡#¹µFWùõݶã0ûV|Hî0Ш
óë
Î ¢Y r²ã{t!ÆÒÿ7mDcc4ãÞh46úklËùrkt_®ã½ítW& ¢KüçPÜMb{0ƾ\§P«ECEb²FtDè;"pé.0üPÚäIÀ{ÀòÅY¬²ªÞ?§FÅ6Hø@57
+½Jo1{±¯¾g^ëïÜÍ×¢É5ýÀÈn£
+Ã[xóô|w~ J"P{§Sã{ÿøÇ¨t´ì{Ë»·àKüxÃÐyhï Ó;FLqOó³|cq/~^Mî¯è|ÿÕd÷îàøà? 'hQ[¿Lå:mòl>L®7ÕE¯Bbãèÿ¬Bb¥Ñ?«4â×Â?¦h÷õ+$Næý£
+Á¢¥Ø¸(
LY£©Ë!êWRÔÔ
Á"«¦ø}qq.øÌ-»ìã:=ZôpísË3;nPµáÚ¯ÜLWfÙ¥Ëæ@ ïhYúÈ¡ýG'wb¨³g~a t 7vÔ
+ux(üÍ(³Ø~w4Áø~ÕAGWg¶_ôü3ØÑÛ~[ÖôÉì%¼è±TÛå[¾¼´Ú[ºã.´M0'JréZ`Âë¼íÂ0öiÙIGüêEgǵN¹Ø.×Ýúìá^ýG«·wó¿az{¨G'½WmP¨l<ó¼?IFdsy1ñ_l^¹ôRéÃga@KöL¦Pm= ³â
Vsl<µsn^x|øÖo
¢Ýð½É7Y « Ä÷ @àå×
+ÎïÅ1jdhêùé^ rAÒ?Ùg/¿ì³é[¶¶.~WVâfW
+t¢sÐ^`°8³}çÝ8@Lu²q@o@#òÂm:sÊqeÌ×pñµã«è%B6àÖýÍ èãI {³l@ÃådE"dâ«-K§E¼màÑ»}Îö#BJ;@ ÆxûÀï,gm Ñ
m,ÑKE!# ,' ~ûY N ;ðD }'Ý èû»NWúzf³2ÅWN> Yª ÐmçC&;ïaôâ>Åí8çÐâ+]¸Éì9ý{û5«º©u @Âh×õ¡`q±{:gw7\n}0XTzÑÃ=×ì¯âî¯ÍRb0²fôr%»ç,±/`¤TSys
G ¨»J5ÏKËð=Üùþ´iYþÁùv0â[Ø®qçd)ôCYZ!r<¦FÊWÏü*Ïneôð<vÑäTöq="CÈcRUsÖwÕ0ª2ÆòØeBæÍázûÀð´ã/Ëu+~¼ÇÓ)ÐÈúALÌÏuxRÞ«Vü$\.We7
p»??ÀkèCqhÔ»VxãÅàõ[ÎKqþ0ðßÖ´ÇËwLRçû1aÈkcÿÂíÈWa|-AÖLð
+¥Üliþõ&©¼ìeçH
+³=rÑNðEìÀ¥eÖ]Â
ðf¿.Lùà¾ñ _ì|J«ÄÅñªGa6k¥gç²YÅÙ¬@pi^ä'À¥ÑÎ5Xc§qÚë¬fáÏ'!ìñÜ)ûÄ8¦ã\´ÞÝDSyÈ^'|Li¦ÉöÄ<õXxóIòuà½7&äã B¦é
+Èâwd² J
^R÷ð_{çÎ\{2kë5SGÆ
-#×ãAò~Gµä³RxÈG>âS#Å{C¶¨|¾Eç¹ÎѼ,½MÛ0ÞÞÅyîE·s¼ÁWe¯nPSpÙÁ}XúTâ¡ïcÙ¾`?¡ÃÕÇÙ¸d?ìõèo®Î!$ܦ±ú¬tB7óasËp|pÒSÂ
¿ $nèbLw¿4b"WÐY@ÑQ;Zv;òÁT¿èyw¡
Æ&â´Ö`-×+¥ÉÞ·ätîP
Õ>OLM.[¯ÐóJ"¯h¤xékú:×¢^t¬?eÌ@>Ó[ÑÎ4¿ÝtÈCmïeÆWɺO:¡úß´p/Ün¶SáVÁbO:Äá¸
BÃ<1_n£?iÀôÿ0ð?øo$fÄýQ£??Bðicl°£¶FÜall
¡/GËÉa¹ÛÈ?Æ8|ôÚlôjEcÜH·¶ £ôÖàîoAÌÿ½þmÀÄàÇðãüñýmÆ÷OÌ8
í
Ñ`v÷bÁpи1ØF§|GÚ9ã碵7âxÔþàH þÇÂ|xüáçþ{àïà°c òÆüÁ(ó,36À3Ì¢¸1ãÞX,Ãg7
Á³7
D|£¼üá°Cü³xy# ÿ¡?b1üÁò{ýá_Ø
÷F#ß]ðÌï÷FbÁ ÿlmðã k8Â?òãÝ(yÃ{Ñm
+îY ´Â±0Ï=F½!Ü1²ÀÑ Ýë÷¤À{óøghmÅ ç°] °Øg\Wgì8èÜ O'·`N)ü±¨7ú N86Äï
þ¤uÈÄAËX ÆþéÝÂyÁ¼±hPù²ÐH¸ßCÀ¾"ü³ àúÁ#@?Yôܧ|ÿ$c±9{*+
íO$À
:êìäÇùgþfBöGÃ~08ûrp¸ìo0 <è
ûXâüH3óS0dúÛ ×?Éà GÜÈÓBP$Ú<À±´Gs¢Kk BçÔè/Â8ÚnwÑØ7Æ9IPI©Åîoø|Â6¸U6üÿúj
endstream
endobj
38 0 obj
<</CreationDate(D:20080827013258+02'00')/Creator(Adobe Illustrator CS3)/ModDate(D:20080827013318+02'00')>>
endobj
xref
0 43
0000000003 65535 f
+0000000016 00000 n
+0000014224 00000 n
+0000000004 00000 f
+0000000006 00000 f
+0000014674 00000 n
+0000000007 00000 f
+0000000008 00000 f
+0000000009 00000 f
+0000000010 00000 f
+0000000011 00000 f
+0000000012 00000 f
+0000000016 00001 f
+0000014275 00000 n
+0000014533 00000 n
+0000014564 00000 n
+0000000017 00000 f
+0000000018 00000 f
+0000000019 00000 f
+0000000020 00000 f
+0000000021 00000 f
+0000000022 00001 f
+0000000023 00000 f
+0000000024 00000 f
+0000000025 00000 f
+0000000031 00000 f
+0000016399 00000 n
+0000016473 00000 n
+0000016647 00000 n
+0000017628 00000 n
+0000031546 00000 n
+0000000000 00001 f
+0000014649 00000 n
+0000014346 00000 n
+0000014417 00000 n
+0000014448 00000 n
+0000015725 00000 n
+0000015019 00000 n
+0000053083 00000 n
+0000015838 00000 n
+0000015886 00000 n
+0000015455 00000 n
+0000000162 00000 n
+trailer
<</Size 43/Root 1 0 R/Info 38 0 R/ID[<A54447479992468B94FA561B9455A255><9B64ED4272634A6ABA86CC1FA8D7917D>]>>
startxref
53206
%%EOF
\ No newline at end of file
diff --git a/iphone/images/camera-roll.png b/iphone/images/camera-roll.png
new file mode 100644
index 0000000..e4e4119
Binary files /dev/null and b/iphone/images/camera-roll.png differ
diff --git a/iphone/images/chat_bubbles.psd b/iphone/images/chat_bubbles.psd
new file mode 100644
index 0000000..dd6d4e8
Binary files /dev/null and b/iphone/images/chat_bubbles.psd differ
diff --git a/iphone/images/chat_bubbles_aqua_l.png b/iphone/images/chat_bubbles_aqua_l.png
new file mode 100644
index 0000000..2a8e638
Binary files /dev/null and b/iphone/images/chat_bubbles_aqua_l.png differ
diff --git a/iphone/images/chat_bubbles_aqua_r.png b/iphone/images/chat_bubbles_aqua_r.png
new file mode 100644
index 0000000..cb61fec
Binary files /dev/null and b/iphone/images/chat_bubbles_aqua_r.png differ
diff --git a/iphone/images/chat_bubbles_clear_l.png b/iphone/images/chat_bubbles_clear_l.png
new file mode 100644
index 0000000..19dc7d6
Binary files /dev/null and b/iphone/images/chat_bubbles_clear_l.png differ
diff --git a/iphone/images/chat_bubbles_clear_r.png b/iphone/images/chat_bubbles_clear_r.png
new file mode 100644
index 0000000..6194d28
Binary files /dev/null and b/iphone/images/chat_bubbles_clear_r.png differ
diff --git a/iphone/images/chat_bubbles_graphite_l.png b/iphone/images/chat_bubbles_graphite_l.png
new file mode 100644
index 0000000..2f0f6c0
Binary files /dev/null and b/iphone/images/chat_bubbles_graphite_l.png differ
diff --git a/iphone/images/chat_bubbles_graphite_r.png b/iphone/images/chat_bubbles_graphite_r.png
new file mode 100644
index 0000000..c51369d
Binary files /dev/null and b/iphone/images/chat_bubbles_graphite_r.png differ
diff --git a/iphone/images/chat_bubbles_lemon_l.png b/iphone/images/chat_bubbles_lemon_l.png
new file mode 100644
index 0000000..7cbdf98
Binary files /dev/null and b/iphone/images/chat_bubbles_lemon_l.png differ
diff --git a/iphone/images/chat_bubbles_lemon_r.png b/iphone/images/chat_bubbles_lemon_r.png
new file mode 100644
index 0000000..3508405
Binary files /dev/null and b/iphone/images/chat_bubbles_lemon_r.png differ
diff --git a/iphone/images/chat_bubbles_lime_l.png b/iphone/images/chat_bubbles_lime_l.png
new file mode 100644
index 0000000..4be16be
Binary files /dev/null and b/iphone/images/chat_bubbles_lime_l.png differ
diff --git a/iphone/images/chat_bubbles_lime_r.png b/iphone/images/chat_bubbles_lime_r.png
new file mode 100644
index 0000000..a36ab6c
Binary files /dev/null and b/iphone/images/chat_bubbles_lime_r.png differ
diff --git a/iphone/images/chat_bubbles_orange_l.png b/iphone/images/chat_bubbles_orange_l.png
new file mode 100644
index 0000000..d0fc14d
Binary files /dev/null and b/iphone/images/chat_bubbles_orange_l.png differ
diff --git a/iphone/images/chat_bubbles_orange_r.png b/iphone/images/chat_bubbles_orange_r.png
new file mode 100644
index 0000000..2c73d6a
Binary files /dev/null and b/iphone/images/chat_bubbles_orange_r.png differ
diff --git a/iphone/images/chat_bubbles_pink_l.png b/iphone/images/chat_bubbles_pink_l.png
new file mode 100644
index 0000000..b811fe3
Binary files /dev/null and b/iphone/images/chat_bubbles_pink_l.png differ
diff --git a/iphone/images/chat_bubbles_pink_r.png b/iphone/images/chat_bubbles_pink_r.png
new file mode 100644
index 0000000..04d4e7d
Binary files /dev/null and b/iphone/images/chat_bubbles_pink_r.png differ
diff --git a/iphone/images/chat_bubbles_purple_l.png b/iphone/images/chat_bubbles_purple_l.png
new file mode 100644
index 0000000..345cb24
Binary files /dev/null and b/iphone/images/chat_bubbles_purple_l.png differ
diff --git a/iphone/images/chat_bubbles_purple_r.png b/iphone/images/chat_bubbles_purple_r.png
new file mode 100644
index 0000000..1495560
Binary files /dev/null and b/iphone/images/chat_bubbles_purple_r.png differ
diff --git a/iphone/images/chevron.png b/iphone/images/chevron.png
new file mode 100644
index 0000000..1f422a9
Binary files /dev/null and b/iphone/images/chevron.png differ
diff --git a/iphone/images/chevron_b.png b/iphone/images/chevron_b.png
new file mode 100644
index 0000000..451d311
Binary files /dev/null and b/iphone/images/chevron_b.png differ
diff --git a/iphone/images/chevron_dg.png b/iphone/images/chevron_dg.png
new file mode 100644
index 0000000..b8590a5
Binary files /dev/null and b/iphone/images/chevron_dg.png differ
diff --git a/iphone/images/chevron_w.png b/iphone/images/chevron_w.png
new file mode 100644
index 0000000..8970e39
Binary files /dev/null and b/iphone/images/chevron_w.png differ
diff --git a/iphone/images/grayButton.png b/iphone/images/grayButton.png
new file mode 100644
index 0000000..83f2c45
Binary files /dev/null and b/iphone/images/grayButton.png differ
diff --git a/iphone/images/greenButton.png b/iphone/images/greenButton.png
new file mode 100644
index 0000000..96ea153
Binary files /dev/null and b/iphone/images/greenButton.png differ
diff --git a/iphone/images/image-loading.gif b/iphone/images/image-loading.gif
new file mode 100644
index 0000000..f5c07e4
Binary files /dev/null and b/iphone/images/image-loading.gif differ
diff --git a/iphone/images/iphoneuikitlogo.png b/iphone/images/iphoneuikitlogo.png
new file mode 100644
index 0000000..0458a8a
Binary files /dev/null and b/iphone/images/iphoneuikitlogo.png differ
diff --git a/iphone/images/kitbg.png b/iphone/images/kitbg.png
new file mode 100644
index 0000000..b310430
Binary files /dev/null and b/iphone/images/kitbg.png differ
diff --git a/iphone/images/list-icon-1.png b/iphone/images/list-icon-1.png
new file mode 100644
index 0000000..024451b
Binary files /dev/null and b/iphone/images/list-icon-1.png differ
diff --git a/iphone/images/list-icon-2.png b/iphone/images/list-icon-2.png
new file mode 100644
index 0000000..38cca3f
Binary files /dev/null and b/iphone/images/list-icon-2.png differ
diff --git a/iphone/images/list-icon-3.png b/iphone/images/list-icon-3.png
new file mode 100644
index 0000000..85ff75f
Binary files /dev/null and b/iphone/images/list-icon-3.png differ
diff --git a/iphone/images/list-icon-4.png b/iphone/images/list-icon-4.png
new file mode 100644
index 0000000..e8b6e41
Binary files /dev/null and b/iphone/images/list-icon-4.png differ
diff --git a/iphone/images/list-icon-5.png b/iphone/images/list-icon-5.png
new file mode 100644
index 0000000..456dc4f
Binary files /dev/null and b/iphone/images/list-icon-5.png differ
diff --git a/iphone/images/masterlogo.psd b/iphone/images/masterlogo.psd
new file mode 100644
index 0000000..629049c
Binary files /dev/null and b/iphone/images/masterlogo.psd differ
diff --git a/iphone/images/minid-profile.png b/iphone/images/minid-profile.png
new file mode 100644
index 0000000..ae10ec8
Binary files /dev/null and b/iphone/images/minid-profile.png differ
diff --git a/iphone/images/minidlastfm.jpg b/iphone/images/minidlastfm.jpg
new file mode 100644
index 0000000..6c951e2
Binary files /dev/null and b/iphone/images/minidlastfm.jpg differ
diff --git a/iphone/images/profile-user.png b/iphone/images/profile-user.png
new file mode 100644
index 0000000..d65596b
Binary files /dev/null and b/iphone/images/profile-user.png differ
diff --git a/iphone/images/redButton.png b/iphone/images/redButton.png
new file mode 100644
index 0000000..af24f71
Binary files /dev/null and b/iphone/images/redButton.png differ
diff --git a/iphone/images/standard-img.jpg b/iphone/images/standard-img.jpg
new file mode 100644
index 0000000..5c186d4
Binary files /dev/null and b/iphone/images/standard-img.jpg differ
diff --git a/iphone/images/standard-img.png b/iphone/images/standard-img.png
new file mode 100644
index 0000000..158d06b
Binary files /dev/null and b/iphone/images/standard-img.png differ
diff --git a/iphone/images/stripes.png b/iphone/images/stripes.png
new file mode 100644
index 0000000..1760f9b
Binary files /dev/null and b/iphone/images/stripes.png differ
diff --git a/iphone/images/toolButton.png b/iphone/images/toolButton.png
new file mode 100644
index 0000000..afe4d7a
Binary files /dev/null and b/iphone/images/toolButton.png differ
diff --git a/iphone/images/whiteButton.png b/iphone/images/whiteButton.png
new file mode 100644
index 0000000..ce8c9cb
Binary files /dev/null and b/iphone/images/whiteButton.png differ
diff --git a/iphone/index.html b/iphone/index.html
new file mode 100644
index 0000000..4e7fdde
--- /dev/null
+++ b/iphone/index.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
+ <title>English Premier League</title>
+ <link rel="stylesheet" href="iphone/stylesheets/iphone.css" />
+ <link rel="stylesheet" href="iphone/stylesheets/table.css" />
+ <link rel="apple-touch-icon" href="iphone/images/apple-touch-icon.png" />
+ <script type="text/javascript" charset="utf-8">
+ window.onload = function() {
+ setTimeout(function(){window.scrollTo(0, 1);}, 100);
+ }
+ </script>
+ <script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
+ <script src="/js/models/epl_table.js" type="text/javascript"></script>
+ <script src="/js/models/epl_team.js" type="text/javascript"></script>
+</head>
+
+<body>
+
+ <div id="header">
+ <h1>EPL Table</h1>
+ </div>
+
+ <ul id="epl_iphone_table">
+
+
+ </ul>
+
+ <script type="text/javascript" charset="utf-8">
+ //<![CDATA[
+ jQuery(function($) {
+ TABLE = new EPL.Table(true);
+ TABLE.initialize_teams();
+ });
+ </script>
+
+</body>
+
+</html>
\ No newline at end of file
diff --git a/iphone/stylesheets/ie-vs-chrome.blog.html b/iphone/stylesheets/ie-vs-chrome.blog.html
new file mode 100644
index 0000000..f67296f
--- /dev/null
+++ b/iphone/stylesheets/ie-vs-chrome.blog.html
@@ -0,0 +1,67 @@
+Title: Google Chrome vs el resto
+
+<p>Tenemos un nuevo navegador para disfrutar: Google Chrome, hecho, valga la redundancia por la misma gente que hace el buscador más utilizado del planeta: Google. En el diario Público leà la reseña que hicieron y me gustó todo, sólo una cosa no me terminó de cerrar: ¿por qué lo comparan con Internet Explorer 8 y no el 7? O sea, ¿el criterio es compararlo con navegadores en estado <em>beta</em> o con navegadores que tienen son lanzamientos oficiales como estables?</p>
+
+<h3>Google Chrome</h3>
+
+<p>Es un navegador rápido. Al menos, es lo que demostró funcionando en una máquina virtual que apenas emularÃa la velocidad de un ordenador con 700MB de RAM y 1Ghz de procesador. Se abre en un <em>plis</em> y todo va rápido. Esa es la sensación inicial.</p>
+
+<p>Necesita un Windows XP con Service Pack 2 para poder funcionar, de lo contrario, el instalador te dirá que no puedes usarlo. El instalador apenas ocupa 500KB, se baja de internet todo, y creo que es acertado el método.
+
+<p>Si fuera estables, entonces deberÃamos comprar Firefox 3, Internet Explorer 7. Aunque, el verdadero problema no es ese. Ya que, Microsoft tiene dividido el uso de Internet Explorer en 6 y 7. Mis estadÃsticas indican que, incluso siendo un público especializados, el 7 le gana al 6 pero no tanto, y el 8 apenas es visible.</p>
+
+<p>Pero yendo al grano, me causó gracia el recuadro de pros y contras de los navegadores, lo resumiré aquÃ:</p>
+
+<blockquote>
+
+ <h3>Microsoft Internet Explorer 8</h3>
+
+ <p>Lo mejor:</p>
+
+ <ul>
+ <li>Es el más difundido, todas las webs funcionan correctamente con él.</li>
+ <li>Integración con Windows. Muchas aplicaciones de Windows utilizan partes del navegador para funcionar.</li>
+ <li>Extensiones, ActiveX. Los programadores pueden añadir funciones para realizar tareas especializadas.</li>
+ </ul>
+
+<p>Lo mejorable:</p>
+
+<ul>
+ <li>Vulnerabilidades, que tardan en corregirse. Como promedio, tardan unos nueve dÃas en ser corregidos mediante una revisión o parche.</li>
+ <li>Pobre gestión de los estándares web.</li>
+ <li>Ciclo de versiones y revisiones lento, aunque la compañÃa ha mejorado algo en Explorer 7 y 8.</li>
+</ul>
+
+</blockquote>
+
+<p>Vayamos punto por punto:</p>
+
+<blockquote><p>Es el más difundido, todas las webs funcionan correctamente con él.</p></blockquote>
+
+<p>Esta es una apreciación bastante incorrecta. Ni es el más difundido (8 apenas tiene meses de lanzamiento) ni todas las webs funcionan correctamente. De hecho, Internet Explorer 8 funciona muy similar a Firefox, Safari y Opera ahora, al ir con modo estándar por defecto. Esto significa que, aunque navegues webs de bancos, administraciones verás los mismos problemas e incluso, algunos peores sólo por el hecho que esas webs utilizan métodos de codificación que se ajustaban a Internet Explorer 6 (casi el más difundido). En mis pruebas, la beta 2 de IE8 iba mejor que la 1 que parecÃa, no sé, un malware. Entrabas a Google Maps y no existÃan los mapas.</p>
+
+<blockquote><p>Integración con Windows. Muchas aplicaciones de Windows utilizan partes del navegador para funcionar.</p></blockquote>
+
+<p>Esta es otra apreciación bastante locuaz. La integración con el OS no es entera, de hecho, el OS no utiliza los últimos componentes, va todo con la DLL concreta para la UI que maneje Windows en ese momento. Por ejemplo, hay casos donde tienes Internet Explorer 8 rendereando varios modos de compatibilidad, y tienes abierto el Outlook Express mirando un correo electrónico usando otra versión del Internet Explorer que no es, precisamente, la 8 beta 2. Tanto Windows como Explorer usan el mismo motor pero no es la misma versión.</p>
+
+<p>Por otro lado, esto no algo apreciable, es invisible al usuario. El usuario utiliza sus aplicaciones y no tiene, se los aseguro, ni puñetera idea que está usando un interfaz montado a partir de XMLs, hojas de estilos que el motor de IE soporta en una ventana de sistema. Simplemente piensa que es una aplicación normal y corriente y no una aplicación web.</p>
+
+<blockquote><p>Extensiones, ActiveX. Los programadores pueden añadir funciones para realizar tareas especializadas.</p></blockquote>
+
+<p>Totalmente de acuerdo. De hecho, es una de las razones por las cuales, muchas empresas siguen apostando por ActiveX. Tanto porque no se quieren actualizar, como por la inconveniencia de meterse con otra cosa que no salga de una suite de programación de Microsoft. En este ámbito, las extensiones ActiveX le dan la verdadera vida al navegador, pero tampoco es la panacea. Comparar ActiveX contra, por ejemplo, las extensiones de Firefox me parecerÃa incorrecto.</p>
+
+<blockquote><p>Vulnerabilidades, que tardan en corregirse. Como promedio, tardan unos nueve dÃas en ser corregidos mediante una revisión o parche.</p></blockquote>
+
+<p>Aquà ya no me meto. En un año, la cantidad de vulnerabilidades que encontraron en IE6 e IE7 (separadamente hablando) fue horripilante. Más de 197 vulnerabilidades. Algunas, requirieron el lanzamiento de SP2 con premura según leÃa Slashdot y otros sitios que tocan el tema.</p>
+
+<blockquote><p>Pobre gestión de los estándares web.</p></blockquote>
+
+<p>Aquà Microsoft ha hecho un esfuerzo notable. En la versión 7, además de dar soporte a cosas tan indispensables como el alpha en los archivos PNG, soporte de algunos de los selectores más importantes de CSS 2. En Internet Explorer 8, el soporte de CSS 2.1 no está completo del todo, pero está casi soportado en su totalidad. La gestión de estándares no es pobre, pero tampoco es la mejor. En IE8 se aprecian incontables bugs de visualización (es una beta tirando a alpha) y todavÃa le quedan incontables cosas por soportar. De todo lo que podemos apreciar de este navegador es que al menos, algo de bola a los estándares le están dando.</p>
+
+<blockquote><p>Ciclo de versiones y revisiones lento, aunque la compañÃa ha mejorado algo en Explorer 7 y 8.</p></blockquote>
+
+<p>Bueno, el ciclo de versiones en Internet Explorer no es lento, es⦠casi estático. Tardaron más de 7 años en lanzar una actualización de 6 a 7, y tardarán bastante (otros 3 años más) en tener la 8. El ciclo se mueve más que nada a velocidad de caracol, y no se trata de lanzar nuevas versiones sino actualizaciones. Firefox, Safari, Opera viven lanzando actualizaciones, además de los tÃpicos parches. Y de lo mejorcito que se puede uno esperar es eso, encontrar que la versión 3.1 soporta 3 o 4 cosas nuevas, que la versión 9.53 mejora este bug y otro, pero en IE eso no es posible. Cada parche es de seguridad, las actualizaciones que involucren mejoras y soporte a nuevas tecnologÃas está sujeto siempre a nuevas versiones y no actualizaciones. Por ejemplo, el soporte PNG llevó sólo 68 horas de programación y test en Internet Explorer 7 cuando llevaron más de 6 años sin ponerlo en IE6. No sé si captan la indirecta.</p>
+
+â------â------â------â------â------â------â------â------â------â------
+
+Main entry continued
diff --git a/iphone/stylesheets/iphone.css b/iphone/stylesheets/iphone.css
new file mode 100644
index 0000000..d42d3f9
--- /dev/null
+++ b/iphone/stylesheets/iphone.css
@@ -0,0 +1,1103 @@
+/*
+
+ Universal iPhone UI Kit 1.0
+ Author: Diego MartÃn Lafuente.
+ E-Mail: [email protected]
+ AIM: Minidixier
+ Licence: AGPLv3
+ date: 2008-08-09
+
+ URL: www.minid.net
+ SVN URL: http://code.google.com/p/iphone-universal/source/checkout
+ Download: http://code.google.com/p/iphone-universal/downloads/list
+
+ */
+
+
+ body {
+ background: rgb(197,204,211) url(../images/stripes.png);
+ font-family: Helvetica;
+ margin: 0 0 0 10px;
+ padding: 0;
+ -webkit-user-select: none;
+ -webkit-text-size-adjust: none;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /* standard header on body */
+
+ div#header + h1, ul + h1 {
+ color: rgb(76,86,108);
+ font: bold 18px Helvetica;
+ text-shadow: #fff 0 1px 0;
+ margin: 15px 0 0 10px;
+ }
+
+
+
+ /* standard paragraph on body */
+
+ ul + p, ul.data + p + p, ul.form + p + p {
+ color: rgb(76,86,108);
+ font: 14px Helvetica;
+ text-align: center;
+ text-shadow: white 0 1px 0;
+ margin: 0 10px 17px 0;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /* headers */
+
+ div#header {
+ background: rgb(109,133,163) url(../images/bgHeader.png) repeat-x top;
+ border-top: 1px solid rgb(205,213,223);
+ border-bottom: 1px solid rgb(46,55,68);
+ padding: 10px;
+ margin: 0 0 0 -10px;
+ min-height: 44px;
+ -webkit-box-sizing: border-box;
+ }
+
+
+ div#header h1 {
+ color: #fff;
+ font: bold 20px/30px Helvetica;
+ text-shadow: #2d3642 0 -1px 0;
+ text-align: center;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ width: 49%;
+ padding: 5px 0;
+ margin: 2px 0 0 -24%;
+ position: absolute;
+ top: 0;
+ left: 50%;
+ }
+
+ div#header a {
+ color: #FFF;
+ background: none;
+ font: bold 12px/30px Helvetica;
+ border-width: 0 5px;
+ margin: 0;
+ padding: 0 3px;
+ width: auto;
+ height: 30px;
+ text-shadow: rgb(46,55,68) 0 -1px 0;
+ text-overflow: ellipsis;
+ text-decoration: none;
+ white-space: nowrap;
+ position: absolute;
+ overflow: hidden;
+ top: 7px;
+ right: 6px;
+ -webkit-border-image: url(../images/toolButton.png) 0 5 0 5;
+ }
+
+ div#header #backButton {
+ left: 6px;
+ right: auto;
+ padding: 0;
+ max-width: 55px;
+ border-width: 0 8px 0 14px;
+ -webkit-border-image: url(../images/backButton.png) 0 8 0 14;
+ }
+
+
+ .Action {
+ border-width: 0 5px;
+ -webkit-border-image: url(../images/actionButton.png) 0 5 0 5;
+ }
+
+
+
+ div#header ul {
+ margin-top: 15px;
+ }
+
+ div#header p {
+ color: rgb(60,70,80);
+ font-weight: bold;
+ font-size: 13px;
+ text-align: center;
+ clear: both;
+ position: absolute;
+ top: 4px;
+ left: 35px;
+ right: 35px;
+ margin: 0;
+ text-shadow: #C0CBDB 0 1px 0;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ }
+
+ div.pre {
+ height: 60px;
+ }
+
+
+ div.pre h1 {
+ top: 18px !important;
+ }
+
+ div.pre a {
+ top: 25px !important;
+ right: 6px;
+ }
+
+ div.pre a#Backbutton {
+ left: 6px !important;
+ }
+
+
+
+
+
+ /***** List (base) ******/
+
+ ul {
+ color: black;
+ background: #fff;
+ border: 1px solid #B4B4B4;
+ font: bold 17px Helvetica;
+ padding: 0;
+ margin: 15px 10px 17px 0;
+ -webkit-border-radius: 8px;
+ }
+
+
+ ul li {
+ color: #666;
+ border-top: 1px solid #B4B4B4;
+ list-style-type: none;
+ padding: 10px 10px 10px 10px;
+ }
+
+
+
+ /* when you have a first LI item on any list */
+
+ li:first-child {
+ border-top: 0;
+ -webkit-border-top-left-radius: 8px;
+ -webkit-border-top-right-radius: 8px;
+ }
+
+ li:last-child {
+ -webkit-border-bottom-left-radius: 8px;
+ -webkit-border-bottom-right-radius: 8px;
+ }
+
+
+ /* universal arrows */
+
+ ul li.arrow {
+ background-image: url(../images/chevron.png);
+ background-position: right center;
+ background-repeat: no-repeat;
+ }
+
+
+ #plastic ul li.arrow, #metal ul li.arrow {
+ background-image: url(../images/chevron_dg.png);
+ background-position: right center;
+ background-repeat: no-repeat;
+ }
+
+
+
+ /* universal links on list */
+
+ ul li a, li.img a + a {
+ color: #000;
+ text-decoration: none;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ display: block;
+ padding: 12px 10px 12px 10px;
+ margin: -10px;
+ -webkit-tap-highlight-color:rgba(0,0,0,0);
+ }
+
+ ul li.img a + a {
+ margin: -10px 10px -20px -5px;
+ font-size: 17px;
+ font-weight: bold;
+ }
+
+ ul li.img a + a + a {
+ font-size: 14px;
+ font-weight: normal;
+ margin-left: -10px;
+ margin-bottom: -10px;
+ margin-top: 0;
+ }
+
+
+ ul li.img a + small + a {
+ margin-left: -5px;
+ }
+
+
+ ul li.img a + small + a + a {
+ margin-left: -10px;
+ margin-top: -20px;
+ margin-bottom: -10px;
+ font-size: 14px;
+ font-weight: normal;
+ }
+
+ ul li.img a + small + a + a + a {
+ margin-left: 0px !important;
+ margin-bottom: 0;
+ }
+
+
+ ul li a + a {
+ color: #000;
+ font: 14px Helvetica;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ display: block;
+ margin: 0;
+ padding: 0;
+ }
+
+ ul li a + a + a, ul li.img a + a + a + a, ul li.img a + small + a + a + a {
+ color: #666;
+ font: 13px Helvetica;
+ margin: 0;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ display: block;
+ padding: 0;
+ }
+
+
+
+
+
+ /* standard mini-label */
+
+ ul li small {
+ color: #369;
+ font: 17px Helvetica;
+ text-align: right;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ display: block;
+ width: 23%;
+ float: right;
+ padding: 3px 0px;
+ }
+
+
+
+ ul li.arrow small {
+ padding: 0 15px;
+ }
+
+ ul li small.counter {
+ font-size: 17px !important;
+ line-height: 13px !important;
+ font-weight: bold;
+ background: rgb(154,159,170);
+ color: #fff;
+ -webkit-border-radius: 11px;
+ padding: 4px 10px 5px 10px;
+ display: inline !important;
+ width: auto;
+ margin-top: 2px;
+ }
+
+
+ ul li.arrow small.counter {
+ margin-right: 15px;
+ }
+
+
+
+
+ /* resize without labels */
+
+ ul li.arrow a {
+ width: 95%;
+ }
+
+ /* with labels */
+
+ ul li small + a {
+ width: 75%;
+ }
+
+ ul li.arrow small + a {
+ width: 70%;
+ }
+
+
+
+ /* images */
+
+ ul li.img {
+ padding-left: 115px;
+ }
+
+ ul li.img a.img {
+ background: url(../images/standard-img.png) no-repeat;
+ display: inline-block;
+ width: 100px;
+ height: 75px;
+ margin: -10px 0 -20px -115px;
+ float: left;
+ }
+
+
+
+ /* individuals */
+
+
+
+ ul.individual {
+ border: 0;
+ background: none;
+ clear: both;
+ height: 45px;
+ }
+
+ ul.individual li {
+ color: rgb(183,190,205);
+ background: white;
+ border: 1px solid rgb(180,180,180);
+ font-size: 14px;
+ text-align: center;
+ -webkit-border-radius: 8px;
+ -webkit-box-sizing: border-box;
+ width: 48%;
+ float:left;
+ display: block;
+ padding: 11px 10px 14px 10px;
+ }
+
+ ul.individual li + li {
+ float: right;
+
+ }
+
+
+ ul.individual li a {
+ color: rgb(50,79,133);
+ line-height: 16px;
+ margin: -11px -10px -14px -10px;
+ padding: 11px 10px 14px 10px;
+ -webkit-border-radius: 8px;
+ }
+
+ ul.individual li a:hover {
+ color: #fff;
+ background: #36c;
+ }
+
+
+
+
+ /* Normal lists and metal */
+
+ body#normal h4 {
+ color: #fff;
+ background: rgb(154,159,170) url(../images/bglight.png) top left repeat-x;
+ border-top: 1px solid rgb(165,177,186);
+ text-shadow: #666 0 1px 0;
+ margin: 0;
+ padding: 2px 10px;
+ }
+
+
+ body#normal, body#metal {
+ margin: 0;
+ padding: 0;
+ background-color: rgb(255,255,255);
+ }
+
+ body#normal ul, body#metal ul, body#plastic ul {
+ -webkit-border-radius: 0;
+ margin: 0;
+ border-left: 0;
+ border-right: 0;
+ border-top: 0;
+ }
+
+ body#metal ul {
+ border-top: 0;
+ border-bottom: 0;
+ background: rgb(180,180,180);
+ }
+
+
+
+
+ body#normal ul li {
+ font-size: 20px;
+ }
+
+ body#normal ul li small {
+ font-size: 16px;
+ line-height: 28px;
+ }
+
+ body#normal li, body#metal li {
+ -webkit-border-radius: 0;
+ }
+
+ body#normal li em {
+ font-weight: normal;
+ font-style: normal;
+ }
+
+ body#normal h4 + ul {
+ border-top: 1px solid rgb(152,158,164);
+ border-bottom: 1px solid rgb(113,125,133);
+ }
+
+
+ body#metal ul li {
+ border-top: 1px solid rgb(238,238,238);
+ border-bottom: 1px solid rgb(156,158,165);
+ background: url(../images/bgMetal.png) top left repeat-x;
+ font-size: 26px;
+ text-shadow: #fff 0 1px 0;
+ }
+
+ body#metal ul li a {
+ line-height: 26px;
+ margin: 0;
+ padding: 13px 0;
+ }
+
+ body#metal ul li a:hover {
+ color: rgb(0,0,0);
+ }
+
+ body#metal ul li:hover small {
+ color: inherit;
+ }
+
+
+ body#metal ul li a em {
+ display: block;
+ font-size: 14px;
+ font-style: normal;
+ color: #444;
+ width: 50%;
+ line-height: 14px;
+ }
+
+ body#metal ul li small {
+ float: right;
+ position: relative;
+ margin-top: 10px;
+ font-weight: bold;
+ }
+
+
+ body#metal ul li.arrow a small {
+ padding-right: 0;
+ line-height: 17px;
+ }
+
+
+ body#metal ul li.arrow {
+ background: url(../images/bgMetal.png) top left repeat-x,
+ url(../images/chevron_dg.png) right center no-repeat;
+ }
+
+
+
+ /* option panel */
+
+ div#optionpanel {
+ background: url(../images/blackbg.png) top left repeat-x;
+ text-align: center;
+ padding: 20px 10px 15px 10px;
+ position: absolute;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ }
+
+ div#optionpanel h2 {
+ font-size: 17px;
+ color: #fff;
+ text-shadow: #000 0 1px 0;
+ }
+
+
+
+
+
+ /***** BUTTONS *****/
+
+ .button {
+ color: #fff;
+ font: bold 20px/46px Helvetica;
+ text-decoration: none;
+ text-align: center;
+ text-shadow: #000 0 1px 0;
+ border-width: 0px 14px 0px 14px;
+ display: block;
+ margin: 3px 0;
+ }
+
+ .green { -webkit-border-image: url(../images/greenButton.png) 0 14 0 14; }
+ .red { -webkit-border-image: url(../images/redButton.png) 0 14 0 14; }
+
+ .white {
+ color: #000;
+ text-shadow: #fff 0px 1px 0;
+ -webkit-border-image: url(../images/whiteButton.png) 0 14 0 14;
+ }
+
+ .black { -webkit-border-image: url(../images/grayButton.png) 0 14 0 14; }
+
+
+/***** FORMS *****/
+
+/* fields list */
+
+ ul.form {
+
+ }
+
+ ul.form li {
+ padding: 7px 10px;
+ }
+
+ ul.form li.error { border: 2px solid red; }
+ ul.form li.error + li.error { border-top: 0; }
+
+ ul.form li:hover { background: #fff; }
+
+ ul li input[type="text"], ul li input[type="password"], ul li textarea, ul li select {
+ color: #777;
+ background: #fff url(../.png); /* this is a hack due the default input shadow that iphones uses on textfields */
+ border: 0;
+ font: normal 17px Helvetica;
+ padding: 0;
+ display: inline-block;
+ margin-left: 0px;
+ width: 100%;
+ -webkit-appearance: textarea;
+ }
+
+ ul li textarea {
+ height: 120px;
+ padding: 0;
+ text-indent: -2px;
+ }
+
+ ul li select {
+ text-indent: 0px;
+ background: transparent url(../images/chevron.png) no-repeat 103% 3px;
+ -webkit-appearance: textfield;
+ margin-left: -6px;
+ width: 104%;
+ }
+
+ ul li input[type="checkbox"], ul li input[type="radio"] {
+ margin: 0;
+ color: rgb(50,79,133);
+ padding: 10px 10px;
+ }
+
+ ul li input[type="checkbox"]:after, ul li input[type="radio"]:after {
+ content: attr(title);
+ font: 17px Helvetica;
+ display: block;
+ width: 246px;
+ margin: -12px 0 0 17px;
+ }
+
+
+
+ /**** INFORMATION FIELDS ****/
+
+ ul.data li h4 {
+ margin: 10px 0 5px 0;
+ }
+
+ ul.data li p {
+ text-align: left;
+ font-size: 14px;
+ line-height: 18px;
+ font-weight: normal;
+ margin: 0;
+ }
+
+ ul.data li p + p { margin-top: 10px; }
+
+
+ ul.data li {
+ background: none;
+ padding: 15px 10px;
+ color: #222;
+ }
+
+ ul.data li a {
+ display: inline;
+ color: #2E3744;
+ text-decoration: underline;
+ }
+
+
+ ul.field li small {
+ position: absolute;
+ right: 25px;
+ margin-top: 3px;
+ z-index: 3;
+ }
+
+ ul.field li h3 {
+ color: rgb(76,86,108);
+ width: 25%;
+ font-size: 13px;
+ line-height: 18px;
+ margin: 0 10px 0 0;
+ float: left;
+ text-align: right;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ padding: 0;
+ }
+
+ ul.field li a {
+ font-size: 13px;
+ line-height: 18px;
+ overflow: visible;
+ white-space: normal;
+ display: inline-block;
+ width: 60%;
+ padding: 0;
+ margin: 0 0 0 0;
+ vertical-align: top;
+ }
+
+ ul.field li big {
+ font-size: 13px;
+ line-height: 18px;
+ font-weight: normal;
+ overflow: visible;
+ white-space: normal;
+ display: inline-block;
+ width: 60%;
+ }
+
+
+
+
+
+
+ ul.field li small {
+ font-size: 13px;
+ font-weight: bold;
+ }
+
+
+ /* this is for profiling */
+
+ ul.profile {
+ border: 0;
+ background: none;
+ clear: both;
+ min-height: 62px;
+ position: relative;
+ }
+
+ ul.profile li {
+ background: #fff url(../images/profile-user.png) no-repeat;
+ border: 1px solid #B4B4B4;
+ width: 62px;
+ height: 62px;
+ -webkit-border-radius: 4px;
+ -webkit-box-sizing: border-box;
+ float: left;
+ }
+
+ ul.profile li + li {
+ border: 0;
+ background: none;
+ width: 70%;
+ }
+
+
+ ul.profile li + li h2, ul.profile li + li p {
+ color: rgb(46,55,68);
+ text-shadow: #fff 0 1px 0;
+ margin: 0;
+ }
+
+ ul.profile li + li h2 {
+ font: bold 18px/22px Helvetica;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ }
+
+ ul.profile li + li p {
+ font: 14px/18px Helvetica;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ }
+
+
+ /* any A element inside this kind of field list will scale 62x62 */
+
+ ul.profile li a {
+ display: block;
+ width: 62px;
+ height: 62px;
+ color: transparent;
+ }
+
+
+
+ /***** PLASTIC LISTS *****/
+
+ body#plastic {
+ margin: 0;
+ padding: 0;
+ background: rgb(173,173,173);
+ }
+
+ body#plastic ul {
+ -webkit-border-radius: 0;
+ margin: 0;
+ border-left: 0;
+ border-right: 0;
+ border-top: 0;
+ background-color: rgb(173,173,173);
+ }
+
+
+ body#plastic ul li {
+ -webkit-border-radius: 0;
+ border-top: 1px solid rgb(191,191,191);
+ border-bottom: 1px solid rgb(157,157,157);
+ }
+
+
+ body#plastic ul li:nth-child(odd) {
+ background-color: rgb(152,152,152);
+ border-top: 1px solid rgb(181,181,181);
+ border-bottom: 1px solid rgb(138,138,138);
+ }
+
+
+ body#plastic ul + p {
+ font-size: 11px;
+ color: #2f3237;
+ text-shadow: none;
+ padding: 10px 10px;
+ }
+
+ body#plastic ul + p strong {
+ font-size: 14px;
+ line-height: 18px;
+ text-shadow: #fff 0 1px 0;
+ }
+
+ body#plastic ul li a {
+ text-shadow: rgb(211,211,211) 0 1px 0;
+ }
+
+ body#plastic ul li:nth-child(odd) a {
+ text-shadow: rgb(191,191,191) 0 1px 0;
+ }
+
+
+ body#plastic ul li small {
+ color: #3C3C3C;
+ text-shadow: rgb(211,211,211) 0 1px 0;
+ font-size: 13px;
+ font-weight: bold;
+ text-transform: uppercase;
+ line-height: 24px;
+ }
+
+
+
+ /**** MINI & BIG BANNERS ****/
+
+ #plastic ul.minibanner, #plastic ul.bigbanner {
+ margin: 10px;
+ border: 0;
+ height: 81px;
+ clear: both;
+ }
+
+ #plastic ul.bigbanner {
+ height: 140px !important;
+ }
+
+ #plastic ul.minibanner li {
+ border: 1px solid rgb(138,138,138);
+ background-color: rgb(152,152,152);
+ width: 145px;
+ height: 81px;
+ float: left;
+ -webkit-border-radius: 5px;
+ padding: 0;
+ }
+
+ #plastic ul.bigbanner li {
+ border: 1px solid rgb(138,138,138);
+ background-color: rgb(152,152,152);
+ width: 296px;
+ height: 140px;
+ float: left;
+ -webkit-border-radius: 5px;
+ padding: 0;
+ margin-bottom: 4px;
+ }
+
+ #plastic ul.minibanner li:first-child {
+ margin-right: 6px;
+ }
+
+
+ #plastic ul.minibanner li a {
+ color: transparent;
+ text-shadow: none;
+ display: block;
+ width: 145px;
+ height: 81px;
+ }
+
+ #plastic ul.bigbanner li a {
+ color: transparent;
+ text-shadow: none;
+ display: block;
+ width: 296px;
+ height: 145px;
+ }
+
+
+
+ /**** CHAT ****/
+
+
+ body#chat {
+ background: #DBE1ED;
+ }
+
+ body#chat div.bubble {
+ margin: 10px 10px 0 0px;
+ width: 80%;
+ clear: both;
+ }
+
+
+
+ body#chat div.right {
+ float: right;
+ }
+
+ body#chat div.left {
+ float: left;
+ }
+
+
+ body#chat div.right p {
+ border-width: 10px 20px 12px 10px;
+ }
+
+ body#chat div.left p {
+ border-width: 10px 10px 12px 20px;
+ }
+
+ /* lefties */
+
+ body#chat div.left p.lime {
+ -webkit-border-image: url(../images/chat_bubbles_lime_l.png) 10 10 13 19;
+ }
+
+ body#chat div.left p.lemon {
+ -webkit-border-image: url(../images/chat_bubbles_lemon_l.png) 10 10 13 19;
+ }
+
+ body#chat div.left p.orange {
+ -webkit-border-image: url(../images/chat_bubbles_orange_l.png) 10 10 13 19;
+ }
+
+ body#chat div.left p.aqua {
+ -webkit-border-image: url(../images/chat_bubbles_aqua_l.png) 10 10 13 19;
+ }
+
+ body#chat div.left p.purple {
+ -webkit-border-image: url(../images/chat_bubbles_purple_l.png) 10 10 13 19;
+ }
+
+ body#chat div.left p.pink {
+ -webkit-border-image: url(../images/chat_bubbles_pink_l.png) 10 10 13 19;
+ }
+
+ body#chat div.left p.graphite {
+ -webkit-border-image: url(../images/chat_bubbles_graphite_l.png) 10 10 13 19;
+ }
+
+ body#chat div.left p.clear {
+ -webkit-border-image: url(../images/chat_bubbles_clear_l.png) 10 10 13 19;
+ }
+
+
+
+
+ /*rights*/
+
+ body#chat div.right p.aqua {
+ -webkit-border-image: url(../images/chat_bubbles_aqua_r.png) 10 19 13 10;
+ }
+
+ body#chat div.right p.lemon {
+ -webkit-border-image: url(../images/chat_bubbles_lemon_r.png) 10 19 13 10;
+ }
+
+ body#chat div.right p.lime {
+ -webkit-border-image: url(../images/chat_bubbles_lime_r.png) 10 19 13 10;
+ }
+
+ body#chat div.right p.purple {
+ -webkit-border-image: url(../images/chat_bubbles_purple_r.png) 10 19 13 10;
+ }
+
+ body#chat div.right p.pink {
+ -webkit-border-image: url(../images/chat_bubbles_pink_r.png) 10 19 13 10;
+ }
+
+ body#chat div.right p.graphite {
+ -webkit-border-image: url(../images/chat_bubbles_graphite_r.png) 10 19 13 10;
+ }
+
+ body#chat div.right p.clear {
+ -webkit-border-image: url(../images/chat_bubbles_clear_r.png) 10 19 13 10;
+ }
+
+
+
+
+
+
+
+ body#chat div.bubble p {
+ color: #000;
+ font-size: 16px;
+ margin: 0;
+ }
+
+ body#chat div.bubble + p {
+ color: #666;
+ text-align: center;
+ font-size: 12px;
+ font-weight: bold;
+ margin: 0;
+ padding: 10px 0 0 0;
+ clear: both;
+ }
+
+
+
+
+
+
+ /**** image grids ****/
+
+
+ body#images {
+ background: #fff;
+ margin: 0;
+ }
+
+ body#images ul {
+ margin: 4px 4px 4px 0;
+ border: 0;
+ -webkit-border-radius: 0;
+ }
+
+ body#images ul li {
+ border: 1px solid #C0D5DD;
+ -webkit-border-radius: 0;
+ width: 73px;
+ height: 73px;
+ float: left;
+ margin: 0 0 4px 4px;
+ background: #F4FBFE url(../images/image-loading.gif) no-repeat center center;
+ padding: 0;
+ }
+
+ body#images ul li a {
+ display: block;
+ width: 100%;
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ }
+
+
+ /*** BLANK PAGES ***/
+
+ body#blank {
+ background: #fff;
+ }
+
+
+ body#blank p {
+ color: #898989;
+ text-align: center;
+ margin: 250px 0 0 0;
+ }
+
+
+
+
+ /**** ICONFIED LIST ****/
+
+
+ ul li a img.ico, ul li img.ico {
+ float: left;
+ display: block;
+ margin: -4px 10px -4px -1px;
+ }
+
+
\ No newline at end of file
diff --git a/iphone/stylesheets/table.css b/iphone/stylesheets/table.css
new file mode 100644
index 0000000..c22a2e6
--- /dev/null
+++ b/iphone/stylesheets/table.css
@@ -0,0 +1,28 @@
+span.rank {
+ float: left;
+ width: 8%;
+}
+
+span.name {
+ float: left;
+ width: 50%;
+}
+
+span.played {
+ float: left;
+ width: 12%;
+}
+
+span.gd {
+ float: left;
+ width: 12%;
+}
+
+span.pts {
+ float: left;
+ width: 12%;
+}
+
+p.standing {
+ height: 7px;
+}
\ No newline at end of file
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index 1e62060..b1d5f56 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,60 +1,71 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
-EPL.Table = function() {
+EPL.Table = function(is_iphone) {
this.table = [];
+ this.is_iphone = is_iphone;
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
$.getJSON("/js/epl/all_teams.js",
function(data) {
for(var i = 0; i < data.length; i++) {
self.table.push(data[i]);
- self.write_team_standings_to_view(data[i], i + 1);
+ if(self.is_iphone) {
+ self.write_team_standings_to_iphone_view(data[i], i + 1);
+ } else {
+ self.write_team_standings_to_normal_view(data[i], i + 1);
+ }
}
self.initialize_fixtures_bindings();
});
};
EPL.Table.prototype.initialize_fixtures_bindings = function() {
var self = this;
$("a.fixtures").bind("click", function(e) {
var id = e.currentTarget.id;
self.show_fixtures_view(id);
return false;
});
};
EPL.Table.prototype.show_fixtures_view = function(id) {
var self = this;
- var html = "<div id=\"fixtures_" + id + "\">";
+ var html = "<span id=\"fixtures_" + id + "\">";
$.getJSON("/js/epl/teams/fixtures/" + id + ".js",
function(fixtures) {
for(var i = 0; i < fixtures.length; i++) {
- html += "<div id=\"fixtures_" + id + "_" + (i + 1) + "\">";
- html += "<p><b>" + fixtures[i].competition + "</b></p>";
- html += "<p><i>" + fixtures[i].details + "</i></p>";
- html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
- html += "</div><hr />";
+ html += "<span id=\"fixtures_" + id + "_" + (i + 1) + "\">";
+ html += "<span><b>" + fixtures[i].competition + "</b></span>";
+ html += "<span><i>" + fixtures[i].details + "</i></span>";
+ html += "<span><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></span>";
+ html += "</span><hr />";
}
- html += "</div>";
- $('div#long_form_div').replaceWith(html);
+ html += "</span>";
+ $('p#long_form_p').replaceWith(html);
});
};
-EPL.Table.prototype.write_team_standings_to_view = function(team, rank) {
+EPL.Table.prototype.write_team_standings_to_iphone_view = function(team, rank) {
+ $('#epl_iphone_table').append(
+ "<li class=\"arrow\"><p class=\"standing\"><span class=\"rank\">" + rank + "</span><span class=\"name\">" + team.name + "</span><span class=\"played\">" + team.total_played + "</span><span class=\"gd\">" + team.goal_difference + "</span><span class=\"pts\">" + team.points + "</span></p></li>"
+ );
+};
+
+EPL.Table.prototype.write_team_standings_to_normal_view = function(team, rank) {
$('#epl_long_form_table').append(
"<tr>" +
"<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
"<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
"<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
"<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
"<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
"<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
"<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
"<td>" + team.points + "</td>" +
"</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
72a815007c18b526aeb53325564ea6154543ebfe
|
Remove console.debug
|
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index b75f505..1e62060 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,63 +1,60 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
EPL.Table = function() {
this.table = [];
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
$.getJSON("/js/epl/all_teams.js",
function(data) {
for(var i = 0; i < data.length; i++) {
self.table.push(data[i]);
self.write_team_standings_to_view(data[i], i + 1);
}
self.initialize_fixtures_bindings();
});
};
EPL.Table.prototype.initialize_fixtures_bindings = function() {
var self = this;
$("a.fixtures").bind("click", function(e) {
var id = e.currentTarget.id;
self.show_fixtures_view(id);
return false;
});
};
EPL.Table.prototype.show_fixtures_view = function(id) {
var self = this;
var html = "<div id=\"fixtures_" + id + "\">";
- console.debug("Going to get JSON");
$.getJSON("/js/epl/teams/fixtures/" + id + ".js",
function(fixtures) {
- console.debug("Got Fixtures");
-
for(var i = 0; i < fixtures.length; i++) {
html += "<div id=\"fixtures_" + id + "_" + (i + 1) + "\">";
html += "<p><b>" + fixtures[i].competition + "</b></p>";
html += "<p><i>" + fixtures[i].details + "</i></p>";
html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
html += "</div><hr />";
}
html += "</div>";
$('div#long_form_div').replaceWith(html);
});
};
EPL.Table.prototype.write_team_standings_to_view = function(team, rank) {
$('#epl_long_form_table').append(
"<tr>" +
"<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
"<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
"<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
"<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
"<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
"<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
"<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
"<td>" + team.points + "</td>" +
"</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
5065996596e4a362a887380e33edd9bff57dbb54
|
Link to fixtures
|
diff --git a/index.html b/index.html
index 643012c..26efefd 100644
--- a/index.html
+++ b/index.html
@@ -1,34 +1,34 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>EPL's GitHub</title>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
- <h3>English Premier League</h3>
+ <h3><a href="/">English Premier League</a></h3>
<div id="long_form_div">
<table id="epl_long_form_table">
<tbody>
<tr>
<td></td><td>Team</td><td>P</td><td>HW</td><td>HD</td><td>HL</td><td>HF</td><td>HA</td><td>AW</td><td>AD</td><td>AL</td><td>AF</td><td>AA</td><td>GD</td><td>Points</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table();
TABLE.initialize_teams();
});
</script>
</body>
</html>
\ No newline at end of file
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
index 3ed9591..b75f505 100644
--- a/js/models/epl_table.js
+++ b/js/models/epl_table.js
@@ -1,30 +1,63 @@
EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
EPL.Table = function() {
this.table = [];
};
EPL.Table.prototype.initialize_teams = function() {
var self = this;
-
$.getJSON("/js/epl/all_teams.js",
function(data) {
for(var i = 0; i < data.length; i++) {
- team = data[i];
- self.table.push(team);
-
- $('#epl_long_form_table').append(
- "<tr>" +
- "<td>" + (i + 1) + "</td><td>" + team.name + "</td>" +
- "<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
- "<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
- "<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
- "<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
- "<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
- "<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
- "<td>" + team.points + "</td>" +
- "</tr>");
+ self.table.push(data[i]);
+ self.write_team_standings_to_view(data[i], i + 1);
}
+ self.initialize_fixtures_bindings();
+ });
+};
+
+EPL.Table.prototype.initialize_fixtures_bindings = function() {
+ var self = this;
+
+ $("a.fixtures").bind("click", function(e) {
+ var id = e.currentTarget.id;
+ self.show_fixtures_view(id);
+ return false;
});
+};
+
+EPL.Table.prototype.show_fixtures_view = function(id) {
+ var self = this;
+ var html = "<div id=\"fixtures_" + id + "\">";
+ console.debug("Going to get JSON");
+
+ $.getJSON("/js/epl/teams/fixtures/" + id + ".js",
+ function(fixtures) {
+ console.debug("Got Fixtures");
+
+ for(var i = 0; i < fixtures.length; i++) {
+ html += "<div id=\"fixtures_" + id + "_" + (i + 1) + "\">";
+ html += "<p><b>" + fixtures[i].competition + "</b></p>";
+ html += "<p><i>" + fixtures[i].details + "</i></p>";
+ html += "<p><b>" + fixtures[i].date + ", " + fixtures[i].gmt_time + " GMT</b></p>";
+ html += "</div><hr />";
+ }
+ html += "</div>";
+ $('div#long_form_div').replaceWith(html);
+ });
+};
+
+EPL.Table.prototype.write_team_standings_to_view = function(team, rank) {
+ $('#epl_long_form_table').append(
+ "<tr>" +
+ "<td>" + rank + "</td><td><a class=\"fixtures\" id=\"" + team.id + "\" href=\"/teams/fixtures/" + team.id + "\">" + team.name + "</a></td>" +
+ "<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
+ "<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
+ "<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
+ "<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
+ "<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
+ "<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
+ "<td>" + team.points + "</td>" +
+ "</tr>");
};
\ No newline at end of file
|
arunthampi/epl.github.com
|
8c174b7f03fc1482e0e1a85b0ecfbfd6b4528499
|
Add headings for the table
|
diff --git a/index.html b/index.html
index 1b33753..643012c 100644
--- a/index.html
+++ b/index.html
@@ -1,28 +1,34 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>EPL's GitHub</title>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="/js/models/epl_table.js" type="text/javascript"></script>
<script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
<h3>English Premier League</h3>
<div id="long_form_div">
<table id="epl_long_form_table">
+ <tbody>
+ <tr>
+<td></td><td>Team</td><td>P</td><td>HW</td><td>HD</td><td>HL</td><td>HF</td><td>HA</td><td>AW</td><td>AD</td><td>AL</td><td>AF</td><td>AA</td><td>GD</td><td>Points</td>
+ </tr>
+ </tbody>
+
</table>
</div>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function($) {
TABLE = new EPL.Table();
TABLE.initialize_teams();
});
</script>
</body>
</html>
\ No newline at end of file
|
arunthampi/epl.github.com
|
1607fbfea3d4c07a2f204b6e8f9c248c4d090cc4
|
Initialize page using JS
|
diff --git a/index.html b/index.html
index 775151b..1b33753 100644
--- a/index.html
+++ b/index.html
@@ -1,14 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>EPL's GitHub</title>
<script src="/js/jquery-1.3.1.min.js" type="text/javascript"></script>
+ <script src="/js/models/epl_table.js" type="text/javascript"></script>
+ <script src="/js/models/epl_team.js" type="text/javascript"></script>
</head>
<body>
+ <h3>English Premier League</h3>
+ <div id="long_form_div">
+ <table id="epl_long_form_table">
+ </table>
+ </div>
+<script type="text/javascript" charset="utf-8">
+//<![CDATA[
+ jQuery(function($) {
+ TABLE = new EPL.Table();
+ TABLE.initialize_teams();
+ });
+</script>
</body>
</html>
\ No newline at end of file
|
arunthampi/epl.github.com
|
895995349848e1622a71345a63ecece8cddf6cf0
|
Models for getting Table and Team information
|
diff --git a/js/models/epl_table.js b/js/models/epl_table.js
new file mode 100644
index 0000000..3ed9591
--- /dev/null
+++ b/js/models/epl_table.js
@@ -0,0 +1,30 @@
+EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
+
+EPL.Table = function() {
+ this.table = [];
+};
+
+
+EPL.Table.prototype.initialize_teams = function() {
+ var self = this;
+
+ $.getJSON("/js/epl/all_teams.js",
+ function(data) {
+ for(var i = 0; i < data.length; i++) {
+ team = data[i];
+ self.table.push(team);
+
+ $('#epl_long_form_table').append(
+ "<tr>" +
+ "<td>" + (i + 1) + "</td><td>" + team.name + "</td>" +
+ "<td>" + team.total_played + "</td><td>" + team.home_won + "</td>" +
+ "<td>" + team.home_drawn + "</td><td>" + team.home_lost + "</td>" +
+ "<td>" + team.home_for + "</td><td>" + team.home_against + "</td>" +
+ "<td>" + team.away_won + "</td><td>" + team.away_drawn + "</td>" +
+ "<td>" + team.away_lost + "</td><td>" + team.away_for + "</td>" +
+ "<td>" + team.away_against + "</td><td>" + team.goal_difference + "</td>" +
+ "<td>" + team.points + "</td>" +
+ "</tr>");
+ }
+ });
+};
\ No newline at end of file
diff --git a/js/models/epl_team.js b/js/models/epl_team.js
new file mode 100644
index 0000000..0a059f7
--- /dev/null
+++ b/js/models/epl_team.js
@@ -0,0 +1,5 @@
+EPL = typeof EPL == 'undefined' || !EPL ? {} : EPL;
+
+EPL.Team = function() {
+ this.table = [];
+};
\ No newline at end of file
|
stefanfoulis/django-multilingual
|
9c43fa86723a82ee30b422235d88f1e79410dacb
|
values and values_list will raise a NotImplementedError until we get around to add those.
|
diff --git a/multilingual/query.py b/multilingual/query.py
index 7cbaf58..72c59cc 100644
--- a/multilingual/query.py
+++ b/multilingual/query.py
@@ -69,512 +69,518 @@ class MultilingualQuery(Query):
defaults = {
'extra_join': self.extra_join,
'include_translation_data': self.include_translation_data,
}
defaults.update(kwargs)
return super(MultilingualQuery, self).clone(klass=klass, **defaults)
def pre_sql_setup(self):
"""Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualQuery, self).pre_sql_setup()
if not self.include_translation_data:
return
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_id in get_language_id_list():
table_alias = get_translation_table_alias(trans_table_name,
language_id)
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(self.model._meta.pk.column),
qn2(table_alias),
language_id))
self.extra_join[table_alias] = trans_join
def get_from_clause(self):
"""Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualQuery, self).get_from_clause()
if not self.include_translation_data:
return result
from_ = result[0]
for join in self.extra_join.values():
from_.append(join)
return (from_, result[1])
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None, process_extras=True):
"""Copied from add_filter to generate WHERES for translation fields.
"""
arg, value = filter_expr
parts = arg.split(LOOKUP_SEP)
if not parts:
raise FieldError("Cannot parse keyword query %r" % arg)
# Work out the lookup type and remove it from 'parts', if necessary.
if len(parts) == 1 or parts[-1] not in self.query_terms:
lookup_type = 'exact'
else:
lookup_type = parts.pop()
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
# uses of None as a query value.
if value is None:
if lookup_type != 'exact':
raise ValueError("Cannot use None as a query value")
lookup_type = 'isnull'
value = True
elif (value == '' and lookup_type == 'exact' and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value = True
elif callable(value):
value = value()
opts = self.get_meta()
alias = self.get_initial_alias()
allow_many = trim or not negate
try:
field, target, opts, join_list, last, extra_filters = self.setup_joins(
parts, opts, alias, True, allow_many, can_reuse=can_reuse,
negate=negate, process_extras=process_extras)
except MultiJoin, e:
self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]),
can_reuse)
return
#NOTE: here comes Django Multilingual
if hasattr(opts, 'translation_model'):
field_name = parts[-1]
if field_name == 'pk':
field_name = opts.pk.name
translation_opts = opts.translation_model._meta
if field_name in translation_opts.translated_fields.keys():
field, model, direct, m2m = opts.get_field_by_name(field_name)
if model == opts.translation_model:
language_id = translation_opts.translated_fields[field_name][1]
if language_id is None:
language_id = get_default_language()
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
self.where.add(constraint_tuple(new_table, field.column, field, lookup_type, value), connector)
return
final = len(join_list)
penultimate = last.pop()
if penultimate == final:
penultimate = last.pop()
if trim and len(join_list) > 1:
extra = join_list[penultimate:]
join_list = join_list[:penultimate]
final = penultimate
penultimate = last.pop()
col = self.alias_map[extra[0]][LHS_JOIN_COL]
for alias in extra:
self.unref_alias(alias)
else:
col = target.column
alias = join_list[-1]
while final > 1:
# An optimization: if the final join is against the same column as
# we are comparing against, we can go back one step in the join
# chain and compare against the lhs of the join instead (and then
# repeat the optimization). The result, potentially, involves less
# table joins.
join = self.alias_map[alias]
if col != join[RHS_JOIN_COL]:
break
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
join_list = join_list[:-1]
final -= 1
if final == penultimate:
penultimate = last.pop()
if (lookup_type == 'isnull' and value is True and not negate and
final > 1):
# If the comparison is against NULL, we need to use a left outer
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed as it's less
# efficient at the database level.
self.promote_alias(join_list[penultimate])
if connector == OR:
# Some joins may need to be promoted when adding a new filter to a
# disjunction. We walk the list of new joins and where it diverges
# from any previous joins (ref count is 1 in the table list), we
# make the new additions (and any existing ones not used in the new
# join list) an outer join.
join_it = iter(join_list)
table_it = iter(self.tables)
join_it.next(), table_it.next()
table_promote = False
join_promote = False
for join in join_it:
table = table_it.next()
if join == table and self.alias_refcount[join] > 1:
continue
join_promote = self.promote_alias(join)
if table != join:
table_promote = self.promote_alias(table)
break
self.promote_alias_chain(join_it, join_promote)
self.promote_alias_chain(table_it, table_promote)
self.where.add(constraint_tuple(alias, col, field, lookup_type, value), connector)
if negate:
self.promote_alias_chain(join_list)
if lookup_type != 'isnull':
if final > 1:
for alias in join_list:
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
j_col = self.alias_map[alias][RHS_JOIN_COL]
entry = self.where_class()
entry.add(constraint_tuple(alias, j_col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
break
elif not (lookup_type == 'in' and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# it's short-circuited in the Where class.
entry = self.where_class()
entry.add(constraint_tuple(alias, col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
if can_reuse is not None:
can_reuse.update(join_list)
if process_extras:
for filter in extra_filters:
self.add_filter(filter, negate=negate, can_reuse=can_reuse,
process_extras=False)
def _setup_joins_with_translation(self, names, opts, alias,
dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None,
negate=False, process_extras=True):
"""
This is based on a full copy of Query.setup_joins because
currently I see no way to handle it differently.
TO DO: there might actually be a way, by splitting a single
multi-name setup_joins call into separate calls. Check it.
-- [email protected]
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are joining to), 'alias' is the alias for the
table we are joining to. If dupe_multis is True, any many-to-many or
many-to-one joins will always create a new alias (necessary for
disjunctive filters).
Returns the final field involved in the join, the target database
column (used for any 'where' constraint), the final 'opts' value and the
list of tables joined.
"""
joins = [alias]
last = [0]
dupe_set = set()
exclusions = set()
extra_filters = []
for pos, name in enumerate(names):
try:
exclusions.add(int_alias)
except NameError:
pass
exclusions.add(alias)
last.append(len(joins))
if name == 'pk':
name = opts.pk.name
try:
field, model, direct, m2m = opts.get_field_by_name(name)
except FieldDoesNotExist:
for f in opts.fields:
if allow_explicit_fk and name == f.attname:
# XXX: A hack to allow foo_id to work in values() for
# backwards compatibility purposes. If we dropped that
# feature, this could be removed.
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
names = opts.get_all_field_names()
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
if not allow_many and (m2m or not direct):
for alias in joins:
self.unref_alias(alias)
raise MultiJoin(pos + 1)
#NOTE: Start Django Multilingual specific code
if hasattr(opts, 'translation_model'):
translation_opts = opts.translation_model._meta
if model == opts.translation_model:
language_id = translation_opts.translated_fields[name][1]
if language_id is None:
language_id = get_default_language()
#TODO: check alias
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(model._meta.db_table),
qn2(new_table),
qn2(new_table),
qn(master_table_name),
qn2(model._meta.pk.column),
qn2(new_table),
language_id))
self.extra_join[new_table] = trans_join
target = field
continue
#NOTE: End Django Multilingual specific code
elif model:
# The field lives on a base class of the current model.
for int_model in opts.get_base_chain(model):
lhs_col = opts.parents[int_model].column
dedupe = lhs_col in opts.duplicate_targets
if dedupe:
exclusions.update(self.dupe_avoidance.get(
(id(opts), lhs_col), ()))
dupe_set.add((opts, lhs_col))
opts = int_model._meta
alias = self.join((alias, opts.db_table, lhs_col,
opts.pk.column), exclusions=exclusions)
joins.append(alias)
exclusions.add(alias)
for (dupe_opts, dupe_col) in dupe_set:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
cached_data = opts._join_cache.get(name)
orig_opts = opts
dupe_col = direct and field.column or field.field.column
dedupe = dupe_col in opts.duplicate_targets
if dupe_set or dedupe:
if dedupe:
dupe_set.add((opts, dupe_col))
exclusions.update(self.dupe_avoidance.get((id(opts), dupe_col),
()))
if process_extras and hasattr(field, 'extra_filters'):
extra_filters.extend(field.extra_filters(names, pos, negate))
if direct:
if m2m:
# Many-to-many field defined on the current model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_column_name()
opts = field.rel.to._meta
table2 = opts.db_table
from_col2 = field.m2m_reverse_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
if int_alias == table2 and from_col2 == to_col2:
joins.append(int_alias)
alias = int_alias
else:
alias = self.join(
(int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
elif field.rel:
# One-to-one or many-to-one field
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
opts = field.rel.to._meta
target = field.rel.get_related_field()
table = opts.db_table
from_col = field.column
to_col = target.column
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
exclusions=exclusions, nullable=field.null)
joins.append(alias)
else:
# Non-relation fields.
target = field
break
else:
orig_field = field
field = field.field
if m2m:
# Many-to-many field defined on the target model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_reverse_name()
opts = orig_field.opts
table2 = opts.db_table
from_col2 = field.m2m_column_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
alias = self.join((int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
else:
# One-to-many field (ForeignKey defined on the target model)
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
local_field = opts.get_field_by_name(
field.rel.field_name)[0]
opts = orig_field.opts
table = opts.db_table
from_col = local_field.column
to_col = field.column
target = opts.pk
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.append(alias)
for (dupe_opts, dupe_col) in dupe_set:
try:
self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias)
except NameError:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None, negate=False,
process_extras=True):
if not self.include_translation_data:
return super(MultilingualQuery, self).setup_joins(names, opts, alias,
dupe_multis, allow_many,
allow_explicit_fk,
can_reuse, negate,
process_extras)
else:
return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
allow_many, allow_explicit_fk,
can_reuse, negate, process_extras)
def get_count(self):
# optimize for the common special case: count without any
# filters
if ((not (self.select or self.where or self.extra_where))
and self.include_translation_data):
obj = self.clone(extra_select = {},
extra_join = {},
include_translation_data = False)
return obj.get_count()
else:
return super(MultilingualQuery, self).get_count()
class MultilingualModelQuerySet(QuerySet):
"""
A specialized QuerySet that knows how to handle translatable
fields in ordering and filtering methods.
"""
def __init__(self, model=None, query=None):
query = query or MultilingualQuery(model, connection)
super(MultilingualModelQuerySet, self).__init__(model, query)
def for_language(self, language_id_or_code):
"""
Set the default language for all objects returned with this
query.
"""
clone = self._clone()
clone._default_language = get_language_id_from_id_or_code(language_id_or_code)
return clone
def iterator(self):
"""
Add the default language information to all returned objects.
"""
default_language = getattr(self, '_default_language', None)
for obj in super(MultilingualModelQuerySet, self).iterator():
obj._default_language = default_language
yield obj
def _clone(self, klass=None, **kwargs):
"""
Override _clone to preserve additional information needed by
MultilingualModelQuerySet.
"""
clone = super(MultilingualModelQuerySet, self)._clone(klass, **kwargs)
clone._default_language = getattr(self, '_default_language', None)
return clone
def order_by(self, *field_names):
if hasattr(self.model._meta, 'translation_model'):
trans_opts = self.model._meta.translation_model._meta
new_field_names = []
for field_name in field_names:
prefix = ''
if field_name[0] == '-':
prefix = '-'
field_name = field_name[1:]
field_and_lang = trans_opts.translated_fields.get(field_name)
if field_and_lang:
field, language_id = field_and_lang
if language_id is None:
language_id = getattr(self, '_default_language', None)
real_name = get_translated_field_alias(field.attname,
language_id)
new_field_names.append(prefix + real_name)
else:
new_field_names.append(prefix + field_name)
return super(MultilingualModelQuerySet, self).extra(order_by=new_field_names)
else:
return super(MultilingualModelQuerySet, self).order_by(*field_names)
+
+ def values(self, *fields):
+ raise NotImplementedError
+
+ def values_list(self, *fields, **kwargs):
+ raise NotImplementedError
|
stefanfoulis/django-multilingual
|
9a2df3dc815b7005815695d65dee414a63c7e12b
|
More pep8 cleanup.
|
diff --git a/multilingual/admin.py b/multilingual/admin.py
index fbc7164..ccd35ab 100644
--- a/multilingual/admin.py
+++ b/multilingual/admin.py
@@ -1,203 +1,211 @@
from django.contrib import admin
from django.forms.models import BaseInlineFormSet
from django.forms.fields import BooleanField
from django.forms.formsets import DELETION_FIELD_NAME
from django.forms.util import ErrorDict
from django.utils.translation import ugettext as _
from multilingual.languages import *
from multilingual.utils import is_multilingual_model
+
def _translation_form_full_clean(self, previous_full_clean):
"""
There is a bug in Django that causes inline forms to be
validated even if they are marked for deletion.
This function fixes that by disabling validation
completely if the delete field is marked and only copying
the absolutely required fields: PK and FK to parent.
TODO: create a fix for Django, have it accepted into trunk and get
rid of this monkey patch.
-
"""
def cleaned_value(name):
field = self.fields[name]
val = field.widget.value_from_datadict(self.data, self.files,
self.add_prefix(name))
return field.clean(val)
delete = cleaned_value(DELETION_FIELD_NAME)
if delete:
# this object is to be skipped or deleted, so only
# construct the minimal cleaned_data
self.cleaned_data = {'DELETE': delete,
'id': cleaned_value('id')}
self._errors = ErrorDict()
else:
return previous_full_clean()
+
class TranslationInlineFormSet(BaseInlineFormSet):
def _construct_forms(self):
## set the right default values for language_ids of empty (new) forms
super(TranslationInlineFormSet, self)._construct_forms()
-
+
empty_forms = []
lang_id_list = get_language_id_list()
lang_to_form = dict(zip(lang_id_list, [None] * len(lang_id_list)))
for form in self.forms:
language_id = form.initial.get('language_id')
if language_id:
lang_to_form[language_id] = form
else:
empty_forms.append(form)
for language_id in lang_id_list:
form = lang_to_form[language_id]
if form is None:
form = empty_forms.pop(0)
form.initial['language_id'] = language_id
def add_fields(self, form, index):
super(TranslationInlineFormSet, self).add_fields(form, index)
previous_full_clean = form.full_clean
- form.full_clean = lambda: _translation_form_full_clean(form, previous_full_clean)
+ form.full_clean = lambda: _translation_form_full_clean(form, \
+ previous_full_clean)
+
class TranslationModelAdmin(admin.StackedInline):
template = "admin/edit_inline_translations_newforms.html"
fk_name = 'master'
extra = get_language_count()
max_num = get_language_count()
formset = TranslationInlineFormSet
+
class ModelAdminClass(admin.ModelAdmin.__metaclass__):
"""
A metaclass for ModelAdmin below.
"""
def __new__(cls, name, bases, attrs):
# Move prepopulated_fields somewhere where Django won't see
# them. We have to handle them ourselves.
prepopulated_fields = attrs.get('prepopulated_fields', {})
attrs['prepopulated_fields'] = {}
attrs['_dm_prepopulated_fields'] = prepopulated_fields
return super(ModelAdminClass, cls).__new__(cls, name, bases, attrs)
+
class ModelAdmin(admin.ModelAdmin):
"""
All model admins for multilingual models must inherit this class
instead of django.contrib.admin.ModelAdmin.
"""
__metaclass__ = ModelAdminClass
def _media(self):
media = super(ModelAdmin, self)._media()
if getattr(self.__class__, '_dm_prepopulated_fields', None):
from django.conf import settings
media.add_js(['%sjs/urlify.js' % (settings.ADMIN_MEDIA_PREFIX,)])
return media
media = property(_media)
def render_change_form(self, request, context, add=False, change=False,
form_url='', obj=None):
# I'm overriding render_change_form to inject information
# about prepopulated_fields
trans_model = self.model._meta.translation_model
trans_fields = trans_model._meta.translated_fields
adminform = context['adminform']
form = adminform.form
def field_name_to_fake_field(field_name):
"""
Return something that looks like a form field enough to
fool prepopulated_fields_js.html
For field_names of real fields in self.model this actually
returns a real form field.
"""
try:
field, language_id = trans_fields[field_name]
if language_id is None:
language_id = get_default_language()
# TODO: we have this mapping between language_id and
# field id in two places -- here and in
# edit_inline_translations_newforms.html
# It is not DRY.
field_idx = language_id - 1
- ret = {'auto_id': 'id_translations-%d-%s' % (field_idx, field.name)
- }
+ ret = {'auto_id': 'id_translations-%d-%s' % \
+ (field_idx, field.name)}
except:
ret = form[field_name]
return ret
adminform.prepopulated_fields = [{
'field': field_name_to_fake_field(field_name),
'dependencies': [field_name_to_fake_field(f) for f in dependencies]
} for field_name, dependencies in self._dm_prepopulated_fields.items()]
return super(ModelAdmin, self).render_change_form(request, context,
- add, change, form_url, obj)
+ add, change, form_url, obj)
+
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
- raise ValueError, ("%s.Translation must be a subclass "
- + " of multilingual.TranslationModelAdmin.") % cls.name
+ raise ValueError, ("%s.Translation must be a subclass " \
+ " of multilingual.TranslationModelAdmin.") % \
+ cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
return tr_cls
+
# TODO: multilingual_modeladmin_new should go away soon. The code will
# be split between the ModelAdmin class, its metaclass and validation
# code.
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
if is_multilingual_model(model):
if cls is admin.ModelAdmin:
# the model is being registered with the default
# django.contrib.admin.options.ModelAdmin. Replace it
# with our ModelAdmin, since it is safe to assume it is a
# simple call to admin.site.register without just model
# passed
# subclass it, because we need to set the inlines class
# attribute below
cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
# make sure it subclasses multilingual.ModelAdmin
if not issubclass(cls, ModelAdmin):
from warnings import warn
warn("%s should be registered with a subclass of "
" of multilingual.ModelAdmin." % model, DeprecationWarning)
# if the inlines already contain a class for the
# translation model, use it and don't create another one
translation_modeladmin = None
for inline in getattr(cls, 'inlines', []):
if inline.model == model._meta.translation_model:
translation_modeladmin = inline
if not translation_modeladmin:
translation_modeladmin = get_translation_modeladmin(cls, model)
if cls.inlines:
- cls.inlines = type(cls.inlines)((translation_modeladmin,)) + cls.inlines
+ cls.inlines = type(cls.inlines)((translation_modeladmin,)) + cls.inlines
else:
cls.inlines = [translation_modeladmin]
return admin.ModelAdmin._original_new_before_dm(cls, model, admin_site, obj)
+
def install_multilingual_modeladmin_new():
"""
Override ModelAdmin.__new__ to create automatic inline
editor for multilingual models.
"""
admin.ModelAdmin._original_new_before_dm = admin.ModelAdmin.__new__
admin.ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
-
diff --git a/multilingual/context_processors.py b/multilingual/context_processors.py
index bcdacb8..8d1ed12 100644
--- a/multilingual/context_processors.py
+++ b/multilingual/context_processors.py
@@ -1,10 +1,11 @@
-from multilingual.languages import get_language_code_list, \
- get_default_language_code
+from multilingual.languages import (
+ get_language_code_list,
+ get_default_language_code)
def multilingual(request):
"""
Returns context variables containing information about available languages.
"""
return {'LANGUAGE_CODES': get_language_code_list(),
'DEFAULT_LANGUAGE_CODE': get_default_language_code()}
diff --git a/multilingual/fields.py b/multilingual/fields.py
index 1248dcc..7e2ab91 100644
--- a/multilingual/fields.py
+++ b/multilingual/fields.py
@@ -1,6 +1,7 @@
from django.db import models
+
class TranslationForeignKey(models.ForeignKey):
"""
"""
pass
diff --git a/multilingual/manager.py b/multilingual/manager.py
index c073d5a..607bea5 100644
--- a/multilingual/manager.py
+++ b/multilingual/manager.py
@@ -1,15 +1,17 @@
from django.db import models
+
from multilingual.query import MultilingualModelQuerySet
from multilingual.languages import *
+
class Manager(models.Manager):
"""
A manager for multilingual models.
TO DO: turn this into a proxy manager that would allow developers
to use any manager they need. It should be sufficient to extend
and additionaly filter or order querysets returned by that manager.
"""
def get_query_set(self):
return MultilingualModelQuerySet(self.model)
diff --git a/multilingual/middleware.py b/multilingual/middleware.py
index 9f3241b..4c22f0a 100644
--- a/multilingual/middleware.py
+++ b/multilingual/middleware.py
@@ -1,22 +1,24 @@
from django.utils.translation import get_language
+
from multilingual.exceptions import LanguageDoesNotExist
from multilingual.languages import set_default_language
class DefaultLanguageMiddleware(object):
"""
Binds DEFAULT_LANGUAGE_CODE to django's currently selected language.
The effect of enabling this middleware is that translated fields can be
accessed by their name; i.e. model.field instead of model.field_en.
"""
+
def process_request(self, request):
assert hasattr(request, 'session'), "The DefaultLanguageMiddleware \
middleware requires session middleware to be installed. Edit your \
MIDDLEWARE_CLASSES setting to insert \
'django.contrib.sessions.middleware.SessionMiddleware'."
try:
set_default_language(get_language())
except LanguageDoesNotExist:
# Try without the territory suffix
set_default_language(get_language()[:2])
diff --git a/multilingual/query.py b/multilingual/query.py
index 6527479..7cbaf58 100644
--- a/multilingual/query.py
+++ b/multilingual/query.py
@@ -1,573 +1,580 @@
"""
Django-multilingual: a QuerySet subclass for models with translatable
fields.
This file contains the implementation for QSRF Django.
"""
import datetime
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models.fields import FieldDoesNotExist
from django.db.models.query import QuerySet, Q
from django.db.models.sql.query import Query
-from django.db.models.sql.datastructures import EmptyResultSet, Empty, \
- MultiJoin
+from django.db.models.sql.datastructures import (
+ EmptyResultSet,
+ Empty,
+ MultiJoin)
from django.db.models.sql.constants import *
from django.db.models.sql.where import WhereNode, EverythingNode, AND, OR
try:
# handle internal API changes in Django rev. 9700
from django.db.models.sql.where import Constraint
def constraint_tuple(alias, col, field, lookup_type, value):
return (Constraint(alias, col, field), lookup_type, value)
-
except ImportError:
# backwards compatibility, for Django versions 1.0 to rev. 9699
def constraint_tuple(alias, col, field, lookup_type, value):
return (alias, col, field, lookup_type, value)
-from multilingual.languages import (get_translation_table_alias, get_language_id_list,
- get_default_language, get_translated_field_alias,
- get_language_id_from_id_or_code)
+from multilingual.languages import (
+ get_translation_table_alias,
+ get_language_id_list,
+ get_default_language,
+ get_translated_field_alias,
+ get_language_id_from_id_or_code)
__ALL__ = ['MultilingualModelQuerySet']
+
class MultilingualQuery(Query):
+
def __init__(self, model, connection, where=WhereNode):
self.extra_join = {}
self.include_translation_data = True
extra_select = {}
super(MultilingualQuery, self).__init__(model, connection, where=where)
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
for language_id in get_language_id_list():
for fname in [f.attname for f in translation_opts.fields]:
table_alias = get_translation_table_alias(trans_table_name,
language_id)
field_alias = get_translated_field_alias(fname,
language_id)
extra_select[field_alias] = qn2(table_alias) + '.' + qn2(fname)
self.add_extra(extra_select, None, None, None, None, None)
self._trans_extra_select_count = len(self.extra_select)
def clone(self, klass=None, **kwargs):
defaults = {
'extra_join': self.extra_join,
'include_translation_data': self.include_translation_data,
}
defaults.update(kwargs)
return super(MultilingualQuery, self).clone(klass=klass, **defaults)
def pre_sql_setup(self):
"""Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualQuery, self).pre_sql_setup()
if not self.include_translation_data:
return
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_id in get_language_id_list():
table_alias = get_translation_table_alias(trans_table_name,
language_id)
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(self.model._meta.pk.column),
qn2(table_alias),
language_id))
self.extra_join[table_alias] = trans_join
def get_from_clause(self):
"""Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualQuery, self).get_from_clause()
if not self.include_translation_data:
return result
from_ = result[0]
for join in self.extra_join.values():
from_.append(join)
return (from_, result[1])
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None, process_extras=True):
"""Copied from add_filter to generate WHERES for translation fields.
"""
arg, value = filter_expr
parts = arg.split(LOOKUP_SEP)
if not parts:
raise FieldError("Cannot parse keyword query %r" % arg)
# Work out the lookup type and remove it from 'parts', if necessary.
if len(parts) == 1 or parts[-1] not in self.query_terms:
lookup_type = 'exact'
else:
lookup_type = parts.pop()
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
# uses of None as a query value.
if value is None:
if lookup_type != 'exact':
raise ValueError("Cannot use None as a query value")
lookup_type = 'isnull'
value = True
elif (value == '' and lookup_type == 'exact' and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value = True
elif callable(value):
value = value()
opts = self.get_meta()
alias = self.get_initial_alias()
allow_many = trim or not negate
try:
field, target, opts, join_list, last, extra_filters = self.setup_joins(
parts, opts, alias, True, allow_many, can_reuse=can_reuse,
negate=negate, process_extras=process_extras)
except MultiJoin, e:
self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]),
can_reuse)
return
#NOTE: here comes Django Multilingual
if hasattr(opts, 'translation_model'):
field_name = parts[-1]
if field_name == 'pk':
field_name = opts.pk.name
translation_opts = opts.translation_model._meta
if field_name in translation_opts.translated_fields.keys():
field, model, direct, m2m = opts.get_field_by_name(field_name)
if model == opts.translation_model:
language_id = translation_opts.translated_fields[field_name][1]
if language_id is None:
language_id = get_default_language()
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
self.where.add(constraint_tuple(new_table, field.column, field, lookup_type, value), connector)
return
final = len(join_list)
penultimate = last.pop()
if penultimate == final:
penultimate = last.pop()
if trim and len(join_list) > 1:
extra = join_list[penultimate:]
join_list = join_list[:penultimate]
final = penultimate
penultimate = last.pop()
col = self.alias_map[extra[0]][LHS_JOIN_COL]
for alias in extra:
self.unref_alias(alias)
else:
col = target.column
alias = join_list[-1]
while final > 1:
# An optimization: if the final join is against the same column as
# we are comparing against, we can go back one step in the join
# chain and compare against the lhs of the join instead (and then
# repeat the optimization). The result, potentially, involves less
# table joins.
join = self.alias_map[alias]
if col != join[RHS_JOIN_COL]:
break
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
join_list = join_list[:-1]
final -= 1
if final == penultimate:
penultimate = last.pop()
if (lookup_type == 'isnull' and value is True and not negate and
final > 1):
# If the comparison is against NULL, we need to use a left outer
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed as it's less
# efficient at the database level.
self.promote_alias(join_list[penultimate])
if connector == OR:
# Some joins may need to be promoted when adding a new filter to a
# disjunction. We walk the list of new joins and where it diverges
# from any previous joins (ref count is 1 in the table list), we
# make the new additions (and any existing ones not used in the new
# join list) an outer join.
join_it = iter(join_list)
table_it = iter(self.tables)
join_it.next(), table_it.next()
table_promote = False
join_promote = False
for join in join_it:
table = table_it.next()
if join == table and self.alias_refcount[join] > 1:
continue
join_promote = self.promote_alias(join)
if table != join:
table_promote = self.promote_alias(table)
break
self.promote_alias_chain(join_it, join_promote)
self.promote_alias_chain(table_it, table_promote)
self.where.add(constraint_tuple(alias, col, field, lookup_type, value), connector)
if negate:
self.promote_alias_chain(join_list)
if lookup_type != 'isnull':
if final > 1:
for alias in join_list:
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
j_col = self.alias_map[alias][RHS_JOIN_COL]
entry = self.where_class()
entry.add(constraint_tuple(alias, j_col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
break
elif not (lookup_type == 'in' and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# it's short-circuited in the Where class.
entry = self.where_class()
entry.add(constraint_tuple(alias, col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
if can_reuse is not None:
can_reuse.update(join_list)
if process_extras:
for filter in extra_filters:
self.add_filter(filter, negate=negate, can_reuse=can_reuse,
process_extras=False)
def _setup_joins_with_translation(self, names, opts, alias,
dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None,
negate=False, process_extras=True):
"""
This is based on a full copy of Query.setup_joins because
currently I see no way to handle it differently.
TO DO: there might actually be a way, by splitting a single
multi-name setup_joins call into separate calls. Check it.
-- [email protected]
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are joining to), 'alias' is the alias for the
table we are joining to. If dupe_multis is True, any many-to-many or
many-to-one joins will always create a new alias (necessary for
disjunctive filters).
Returns the final field involved in the join, the target database
column (used for any 'where' constraint), the final 'opts' value and the
list of tables joined.
"""
joins = [alias]
last = [0]
dupe_set = set()
exclusions = set()
extra_filters = []
for pos, name in enumerate(names):
try:
exclusions.add(int_alias)
except NameError:
pass
exclusions.add(alias)
last.append(len(joins))
if name == 'pk':
name = opts.pk.name
try:
field, model, direct, m2m = opts.get_field_by_name(name)
except FieldDoesNotExist:
for f in opts.fields:
if allow_explicit_fk and name == f.attname:
# XXX: A hack to allow foo_id to work in values() for
# backwards compatibility purposes. If we dropped that
# feature, this could be removed.
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
names = opts.get_all_field_names()
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
if not allow_many and (m2m or not direct):
for alias in joins:
self.unref_alias(alias)
raise MultiJoin(pos + 1)
#NOTE: Start Django Multilingual specific code
if hasattr(opts, 'translation_model'):
translation_opts = opts.translation_model._meta
if model == opts.translation_model:
language_id = translation_opts.translated_fields[name][1]
if language_id is None:
language_id = get_default_language()
#TODO: check alias
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(model._meta.db_table),
qn2(new_table),
qn2(new_table),
qn(master_table_name),
qn2(model._meta.pk.column),
qn2(new_table),
language_id))
self.extra_join[new_table] = trans_join
target = field
continue
#NOTE: End Django Multilingual specific code
elif model:
# The field lives on a base class of the current model.
for int_model in opts.get_base_chain(model):
lhs_col = opts.parents[int_model].column
dedupe = lhs_col in opts.duplicate_targets
if dedupe:
exclusions.update(self.dupe_avoidance.get(
(id(opts), lhs_col), ()))
dupe_set.add((opts, lhs_col))
opts = int_model._meta
alias = self.join((alias, opts.db_table, lhs_col,
opts.pk.column), exclusions=exclusions)
joins.append(alias)
exclusions.add(alias)
for (dupe_opts, dupe_col) in dupe_set:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
cached_data = opts._join_cache.get(name)
orig_opts = opts
dupe_col = direct and field.column or field.field.column
dedupe = dupe_col in opts.duplicate_targets
if dupe_set or dedupe:
if dedupe:
dupe_set.add((opts, dupe_col))
exclusions.update(self.dupe_avoidance.get((id(opts), dupe_col),
()))
if process_extras and hasattr(field, 'extra_filters'):
extra_filters.extend(field.extra_filters(names, pos, negate))
if direct:
if m2m:
# Many-to-many field defined on the current model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_column_name()
opts = field.rel.to._meta
table2 = opts.db_table
from_col2 = field.m2m_reverse_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
if int_alias == table2 and from_col2 == to_col2:
joins.append(int_alias)
alias = int_alias
else:
alias = self.join(
(int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
elif field.rel:
# One-to-one or many-to-one field
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
opts = field.rel.to._meta
target = field.rel.get_related_field()
table = opts.db_table
from_col = field.column
to_col = target.column
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
exclusions=exclusions, nullable=field.null)
joins.append(alias)
else:
# Non-relation fields.
target = field
break
else:
orig_field = field
field = field.field
if m2m:
# Many-to-many field defined on the target model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_reverse_name()
opts = orig_field.opts
table2 = opts.db_table
from_col2 = field.m2m_column_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
alias = self.join((int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
else:
# One-to-many field (ForeignKey defined on the target model)
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
local_field = opts.get_field_by_name(
field.rel.field_name)[0]
opts = orig_field.opts
table = opts.db_table
from_col = local_field.column
to_col = field.column
target = opts.pk
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.append(alias)
for (dupe_opts, dupe_col) in dupe_set:
try:
self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias)
except NameError:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None, negate=False,
process_extras=True):
if not self.include_translation_data:
return super(MultilingualQuery, self).setup_joins(names, opts, alias,
dupe_multis, allow_many,
allow_explicit_fk,
can_reuse, negate,
process_extras)
else:
return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
allow_many, allow_explicit_fk,
can_reuse, negate, process_extras)
def get_count(self):
# optimize for the common special case: count without any
# filters
if ((not (self.select or self.where or self.extra_where))
and self.include_translation_data):
obj = self.clone(extra_select = {},
extra_join = {},
include_translation_data = False)
return obj.get_count()
else:
return super(MultilingualQuery, self).get_count()
+
class MultilingualModelQuerySet(QuerySet):
"""
A specialized QuerySet that knows how to handle translatable
fields in ordering and filtering methods.
"""
def __init__(self, model=None, query=None):
query = query or MultilingualQuery(model, connection)
super(MultilingualModelQuerySet, self).__init__(model, query)
def for_language(self, language_id_or_code):
"""
Set the default language for all objects returned with this
query.
"""
clone = self._clone()
clone._default_language = get_language_id_from_id_or_code(language_id_or_code)
return clone
def iterator(self):
"""
Add the default language information to all returned objects.
"""
default_language = getattr(self, '_default_language', None)
for obj in super(MultilingualModelQuerySet, self).iterator():
obj._default_language = default_language
yield obj
def _clone(self, klass=None, **kwargs):
"""
Override _clone to preserve additional information needed by
MultilingualModelQuerySet.
"""
clone = super(MultilingualModelQuerySet, self)._clone(klass, **kwargs)
clone._default_language = getattr(self, '_default_language', None)
return clone
def order_by(self, *field_names):
if hasattr(self.model._meta, 'translation_model'):
trans_opts = self.model._meta.translation_model._meta
new_field_names = []
for field_name in field_names:
prefix = ''
if field_name[0] == '-':
prefix = '-'
field_name = field_name[1:]
field_and_lang = trans_opts.translated_fields.get(field_name)
if field_and_lang:
field, language_id = field_and_lang
if language_id is None:
language_id = getattr(self, '_default_language', None)
real_name = get_translated_field_alias(field.attname,
language_id)
new_field_names.append(prefix + real_name)
else:
new_field_names.append(prefix + field_name)
return super(MultilingualModelQuerySet, self).extra(order_by=new_field_names)
else:
return super(MultilingualModelQuerySet, self).order_by(*field_names)
diff --git a/multilingual/templatetags/multilingual_tags.py b/multilingual/templatetags/multilingual_tags.py
index ed9838f..4eb777b 100644
--- a/multilingual/templatetags/multilingual_tags.py
+++ b/multilingual/templatetags/multilingual_tags.py
@@ -1,81 +1,90 @@
import math
import StringIO
import tokenize
from django import template
from django import forms
from django.template import Node, NodeList, Template, Context, resolve_variable
from django.template.loader import get_template, render_to_string
from django.conf import settings
from django.utils.html import escape
-from multilingual.languages import get_language_idx, get_default_language, \
- get_language_id_list, get_language_code, \
- get_language_name, get_language_bidi
+from multilingual.languages import (
+ get_language_idx,
+ get_default_language,
+ get_language_id_list,
+ get_language_code,
+ get_language_name,
+ get_language_bidi)
register = template.Library()
def language_code(language_id):
"""
Return the code of the language with id=language_id
"""
return get_language_code(language_id)
+
def language_name(language_id):
"""
Return the name of the language with id=language_id
"""
return get_language_name(language_id)
+
def language_bidi(language_id):
"""
Return whether the language with id=language_id is written right-to-left.
"""
return get_language_bidi(language_id)
+
class EditTranslationNode(template.Node):
def __init__(self, form_name, field_name, language=None):
self.form_name = form_name
self.field_name = field_name
self.language = language
def render(self, context):
form = resolve_variable(self.form_name, context)
model = form._meta.model
trans_model = model._meta.translation_model
if self.language:
language_id = self.language.resolve(context)
else:
language_id = get_default_language()
real_name = "%s.%s.%s.%s" % (self.form_name,
trans_model._meta.object_name.lower(),
get_language_idx(language_id),
self.field_name)
return str(resolve_variable(real_name, context))
+
def do_edit_translation(parser, token):
bits = token.split_contents()
if len(bits) not in [3, 4]:
raise template.TemplateSyntaxError, \
"%r tag requires 3 or 4 arguments" % bits[0]
if len(bits) == 4:
language = parser.compile_filter(bits[3])
else:
language = None
return EditTranslationNode(bits[1], bits[2], language)
+
def reorder_translation_formset_by_language_id(inline_admin_form):
"""
Shuffle the forms in the formset of multilingual model in the
order of their language_ids.
"""
lang_to_form = dict([(form.form.initial['language_id'], form)
for form in inline_admin_form])
return [lang_to_form[language_id] for language_id in
get_language_id_list()]
register.filter(language_code)
register.filter(language_name)
register.filter(language_bidi)
register.tag('edit_translation', do_edit_translation)
register.filter(reorder_translation_formset_by_language_id)
diff --git a/multilingual/validation.py b/multilingual/validation.py
index ac559d6..dc1bea0 100644
--- a/multilingual/validation.py
+++ b/multilingual/validation.py
@@ -1,67 +1,71 @@
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from multilingual.utils import is_multilingual_model
+
def get_field(cls, model, opts, label, field):
"""
Just like django.contrib.admin.validation.get_field, but knows
about translation models.
"""
trans_model = model._meta.translation_model
try:
(f, lang_id) = trans_model._meta.translated_fields[field]
return f
except KeyError:
# fall back to the old way -- see if model contains the field
# directly
pass
-
+
try:
return opts.get_field(field)
except models.FieldDoesNotExist:
- raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is missing from model '%s'."
- % (cls.__name__, label, field, model.__name__))
+ raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is " \
+ "missing from model '%s'." \
+ % (cls.__name__, label, field, model.__name__))
+
def validate_admin_registration(cls, model):
"""
Validates a class specified as a model admin.
Right now this means validating prepopulated_fields, as for
multilingual models DM handles them by itself.
"""
if not is_multilingual_model(model):
return
from django.contrib.admin.validation import check_isdict, check_isseq
opts = model._meta
# this is heavily based on django.contrib.admin.validation.
if hasattr(cls, '_dm_prepopulated_fields'):
check_isdict(cls, '_dm_prepopulated_fields', cls.prepopulated_fields)
for field, val in cls._dm_prepopulated_fields.items():
f = get_field(cls, model, opts, 'prepopulated_fields', field)
if isinstance(f, (models.DateTimeField, models.ForeignKey,
models.ManyToManyField)):
raise ImproperlyConfigured("'%s.prepopulated_fields['%s']' "
"is either a DateTimeField, ForeignKey or "
"ManyToManyField. This isn't allowed."
% (cls.__name__, field))
check_isseq(cls, "prepopulated_fields['%s']" % field, val)
for idx, f in enumerate(val):
get_field(cls, model,
opts, "prepopulated_fields['%s'][%d]"
% (f, idx), f)
+
def install_multilingual_admin_validation():
from django.contrib.admin import validation
old_validate = validation.validate
-
+
def new_validate(admin_class, model):
old_validate(admin_class, model)
validate_admin_registration(admin_class, model)
-
+
validation.validate = new_validate
|
stefanfoulis/django-multilingual
|
a39f67e7f30642e886d64d9d4cd02ae45d4473ea
|
Some pep8 cleanups.
|
diff --git a/multilingual/context_processors.py b/multilingual/context_processors.py
index 46e919d..bcdacb8 100644
--- a/multilingual/context_processors.py
+++ b/multilingual/context_processors.py
@@ -1,8 +1,10 @@
-from multilingual.languages import get_language_code_list, get_default_language_code
+from multilingual.languages import get_language_code_list, \
+ get_default_language_code
+
def multilingual(request):
"""
Returns context variables containing information about available languages.
"""
return {'LANGUAGE_CODES': get_language_code_list(),
'DEFAULT_LANGUAGE_CODE': get_default_language_code()}
diff --git a/multilingual/middleware.py b/multilingual/middleware.py
index 4b56151..9f3241b 100644
--- a/multilingual/middleware.py
+++ b/multilingual/middleware.py
@@ -1,18 +1,22 @@
from django.utils.translation import get_language
from multilingual.exceptions import LanguageDoesNotExist
from multilingual.languages import set_default_language
+
class DefaultLanguageMiddleware(object):
"""
Binds DEFAULT_LANGUAGE_CODE to django's currently selected language.
The effect of enabling this middleware is that translated fields can be
accessed by their name; i.e. model.field instead of model.field_en.
"""
def process_request(self, request):
- assert hasattr(request, 'session'), "The DefaultLanguageMiddleware middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
+ assert hasattr(request, 'session'), "The DefaultLanguageMiddleware \
+ middleware requires session middleware to be installed. Edit your \
+ MIDDLEWARE_CLASSES setting to insert \
+ 'django.contrib.sessions.middleware.SessionMiddleware'."
try:
set_default_language(get_language())
except LanguageDoesNotExist:
# Try without the territory suffix
set_default_language(get_language()[:2])
diff --git a/multilingual/query.py b/multilingual/query.py
index adb3d1c..6527479 100644
--- a/multilingual/query.py
+++ b/multilingual/query.py
@@ -1,572 +1,573 @@
"""
Django-multilingual: a QuerySet subclass for models with translatable
fields.
This file contains the implementation for QSRF Django.
"""
import datetime
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models.fields import FieldDoesNotExist
from django.db.models.query import QuerySet, Q
from django.db.models.sql.query import Query
-from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin
+from django.db.models.sql.datastructures import EmptyResultSet, Empty, \
+ MultiJoin
from django.db.models.sql.constants import *
from django.db.models.sql.where import WhereNode, EverythingNode, AND, OR
try:
# handle internal API changes in Django rev. 9700
from django.db.models.sql.where import Constraint
def constraint_tuple(alias, col, field, lookup_type, value):
return (Constraint(alias, col, field), lookup_type, value)
except ImportError:
# backwards compatibility, for Django versions 1.0 to rev. 9699
def constraint_tuple(alias, col, field, lookup_type, value):
return (alias, col, field, lookup_type, value)
from multilingual.languages import (get_translation_table_alias, get_language_id_list,
get_default_language, get_translated_field_alias,
get_language_id_from_id_or_code)
__ALL__ = ['MultilingualModelQuerySet']
class MultilingualQuery(Query):
def __init__(self, model, connection, where=WhereNode):
self.extra_join = {}
self.include_translation_data = True
extra_select = {}
super(MultilingualQuery, self).__init__(model, connection, where=where)
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
for language_id in get_language_id_list():
for fname in [f.attname for f in translation_opts.fields]:
table_alias = get_translation_table_alias(trans_table_name,
language_id)
field_alias = get_translated_field_alias(fname,
language_id)
extra_select[field_alias] = qn2(table_alias) + '.' + qn2(fname)
- self.add_extra(extra_select, None,None,None,None,None)
+ self.add_extra(extra_select, None, None, None, None, None)
self._trans_extra_select_count = len(self.extra_select)
def clone(self, klass=None, **kwargs):
defaults = {
'extra_join': self.extra_join,
'include_translation_data': self.include_translation_data,
}
defaults.update(kwargs)
return super(MultilingualQuery, self).clone(klass=klass, **defaults)
def pre_sql_setup(self):
"""Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualQuery, self).pre_sql_setup()
if not self.include_translation_data:
return
-
+
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_id in get_language_id_list():
table_alias = get_translation_table_alias(trans_table_name,
language_id)
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(self.model._meta.pk.column),
qn2(table_alias),
language_id))
self.extra_join[table_alias] = trans_join
def get_from_clause(self):
"""Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualQuery, self).get_from_clause()
if not self.include_translation_data:
return result
-
+
from_ = result[0]
for join in self.extra_join.values():
from_.append(join)
return (from_, result[1])
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None, process_extras=True):
"""Copied from add_filter to generate WHERES for translation fields.
"""
arg, value = filter_expr
parts = arg.split(LOOKUP_SEP)
if not parts:
raise FieldError("Cannot parse keyword query %r" % arg)
# Work out the lookup type and remove it from 'parts', if necessary.
if len(parts) == 1 or parts[-1] not in self.query_terms:
lookup_type = 'exact'
else:
lookup_type = parts.pop()
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
# uses of None as a query value.
if value is None:
if lookup_type != 'exact':
raise ValueError("Cannot use None as a query value")
lookup_type = 'isnull'
value = True
elif (value == '' and lookup_type == 'exact' and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value = True
elif callable(value):
value = value()
opts = self.get_meta()
alias = self.get_initial_alias()
allow_many = trim or not negate
try:
field, target, opts, join_list, last, extra_filters = self.setup_joins(
parts, opts, alias, True, allow_many, can_reuse=can_reuse,
negate=negate, process_extras=process_extras)
except MultiJoin, e:
self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]),
can_reuse)
return
#NOTE: here comes Django Multilingual
if hasattr(opts, 'translation_model'):
field_name = parts[-1]
if field_name == 'pk':
field_name = opts.pk.name
translation_opts = opts.translation_model._meta
if field_name in translation_opts.translated_fields.keys():
field, model, direct, m2m = opts.get_field_by_name(field_name)
if model == opts.translation_model:
language_id = translation_opts.translated_fields[field_name][1]
if language_id is None:
language_id = get_default_language()
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
self.where.add(constraint_tuple(new_table, field.column, field, lookup_type, value), connector)
return
final = len(join_list)
penultimate = last.pop()
if penultimate == final:
penultimate = last.pop()
if trim and len(join_list) > 1:
extra = join_list[penultimate:]
join_list = join_list[:penultimate]
final = penultimate
penultimate = last.pop()
col = self.alias_map[extra[0]][LHS_JOIN_COL]
for alias in extra:
self.unref_alias(alias)
else:
col = target.column
alias = join_list[-1]
while final > 1:
# An optimization: if the final join is against the same column as
# we are comparing against, we can go back one step in the join
# chain and compare against the lhs of the join instead (and then
# repeat the optimization). The result, potentially, involves less
# table joins.
join = self.alias_map[alias]
if col != join[RHS_JOIN_COL]:
break
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
join_list = join_list[:-1]
final -= 1
if final == penultimate:
penultimate = last.pop()
if (lookup_type == 'isnull' and value is True and not negate and
final > 1):
# If the comparison is against NULL, we need to use a left outer
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed as it's less
# efficient at the database level.
self.promote_alias(join_list[penultimate])
if connector == OR:
# Some joins may need to be promoted when adding a new filter to a
# disjunction. We walk the list of new joins and where it diverges
# from any previous joins (ref count is 1 in the table list), we
# make the new additions (and any existing ones not used in the new
# join list) an outer join.
join_it = iter(join_list)
table_it = iter(self.tables)
join_it.next(), table_it.next()
table_promote = False
join_promote = False
for join in join_it:
table = table_it.next()
if join == table and self.alias_refcount[join] > 1:
continue
join_promote = self.promote_alias(join)
if table != join:
table_promote = self.promote_alias(table)
break
self.promote_alias_chain(join_it, join_promote)
self.promote_alias_chain(table_it, table_promote)
self.where.add(constraint_tuple(alias, col, field, lookup_type, value), connector)
if negate:
self.promote_alias_chain(join_list)
if lookup_type != 'isnull':
if final > 1:
for alias in join_list:
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
j_col = self.alias_map[alias][RHS_JOIN_COL]
entry = self.where_class()
entry.add(constraint_tuple(alias, j_col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
break
elif not (lookup_type == 'in' and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# it's short-circuited in the Where class.
entry = self.where_class()
entry.add(constraint_tuple(alias, col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
if can_reuse is not None:
can_reuse.update(join_list)
if process_extras:
for filter in extra_filters:
self.add_filter(filter, negate=negate, can_reuse=can_reuse,
process_extras=False)
def _setup_joins_with_translation(self, names, opts, alias,
dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None,
negate=False, process_extras=True):
"""
This is based on a full copy of Query.setup_joins because
currently I see no way to handle it differently.
TO DO: there might actually be a way, by splitting a single
multi-name setup_joins call into separate calls. Check it.
-- [email protected]
-
+
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are joining to), 'alias' is the alias for the
table we are joining to. If dupe_multis is True, any many-to-many or
many-to-one joins will always create a new alias (necessary for
disjunctive filters).
Returns the final field involved in the join, the target database
column (used for any 'where' constraint), the final 'opts' value and the
list of tables joined.
"""
joins = [alias]
last = [0]
dupe_set = set()
exclusions = set()
extra_filters = []
for pos, name in enumerate(names):
try:
exclusions.add(int_alias)
except NameError:
pass
exclusions.add(alias)
last.append(len(joins))
if name == 'pk':
name = opts.pk.name
try:
field, model, direct, m2m = opts.get_field_by_name(name)
except FieldDoesNotExist:
for f in opts.fields:
if allow_explicit_fk and name == f.attname:
# XXX: A hack to allow foo_id to work in values() for
# backwards compatibility purposes. If we dropped that
# feature, this could be removed.
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
names = opts.get_all_field_names()
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
if not allow_many and (m2m or not direct):
for alias in joins:
self.unref_alias(alias)
raise MultiJoin(pos + 1)
#NOTE: Start Django Multilingual specific code
if hasattr(opts, 'translation_model'):
translation_opts = opts.translation_model._meta
if model == opts.translation_model:
language_id = translation_opts.translated_fields[name][1]
if language_id is None:
language_id = get_default_language()
#TODO: check alias
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(model._meta.db_table),
qn2(new_table),
qn2(new_table),
qn(master_table_name),
qn2(model._meta.pk.column),
qn2(new_table),
language_id))
self.extra_join[new_table] = trans_join
target = field
continue
#NOTE: End Django Multilingual specific code
elif model:
# The field lives on a base class of the current model.
for int_model in opts.get_base_chain(model):
lhs_col = opts.parents[int_model].column
dedupe = lhs_col in opts.duplicate_targets
if dedupe:
exclusions.update(self.dupe_avoidance.get(
(id(opts), lhs_col), ()))
dupe_set.add((opts, lhs_col))
opts = int_model._meta
alias = self.join((alias, opts.db_table, lhs_col,
opts.pk.column), exclusions=exclusions)
joins.append(alias)
exclusions.add(alias)
for (dupe_opts, dupe_col) in dupe_set:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
cached_data = opts._join_cache.get(name)
orig_opts = opts
dupe_col = direct and field.column or field.field.column
dedupe = dupe_col in opts.duplicate_targets
if dupe_set or dedupe:
if dedupe:
dupe_set.add((opts, dupe_col))
exclusions.update(self.dupe_avoidance.get((id(opts), dupe_col),
()))
if process_extras and hasattr(field, 'extra_filters'):
extra_filters.extend(field.extra_filters(names, pos, negate))
if direct:
if m2m:
# Many-to-many field defined on the current model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_column_name()
opts = field.rel.to._meta
table2 = opts.db_table
from_col2 = field.m2m_reverse_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
if int_alias == table2 and from_col2 == to_col2:
joins.append(int_alias)
alias = int_alias
else:
alias = self.join(
(int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
elif field.rel:
# One-to-one or many-to-one field
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
opts = field.rel.to._meta
target = field.rel.get_related_field()
table = opts.db_table
from_col = field.column
to_col = target.column
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
exclusions=exclusions, nullable=field.null)
joins.append(alias)
else:
# Non-relation fields.
target = field
break
else:
orig_field = field
field = field.field
if m2m:
# Many-to-many field defined on the target model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_reverse_name()
opts = orig_field.opts
table2 = opts.db_table
from_col2 = field.m2m_column_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
alias = self.join((int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
else:
# One-to-many field (ForeignKey defined on the target model)
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
local_field = opts.get_field_by_name(
field.rel.field_name)[0]
opts = orig_field.opts
table = opts.db_table
from_col = local_field.column
to_col = field.column
target = opts.pk
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.append(alias)
for (dupe_opts, dupe_col) in dupe_set:
try:
self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias)
except NameError:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None, negate=False,
process_extras=True):
if not self.include_translation_data:
return super(MultilingualQuery, self).setup_joins(names, opts, alias,
dupe_multis, allow_many,
allow_explicit_fk,
can_reuse, negate,
process_extras)
else:
return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
allow_many, allow_explicit_fk,
can_reuse, negate, process_extras)
def get_count(self):
# optimize for the common special case: count without any
# filters
if ((not (self.select or self.where or self.extra_where))
and self.include_translation_data):
obj = self.clone(extra_select = {},
extra_join = {},
include_translation_data = False)
return obj.get_count()
else:
return super(MultilingualQuery, self).get_count()
class MultilingualModelQuerySet(QuerySet):
"""
A specialized QuerySet that knows how to handle translatable
fields in ordering and filtering methods.
"""
def __init__(self, model=None, query=None):
query = query or MultilingualQuery(model, connection)
super(MultilingualModelQuerySet, self).__init__(model, query)
def for_language(self, language_id_or_code):
"""
Set the default language for all objects returned with this
query.
"""
clone = self._clone()
clone._default_language = get_language_id_from_id_or_code(language_id_or_code)
return clone
def iterator(self):
"""
Add the default language information to all returned objects.
"""
default_language = getattr(self, '_default_language', None)
for obj in super(MultilingualModelQuerySet, self).iterator():
obj._default_language = default_language
yield obj
def _clone(self, klass=None, **kwargs):
"""
Override _clone to preserve additional information needed by
MultilingualModelQuerySet.
"""
clone = super(MultilingualModelQuerySet, self)._clone(klass, **kwargs)
clone._default_language = getattr(self, '_default_language', None)
return clone
def order_by(self, *field_names):
if hasattr(self.model._meta, 'translation_model'):
trans_opts = self.model._meta.translation_model._meta
new_field_names = []
for field_name in field_names:
prefix = ''
if field_name[0] == '-':
prefix = '-'
field_name = field_name[1:]
field_and_lang = trans_opts.translated_fields.get(field_name)
if field_and_lang:
field, language_id = field_and_lang
if language_id is None:
language_id = getattr(self, '_default_language', None)
real_name = get_translated_field_alias(field.attname,
language_id)
new_field_names.append(prefix + real_name)
else:
new_field_names.append(prefix + field_name)
return super(MultilingualModelQuerySet, self).extra(order_by=new_field_names)
else:
return super(MultilingualModelQuerySet, self).order_by(*field_names)
diff --git a/multilingual/templatetags/multilingual_tags.py b/multilingual/templatetags/multilingual_tags.py
index 9b5c0f5..ed9838f 100644
--- a/multilingual/templatetags/multilingual_tags.py
+++ b/multilingual/templatetags/multilingual_tags.py
@@ -1,84 +1,81 @@
+import math
+import StringIO
+import tokenize
+
from django import template
from django import forms
from django.template import Node, NodeList, Template, Context, resolve_variable
from django.template.loader import get_template, render_to_string
from django.conf import settings
from django.utils.html import escape
-from multilingual.languages import (get_language_idx, get_default_language,
- get_language_id_list)
-import math
-import StringIO
-import tokenize
+from multilingual.languages import get_language_idx, get_default_language, \
+ get_language_id_list, get_language_code, \
+ get_language_name, get_language_bidi
register = template.Library()
-from multilingual.languages import get_language_code, get_language_name, get_language_bidi
def language_code(language_id):
"""
Return the code of the language with id=language_id
"""
return get_language_code(language_id)
-
-register.filter(language_code)
def language_name(language_id):
"""
Return the name of the language with id=language_id
"""
return get_language_name(language_id)
-
-register.filter(language_name)
def language_bidi(language_id):
"""
Return whether the language with id=language_id is written right-to-left.
"""
return get_language_bidi(language_id)
-register.filter(language_bidi)
-
class EditTranslationNode(template.Node):
def __init__(self, form_name, field_name, language=None):
self.form_name = form_name
self.field_name = field_name
self.language = language
def render(self, context):
form = resolve_variable(self.form_name, context)
model = form._meta.model
trans_model = model._meta.translation_model
if self.language:
language_id = self.language.resolve(context)
else:
language_id = get_default_language()
real_name = "%s.%s.%s.%s" % (self.form_name,
trans_model._meta.object_name.lower(),
get_language_idx(language_id),
self.field_name)
return str(resolve_variable(real_name, context))
def do_edit_translation(parser, token):
bits = token.split_contents()
if len(bits) not in [3, 4]:
raise template.TemplateSyntaxError, \
"%r tag requires 3 or 4 arguments" % bits[0]
if len(bits) == 4:
language = parser.compile_filter(bits[3])
else:
language = None
return EditTranslationNode(bits[1], bits[2], language)
-register.tag('edit_translation', do_edit_translation)
-
def reorder_translation_formset_by_language_id(inline_admin_form):
"""
Shuffle the forms in the formset of multilingual model in the
order of their language_ids.
"""
lang_to_form = dict([(form.form.initial['language_id'], form)
for form in inline_admin_form])
- return [lang_to_form[language_id] for language_id in get_language_id_list()]
-
-register.filter(reorder_translation_formset_by_language_id)
+ return [lang_to_form[language_id] for language_id in
+ get_language_id_list()]
+register.filter(language_code)
+register.filter(language_name)
+register.filter(language_bidi)
+register.tag('edit_translation', do_edit_translation)
+register.filter(reorder_translation_formset_by_language_id)
|
stefanfoulis/django-multilingual
|
1df576c4e14223f26605ac610ffb12874b273e4b
|
Fixed issue 100, inlines can be defined both as lists or tuples.
|
diff --git a/multilingual/admin.py b/multilingual/admin.py
index 52e645c..fbc7164 100644
--- a/multilingual/admin.py
+++ b/multilingual/admin.py
@@ -1,203 +1,203 @@
from django.contrib import admin
from django.forms.models import BaseInlineFormSet
from django.forms.fields import BooleanField
from django.forms.formsets import DELETION_FIELD_NAME
from django.forms.util import ErrorDict
from django.utils.translation import ugettext as _
from multilingual.languages import *
from multilingual.utils import is_multilingual_model
def _translation_form_full_clean(self, previous_full_clean):
"""
There is a bug in Django that causes inline forms to be
validated even if they are marked for deletion.
This function fixes that by disabling validation
completely if the delete field is marked and only copying
the absolutely required fields: PK and FK to parent.
TODO: create a fix for Django, have it accepted into trunk and get
rid of this monkey patch.
"""
def cleaned_value(name):
field = self.fields[name]
val = field.widget.value_from_datadict(self.data, self.files,
self.add_prefix(name))
return field.clean(val)
delete = cleaned_value(DELETION_FIELD_NAME)
if delete:
# this object is to be skipped or deleted, so only
# construct the minimal cleaned_data
self.cleaned_data = {'DELETE': delete,
'id': cleaned_value('id')}
self._errors = ErrorDict()
else:
return previous_full_clean()
class TranslationInlineFormSet(BaseInlineFormSet):
def _construct_forms(self):
## set the right default values for language_ids of empty (new) forms
super(TranslationInlineFormSet, self)._construct_forms()
empty_forms = []
lang_id_list = get_language_id_list()
lang_to_form = dict(zip(lang_id_list, [None] * len(lang_id_list)))
for form in self.forms:
language_id = form.initial.get('language_id')
if language_id:
lang_to_form[language_id] = form
else:
empty_forms.append(form)
for language_id in lang_id_list:
form = lang_to_form[language_id]
if form is None:
form = empty_forms.pop(0)
form.initial['language_id'] = language_id
def add_fields(self, form, index):
super(TranslationInlineFormSet, self).add_fields(form, index)
previous_full_clean = form.full_clean
form.full_clean = lambda: _translation_form_full_clean(form, previous_full_clean)
class TranslationModelAdmin(admin.StackedInline):
template = "admin/edit_inline_translations_newforms.html"
fk_name = 'master'
extra = get_language_count()
max_num = get_language_count()
formset = TranslationInlineFormSet
class ModelAdminClass(admin.ModelAdmin.__metaclass__):
"""
A metaclass for ModelAdmin below.
"""
def __new__(cls, name, bases, attrs):
# Move prepopulated_fields somewhere where Django won't see
# them. We have to handle them ourselves.
prepopulated_fields = attrs.get('prepopulated_fields', {})
attrs['prepopulated_fields'] = {}
attrs['_dm_prepopulated_fields'] = prepopulated_fields
return super(ModelAdminClass, cls).__new__(cls, name, bases, attrs)
class ModelAdmin(admin.ModelAdmin):
"""
All model admins for multilingual models must inherit this class
instead of django.contrib.admin.ModelAdmin.
"""
__metaclass__ = ModelAdminClass
def _media(self):
media = super(ModelAdmin, self)._media()
if getattr(self.__class__, '_dm_prepopulated_fields', None):
from django.conf import settings
media.add_js(['%sjs/urlify.js' % (settings.ADMIN_MEDIA_PREFIX,)])
return media
media = property(_media)
def render_change_form(self, request, context, add=False, change=False,
form_url='', obj=None):
# I'm overriding render_change_form to inject information
# about prepopulated_fields
trans_model = self.model._meta.translation_model
trans_fields = trans_model._meta.translated_fields
adminform = context['adminform']
form = adminform.form
def field_name_to_fake_field(field_name):
"""
Return something that looks like a form field enough to
fool prepopulated_fields_js.html
For field_names of real fields in self.model this actually
returns a real form field.
"""
try:
field, language_id = trans_fields[field_name]
if language_id is None:
language_id = get_default_language()
# TODO: we have this mapping between language_id and
# field id in two places -- here and in
# edit_inline_translations_newforms.html
# It is not DRY.
field_idx = language_id - 1
ret = {'auto_id': 'id_translations-%d-%s' % (field_idx, field.name)
}
except:
ret = form[field_name]
return ret
adminform.prepopulated_fields = [{
'field': field_name_to_fake_field(field_name),
'dependencies': [field_name_to_fake_field(f) for f in dependencies]
} for field_name, dependencies in self._dm_prepopulated_fields.items()]
return super(ModelAdmin, self).render_change_form(request, context,
add, change, form_url, obj)
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
return tr_cls
# TODO: multilingual_modeladmin_new should go away soon. The code will
# be split between the ModelAdmin class, its metaclass and validation
# code.
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
if is_multilingual_model(model):
if cls is admin.ModelAdmin:
# the model is being registered with the default
# django.contrib.admin.options.ModelAdmin. Replace it
# with our ModelAdmin, since it is safe to assume it is a
# simple call to admin.site.register without just model
# passed
# subclass it, because we need to set the inlines class
# attribute below
cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
# make sure it subclasses multilingual.ModelAdmin
if not issubclass(cls, ModelAdmin):
from warnings import warn
warn("%s should be registered with a subclass of "
" of multilingual.ModelAdmin." % model, DeprecationWarning)
# if the inlines already contain a class for the
# translation model, use it and don't create another one
translation_modeladmin = None
for inline in getattr(cls, 'inlines', []):
if inline.model == model._meta.translation_model:
translation_modeladmin = inline
if not translation_modeladmin:
translation_modeladmin = get_translation_modeladmin(cls, model)
if cls.inlines:
- cls.inlines.insert(0, translation_modeladmin)
+ cls.inlines = type(cls.inlines)((translation_modeladmin,)) + cls.inlines
else:
cls.inlines = [translation_modeladmin]
return admin.ModelAdmin._original_new_before_dm(cls, model, admin_site, obj)
def install_multilingual_modeladmin_new():
"""
Override ModelAdmin.__new__ to create automatic inline
editor for multilingual models.
"""
admin.ModelAdmin._original_new_before_dm = admin.ModelAdmin.__new__
admin.ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
|
stefanfoulis/django-multilingual
|
5e8eec19323f26455f58005ea24ed049791346a7
|
Fixed issue 94 and 96 - multilingual flatpages are now in sync with the contrib app.
|
diff --git a/multilingual/flatpages/admin.py b/multilingual/flatpages/admin.py
index 5e70ad1..0c954a3 100644
--- a/multilingual/flatpages/admin.py
+++ b/multilingual/flatpages/admin.py
@@ -1,14 +1,29 @@
+from django import forms
from django.contrib import admin
-from django.utils.translation import ugettext_lazy as _
from multilingual.flatpages.models import MultilingualFlatPage
+from django.utils.translation import ugettext_lazy as _
import multilingual
+
+class MultilingualFlatpageForm(forms.ModelForm):
+ url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/]+$',
+ help_text = _("Example: '/about/contact/'. Make sure to have leading"
+ " and trailing slashes."),
+ error_message = _("This value must contain only letters, numbers,"
+ " underscores, dashes or slashes."))
+
+ class Meta:
+ model = MultilingualFlatPage
+
+
class MultilingualFlatPageAdmin(multilingual.ModelAdmin):
+ form = MultilingualFlatpageForm
fieldsets = (
(None, {'fields': ('url', 'sites')}),
(_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
)
- list_filter = ('sites',)
+ list_display = ('url', 'title')
+ list_filter = ('sites', 'enable_comments', 'registration_required')
search_fields = ('url', 'title')
admin.site.register(MultilingualFlatPage, MultilingualFlatPageAdmin)
diff --git a/multilingual/flatpages/models.py b/multilingual/flatpages/models.py
index 970a1fb..3d97a81 100644
--- a/multilingual/flatpages/models.py
+++ b/multilingual/flatpages/models.py
@@ -1,48 +1,47 @@
from django.db import models
from django.contrib.sites.models import Site
+from django.utils.translation import ugettext_lazy as _
import multilingual
-from django.utils.translation import ugettext as _
class MultilingualFlatPage(models.Model):
# non-translatable fields first
- url = models.CharField(_('URL'), max_length=100, db_index=True,
- help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes."))
+ url = models.CharField(_('URL'), max_length=100, db_index=True)
enable_comments = models.BooleanField(_('enable comments'))
template_name = models.CharField(_('template name'), max_length=70, blank=True,
help_text=_("Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'."))
registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page."))
sites = models.ManyToManyField(Site)
# And now the translatable fields
class Translation(multilingual.Translation):
"""
The definition of translation model.
The multilingual machinery will automatically add these to the
Category class:
-
+
* get_title(language_id=None)
* set_title(value, language_id=None)
* get_content(language_id=None)
* set_content(value, language_id=None)
* title and content properties using the methods above
"""
title = models.CharField(_('title'), max_length=200)
content = models.TextField(_('content'), blank=True)
class Meta:
db_table = 'multilingual_flatpage'
verbose_name = _('multilingual flat page')
verbose_name_plural = _('multilingual flat pages')
ordering = ('url',)
def __unicode__(self):
# note that you can use name and description fields as usual
try:
return u"%s -- %s" % (self.url, self.title)
except multilingual.TranslationDoesNotExist:
return u"-not-available-"
def get_absolute_url(self):
return self.url
diff --git a/multilingual/flatpages/urls.py b/multilingual/flatpages/urls.py
index 8710c81..f8cc879 100644
--- a/multilingual/flatpages/urls.py
+++ b/multilingual/flatpages/urls.py
@@ -1,6 +1,5 @@
from django.conf.urls.defaults import *
-from multilingual.flatpages.views import *
-urlpatterns = patterns('',
- url(r'^(?P<url>.*)$', MultilingualFlatPage , name="multilingual_flatpage"),
+urlpatterns = patterns('multilingual.flatpages.views',
+ (r'^(?P<url>.*)$', 'multilingual_flatpage'),
)
diff --git a/multilingual/flatpages/views.py b/multilingual/flatpages/views.py
index 25dc602..0ea2254 100644
--- a/multilingual/flatpages/views.py
+++ b/multilingual/flatpages/views.py
@@ -1,52 +1,53 @@
from multilingual.flatpages.models import MultilingualFlatPage
from django.template import loader, RequestContext
from django.shortcuts import get_object_or_404
-from django.http import HttpResponse
+from django.http import HttpResponse, HttpResponseRedirect
from django.conf import settings
from django.core.xheaders import populate_xheaders
+from django.utils.safestring import mark_safe
from django.utils.translation import get_language
import multilingual
-from django.utils.safestring import mark_safe
-
DEFAULT_TEMPLATE = 'flatpages/default.html'
def multilingual_flatpage(request, url):
"""
Multilingual flat page view.
Models: `multilingual.flatpages.models`
Templates: Uses the template defined by the ``template_name`` field,
or `flatpages/default.html` if template_name is not defined.
Context:
flatpage
`flatpages.flatpages` object
"""
+ if not url.endswith('/') and settings.APPEND_SLASH:
+ return HttpResponseRedirect("%s/" % request.path)
if not url.startswith('/'):
url = "/" + url
f = get_object_or_404(MultilingualFlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
# If registration is required for accessing this page, and the user isn't
# logged in, redirect to the login page.
if f.registration_required and not request.user.is_authenticated():
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(request.path)
- #Serve the content in the language defined by the Django translation module
- #if possible else serve the default language
+ # Serve the content in the language defined by the Django translation module
+ # if possible else serve the default language.
f._default_language = multilingual.languages.get_language_id_from_id_or_code(get_language())
if f.template_name:
t = loader.select_template((f.template_name, DEFAULT_TEMPLATE))
else:
t = loader.get_template(DEFAULT_TEMPLATE)
# To avoid having to always use the "|safe" filter in flatpage templates,
# mark the title and content as already safe (since they are raw HTML
# content in the first place).
f.title = mark_safe(f.title)
f.content = mark_safe(f.content)
c = RequestContext(request, {
'flatpage': f,
})
response = HttpResponse(t.render(c))
populate_xheaders(request, response, MultilingualFlatPage, f.id)
return response
|
stefanfoulis/django-multilingual
|
a8f885f3611f9308757c39bef72c9c147dd7e8e1
|
Added a README and INSTALL explanatory files.
|
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..7481cc3
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,12 @@
+Thanks for downloading django-multilingual.
+
+To install it, checkout from Subversion:
+
+ svn co http://django-multilingual.googlecode.com/svn/trunk/ multilingual
+
+and add the included ``multilingual`` directory to your PYTHONPATH, or symlink
+to it from somewhere on your PYTHONPATH.
+
+Note that this application requires Python 2.3 or later, and Django 1.0 or 1.1. You
+can obtain Python from http://www.python.org/ and Django from
+http://www.djangoproject.com/.
diff --git a/README b/README
new file mode 100644
index 0000000..e1ee8f5
--- /dev/null
+++ b/README
@@ -0,0 +1,10 @@
+===================
+Django Multilingual
+===================
+
+This is a library providing support for multilingual content in Django models.
+
+For installation instructions, see the file "INSTALL" in this directory; for
+instructions on how to use this application, and on what it provides, see the
+file "overview.rst" in the "docs/" directory or browse the whole documentation
+already available in "docs/_build/html".
|
stefanfoulis/django-multilingual
|
b918fb7bbb8b319ddf5919717ddb88dbc835f0ec
|
Added basic documentation. Basically it is a move of the googlecode wiki to Sphinx.
|
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..fe40e04
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,89 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/DjangoMultilingual.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/DjangoMultilingual.qhc"
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+ "run these through (pdf)latex."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/_build/doctrees/backwards.doctree b/docs/_build/doctrees/backwards.doctree
new file mode 100644
index 0000000..681b500
Binary files /dev/null and b/docs/_build/doctrees/backwards.doctree differ
diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle
new file mode 100644
index 0000000..91dab02
Binary files /dev/null and b/docs/_build/doctrees/environment.pickle differ
diff --git a/docs/_build/doctrees/flatpages.doctree b/docs/_build/doctrees/flatpages.doctree
new file mode 100644
index 0000000..8b4840a
Binary files /dev/null and b/docs/_build/doctrees/flatpages.doctree differ
diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree
new file mode 100644
index 0000000..f13360a
Binary files /dev/null and b/docs/_build/doctrees/index.doctree differ
diff --git a/docs/_build/doctrees/middleware.doctree b/docs/_build/doctrees/middleware.doctree
new file mode 100644
index 0000000..1fca98f
Binary files /dev/null and b/docs/_build/doctrees/middleware.doctree differ
diff --git a/docs/_build/doctrees/overview.doctree b/docs/_build/doctrees/overview.doctree
new file mode 100644
index 0000000..682192c
Binary files /dev/null and b/docs/_build/doctrees/overview.doctree differ
diff --git a/docs/_build/html/_sources/backwards.txt b/docs/_build/html/_sources/backwards.txt
new file mode 100644
index 0000000..02aaeda
--- /dev/null
+++ b/docs/_build/html/_sources/backwards.txt
@@ -0,0 +1,21 @@
+==============================
+Backwards Incompatible Changes
+==============================
+
+
+Translation table rename
+========================
+
+In revision 98 the default name for translation tables was changed: instead of
+"modeltranslation" it is now "model_translation". You don't have to rename your
+tables, just upgrade to DM revision 102 or later and add a Meta class within
+your translation model::
+
+ class MyModel(models.Model):
+ [...]
+ class Translation(multilingual.Translation):
+ my_field = ...
+ class Meta:
+ db_table="my_modeltranslation"
+
+Note that this "class Meta" is inside the inner Translation class.
diff --git a/docs/_build/html/_sources/flatpages.txt b/docs/_build/html/_sources/flatpages.txt
new file mode 100644
index 0000000..b3450d2
--- /dev/null
+++ b/docs/_build/html/_sources/flatpages.txt
@@ -0,0 +1,29 @@
+======================
+Multilingual Flatpages
+======================
+
+
+The Django flatpages application is "[...] a simple object with a URL, title and
+content. Use it for one-off, special-case pages, such as 'About' or 'Privacy Policy'
+pages, that you want to store in a database but for which you donât want to develop
+a custom Django application."
+
+If you have a website in multiple languages you will want to have these pages in
+your supported languages. Django-multilingual comes with a version of flatpages
+that has translatable name and content fields. You install it by adding
+``multilingual.flatpages`` to the installed applications list::
+
+ INSTALLED_APPS = (
+ ...
+ 'multilingual',
+ 'multilingual.flatpages',
+ ...
+ )
+
+The multilingual flatpages should now be available in the admin interface. They
+use the same templates as the original flatpages application: ``flatpages/base.html``.
+
+You will want to enable the middleware Django Multilingual provides if you want your
+pages to appear in the correct language automatically.
+
+.. vi:ft=rst:expandtab:shiftwidth=4
diff --git a/docs/_build/html/_sources/index.txt b/docs/_build/html/_sources/index.txt
new file mode 100644
index 0000000..c632ae1
--- /dev/null
+++ b/docs/_build/html/_sources/index.txt
@@ -0,0 +1,25 @@
+.. Django Multilingual documentation master file, created by
+ sphinx-quickstart on Mon Dec 14 21:00:06 2009.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to Django Multilingual's documentation!
+===============================================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ overview
+ middleware
+ flatpages
+ backwards
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/docs/_build/html/_sources/middleware.txt b/docs/_build/html/_sources/middleware.txt
new file mode 100644
index 0000000..cb82b8f
--- /dev/null
+++ b/docs/_build/html/_sources/middleware.txt
@@ -0,0 +1,23 @@
+==========================================
+Add middleware to set the default language
+==========================================
+
+Django contains middleware that automatically discovers the browser's language
+and allows the user to change it. All translated strings in Python code and
+templates are then automatically shown in this language. (See the official
+Django documentation.) You can use the same language as the default translation
+for model fields.
+
+Add ``multilingual.middleware.DefaultLanguageMiddleware`` to your ``MIDDLEWARE_CLASSES``::
+
+ MIDDLEWARE_CLASSES = (
+ #...
+ 'django.middleware.locale.LocaleMiddleware',
+ 'multilingual.middleware.DefaultLanguageMiddleware',
+ #...
+ )
+
+The multilingual middleware must come after the language discovery middleware,
+in this case ``django.middleware.locale.LocaleMiddleware``.
+
+.. vi:ft=rst:expandtab:shiftwidth=4
diff --git a/docs/_build/html/_sources/overview.txt b/docs/_build/html/_sources/overview.txt
new file mode 100644
index 0000000..94ff24c
--- /dev/null
+++ b/docs/_build/html/_sources/overview.txt
@@ -0,0 +1,87 @@
+===================
+Django Multilingual
+===================
+
+
+Configuration
+=============
+
+After following the instructions over at ``INSTALL``, we need to configure our
+app's ``settings.py`` file.
+
+* Add ``LANGUAGES`` setting this is the same setting that is used by Django's
+ i18n::
+
+ LANGUAGES = (
+ ('en', 'English'),
+ ('pl', 'Polish'),
+ )
+
+* Add ``DEFAULT_LANGUAGE``, in this example setting it to 1 would make the
+ default English as it is first in the ``LANGUAGES`` list::
+
+ DEFAULT_LANGUAGE = 1
+
+* Add multilingual.context_processors.multilingual to ``TEMPLATE_CONTEXT_PROCESSORS``,
+ it should look something like this::
+
+ TEMPLATE_CONTEXT_PROCESSORS = (
+ 'django.core.context_processors.auth',
+ 'django.core.context_processors.debug',
+ 'django.core.context_processors.i18n',
+ 'multilingual.context_processors.multilingual',
+ )
+
+* Add multilingual to ``INSTALLED_APPS``, it should look like this::
+
+ INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ 'multilingual',
+ )
+
+Model Setup
+===========
+
+Once this is done, we need to setup our Model.
+
+* At the top of the model file import multilingual::
+
+ import multilingual
+
+* Create the model, the sub-class translation contains all the fields that
+ will have multiple language data. For example::
+
+ class Category(models.Model):
+ parent = models.ForeignKey('self', blank=True, null=True)
+
+ class Translation(multilingual.Translation):
+ name = models.CharField(max_length=250)
+
+ def __unicode__(self):
+ return self.name
+
+``Meta`` Class
+==============
+
+You may also add a ``Meta`` inner class to the ``Translation`` class to
+configure the translation mechanism. Currently, the only properties
+recognized is::
+
+ db_table sets the database table name (default: <model>_translation)
+
+An example::
+
+ class Dog(models.Model):
+ owner = models.ForeignKey(Human)
+
+ class Translation(multilingual.Translation):
+ breed = models.CharField(max_length=50)
+
+ class Meta:
+ db_table = 'dog_languages_table'
+
+.. vi:ft=rst:expandtab:shiftwidth=4
diff --git a/docs/_build/html/_static/basic.css b/docs/_build/html/_static/basic.css
new file mode 100644
index 0000000..128114b
--- /dev/null
+++ b/docs/_build/html/_static/basic.css
@@ -0,0 +1,405 @@
+/**
+ * Sphinx stylesheet -- basic theme
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/* -- main layout ----------------------------------------------------------- */
+
+div.clearer {
+ clear: both;
+}
+
+/* -- relbar ---------------------------------------------------------------- */
+
+div.related {
+ width: 100%;
+ font-size: 90%;
+}
+
+div.related h3 {
+ display: none;
+}
+
+div.related ul {
+ margin: 0;
+ padding: 0 0 0 10px;
+ list-style: none;
+}
+
+div.related li {
+ display: inline;
+}
+
+div.related li.right {
+ float: right;
+ margin-right: 5px;
+}
+
+/* -- sidebar --------------------------------------------------------------- */
+
+div.sphinxsidebarwrapper {
+ padding: 10px 5px 0 10px;
+}
+
+div.sphinxsidebar {
+ float: left;
+ width: 230px;
+ margin-left: -100%;
+ font-size: 90%;
+}
+
+div.sphinxsidebar ul {
+ list-style: none;
+}
+
+div.sphinxsidebar ul ul,
+div.sphinxsidebar ul.want-points {
+ margin-left: 20px;
+ list-style: square;
+}
+
+div.sphinxsidebar ul ul {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+div.sphinxsidebar form {
+ margin-top: 10px;
+}
+
+div.sphinxsidebar input {
+ border: 1px solid #98dbcc;
+ font-family: sans-serif;
+ font-size: 1em;
+}
+
+img {
+ border: 0;
+}
+
+/* -- search page ----------------------------------------------------------- */
+
+ul.search {
+ margin: 10px 0 0 20px;
+ padding: 0;
+}
+
+ul.search li {
+ padding: 5px 0 5px 20px;
+ background-image: url(file.png);
+ background-repeat: no-repeat;
+ background-position: 0 7px;
+}
+
+ul.search li a {
+ font-weight: bold;
+}
+
+ul.search li div.context {
+ color: #888;
+ margin: 2px 0 0 30px;
+ text-align: left;
+}
+
+ul.keywordmatches li.goodmatch a {
+ font-weight: bold;
+}
+
+/* -- index page ------------------------------------------------------------ */
+
+table.contentstable {
+ width: 90%;
+}
+
+table.contentstable p.biglink {
+ line-height: 150%;
+}
+
+a.biglink {
+ font-size: 1.3em;
+}
+
+span.linkdescr {
+ font-style: italic;
+ padding-top: 5px;
+ font-size: 90%;
+}
+
+/* -- general index --------------------------------------------------------- */
+
+table.indextable td {
+ text-align: left;
+ vertical-align: top;
+}
+
+table.indextable dl, table.indextable dd {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+table.indextable tr.pcap {
+ height: 10px;
+}
+
+table.indextable tr.cap {
+ margin-top: 10px;
+ background-color: #f2f2f2;
+}
+
+img.toggler {
+ margin-right: 3px;
+ margin-top: 3px;
+ cursor: pointer;
+}
+
+/* -- general body styles --------------------------------------------------- */
+
+a.headerlink {
+ visibility: hidden;
+}
+
+h1:hover > a.headerlink,
+h2:hover > a.headerlink,
+h3:hover > a.headerlink,
+h4:hover > a.headerlink,
+h5:hover > a.headerlink,
+h6:hover > a.headerlink,
+dt:hover > a.headerlink {
+ visibility: visible;
+}
+
+div.body p.caption {
+ text-align: inherit;
+}
+
+div.body td {
+ text-align: left;
+}
+
+.field-list ul {
+ padding-left: 1em;
+}
+
+.first {
+ margin-top: 0 !important;
+}
+
+p.rubric {
+ margin-top: 30px;
+ font-weight: bold;
+}
+
+/* -- sidebars -------------------------------------------------------------- */
+
+div.sidebar {
+ margin: 0 0 0.5em 1em;
+ border: 1px solid #ddb;
+ padding: 7px 7px 0 7px;
+ background-color: #ffe;
+ width: 40%;
+ float: right;
+}
+
+p.sidebar-title {
+ font-weight: bold;
+}
+
+/* -- topics ---------------------------------------------------------------- */
+
+div.topic {
+ border: 1px solid #ccc;
+ padding: 7px 7px 0 7px;
+ margin: 10px 0 10px 0;
+}
+
+p.topic-title {
+ font-size: 1.1em;
+ font-weight: bold;
+ margin-top: 10px;
+}
+
+/* -- admonitions ----------------------------------------------------------- */
+
+div.admonition {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ padding: 7px;
+}
+
+div.admonition dt {
+ font-weight: bold;
+}
+
+div.admonition dl {
+ margin-bottom: 0;
+}
+
+p.admonition-title {
+ margin: 0px 10px 5px 0px;
+ font-weight: bold;
+}
+
+div.body p.centered {
+ text-align: center;
+ margin-top: 25px;
+}
+
+/* -- tables ---------------------------------------------------------------- */
+
+table.docutils {
+ border: 0;
+ border-collapse: collapse;
+}
+
+table.docutils td, table.docutils th {
+ padding: 1px 8px 1px 0;
+ border-top: 0;
+ border-left: 0;
+ border-right: 0;
+ border-bottom: 1px solid #aaa;
+}
+
+table.field-list td, table.field-list th {
+ border: 0 !important;
+}
+
+table.footnote td, table.footnote th {
+ border: 0 !important;
+}
+
+th {
+ text-align: left;
+ padding-right: 5px;
+}
+
+/* -- other body styles ----------------------------------------------------- */
+
+dl {
+ margin-bottom: 15px;
+}
+
+dd p {
+ margin-top: 0px;
+}
+
+dd ul, dd table {
+ margin-bottom: 10px;
+}
+
+dd {
+ margin-top: 3px;
+ margin-bottom: 10px;
+ margin-left: 30px;
+}
+
+dt:target, .highlight {
+ background-color: #fbe54e;
+}
+
+dl.glossary dt {
+ font-weight: bold;
+ font-size: 1.1em;
+}
+
+.field-list ul {
+ margin: 0;
+ padding-left: 1em;
+}
+
+.field-list p {
+ margin: 0;
+}
+
+.refcount {
+ color: #060;
+}
+
+.optional {
+ font-size: 1.3em;
+}
+
+.versionmodified {
+ font-style: italic;
+}
+
+.system-message {
+ background-color: #fda;
+ padding: 5px;
+ border: 3px solid red;
+}
+
+.footnote:target {
+ background-color: #ffa
+}
+
+/* -- code displays --------------------------------------------------------- */
+
+pre {
+ overflow: auto;
+}
+
+td.linenos pre {
+ padding: 5px 0px;
+ border: 0;
+ background-color: transparent;
+ color: #aaa;
+}
+
+table.highlighttable {
+ margin-left: 0.5em;
+}
+
+table.highlighttable td {
+ padding: 0 0.5em 0 0.5em;
+}
+
+tt.descname {
+ background-color: transparent;
+ font-weight: bold;
+ font-size: 1.2em;
+}
+
+tt.descclassname {
+ background-color: transparent;
+}
+
+tt.xref, a tt {
+ background-color: transparent;
+ font-weight: bold;
+}
+
+h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
+ background-color: transparent;
+}
+
+/* -- math display ---------------------------------------------------------- */
+
+img.math {
+ vertical-align: middle;
+}
+
+div.body div.math p {
+ text-align: center;
+}
+
+span.eqno {
+ float: right;
+}
+
+/* -- printout stylesheet --------------------------------------------------- */
+
+@media print {
+ div.document,
+ div.documentwrapper,
+ div.bodywrapper {
+ margin: 0;
+ width: 100%;
+ }
+
+ div.sphinxsidebar,
+ div.related,
+ div.footer,
+ #top-link {
+ display: none;
+ }
+}
diff --git a/docs/_build/html/_static/default.css b/docs/_build/html/_static/default.css
new file mode 100644
index 0000000..c999f67
--- /dev/null
+++ b/docs/_build/html/_static/default.css
@@ -0,0 +1,210 @@
+/**
+ * Sphinx stylesheet -- default theme
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+@import url("basic.css");
+
+/* -- page layout ----------------------------------------------------------- */
+
+body {
+ font-family: sans-serif;
+ font-size: 100%;
+ background-color: #11303d;
+ color: #000;
+ margin: 0;
+ padding: 0;
+}
+
+div.document {
+ background-color: #1c4e63;
+}
+
+div.documentwrapper {
+ float: left;
+ width: 100%;
+}
+
+div.bodywrapper {
+ margin: 0 0 0 230px;
+}
+
+div.body {
+ background-color: #ffffff;
+ color: #000000;
+ padding: 0 20px 30px 20px;
+}
+
+div.footer {
+ color: #ffffff;
+ width: 100%;
+ padding: 9px 0 9px 0;
+ text-align: center;
+ font-size: 75%;
+}
+
+div.footer a {
+ color: #ffffff;
+ text-decoration: underline;
+}
+
+div.related {
+ background-color: #133f52;
+ line-height: 30px;
+ color: #ffffff;
+}
+
+div.related a {
+ color: #ffffff;
+}
+
+div.sphinxsidebar {
+}
+
+div.sphinxsidebar h3 {
+ font-family: 'Trebuchet MS', sans-serif;
+ color: #ffffff;
+ font-size: 1.4em;
+ font-weight: normal;
+ margin: 0;
+ padding: 0;
+}
+
+div.sphinxsidebar h3 a {
+ color: #ffffff;
+}
+
+div.sphinxsidebar h4 {
+ font-family: 'Trebuchet MS', sans-serif;
+ color: #ffffff;
+ font-size: 1.3em;
+ font-weight: normal;
+ margin: 5px 0 0 0;
+ padding: 0;
+}
+
+div.sphinxsidebar p {
+ color: #ffffff;
+}
+
+div.sphinxsidebar p.topless {
+ margin: 5px 10px 10px 10px;
+}
+
+div.sphinxsidebar ul {
+ margin: 10px;
+ padding: 0;
+ color: #ffffff;
+}
+
+div.sphinxsidebar a {
+ color: #98dbcc;
+}
+
+div.sphinxsidebar input {
+ border: 1px solid #98dbcc;
+ font-family: sans-serif;
+ font-size: 1em;
+}
+
+/* -- body styles ----------------------------------------------------------- */
+
+a {
+ color: #355f7c;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+div.body p, div.body dd, div.body li {
+ text-align: justify;
+ line-height: 130%;
+}
+
+div.body h1,
+div.body h2,
+div.body h3,
+div.body h4,
+div.body h5,
+div.body h6 {
+ font-family: 'Trebuchet MS', sans-serif;
+ background-color: #f2f2f2;
+ font-weight: normal;
+ color: #20435c;
+ border-bottom: 1px solid #ccc;
+ margin: 20px -20px 10px -20px;
+ padding: 3px 0 3px 10px;
+}
+
+div.body h1 { margin-top: 0; font-size: 200%; }
+div.body h2 { font-size: 160%; }
+div.body h3 { font-size: 140%; }
+div.body h4 { font-size: 120%; }
+div.body h5 { font-size: 110%; }
+div.body h6 { font-size: 100%; }
+
+a.headerlink {
+ color: #c60f0f;
+ font-size: 0.8em;
+ padding: 0 4px 0 4px;
+ text-decoration: none;
+}
+
+a.headerlink:hover {
+ background-color: #c60f0f;
+ color: white;
+}
+
+div.body p, div.body dd, div.body li {
+ text-align: justify;
+ line-height: 130%;
+}
+
+div.admonition p.admonition-title + p {
+ display: inline;
+}
+
+div.note {
+ background-color: #eee;
+ border: 1px solid #ccc;
+}
+
+div.seealso {
+ background-color: #ffc;
+ border: 1px solid #ff6;
+}
+
+div.topic {
+ background-color: #eee;
+}
+
+div.warning {
+ background-color: #ffe4e4;
+ border: 1px solid #f66;
+}
+
+p.admonition-title {
+ display: inline;
+}
+
+p.admonition-title:after {
+ content: ":";
+}
+
+pre {
+ padding: 5px;
+ background-color: #eeffcc;
+ color: #333333;
+ line-height: 120%;
+ border: 1px solid #ac9;
+ border-left: none;
+ border-right: none;
+}
+
+tt {
+ background-color: #ecf0f3;
+ padding: 0 1px 0 1px;
+ font-size: 0.95em;
+}
\ No newline at end of file
diff --git a/docs/_build/html/_static/doctools.js b/docs/_build/html/_static/doctools.js
new file mode 100644
index 0000000..9447678
--- /dev/null
+++ b/docs/_build/html/_static/doctools.js
@@ -0,0 +1,232 @@
+/// XXX: make it cross browser
+
+/**
+ * make the code below compatible with browsers without
+ * an installed firebug like debugger
+ */
+if (!window.console || !console.firebug) {
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
+ window.console = {};
+ for (var i = 0; i < names.length; ++i)
+ window.console[names[i]] = function() {}
+}
+
+/**
+ * small helper function to urldecode strings
+ */
+jQuery.urldecode = function(x) {
+ return decodeURIComponent(x).replace(/\+/g, ' ');
+}
+
+/**
+ * small helper function to urlencode strings
+ */
+jQuery.urlencode = encodeURIComponent;
+
+/**
+ * This function returns the parsed url parameters of the
+ * current request. Multiple values per key are supported,
+ * it will always return arrays of strings for the value parts.
+ */
+jQuery.getQueryParameters = function(s) {
+ if (typeof s == 'undefined')
+ s = document.location.search;
+ var parts = s.substr(s.indexOf('?') + 1).split('&');
+ var result = {};
+ for (var i = 0; i < parts.length; i++) {
+ var tmp = parts[i].split('=', 2);
+ var key = jQuery.urldecode(tmp[0]);
+ var value = jQuery.urldecode(tmp[1]);
+ if (key in result)
+ result[key].push(value);
+ else
+ result[key] = [value];
+ }
+ return result;
+}
+
+/**
+ * small function to check if an array contains
+ * a given item.
+ */
+jQuery.contains = function(arr, item) {
+ for (var i = 0; i < arr.length; i++) {
+ if (arr[i] == item)
+ return true;
+ }
+ return false;
+}
+
+/**
+ * highlight a given string on a jquery object by wrapping it in
+ * span elements with the given class name.
+ */
+jQuery.fn.highlightText = function(text, className) {
+ function highlight(node) {
+ if (node.nodeType == 3) {
+ var val = node.nodeValue;
+ var pos = val.toLowerCase().indexOf(text);
+ if (pos >= 0 && !jQuery.className.has(node.parentNode, className)) {
+ var span = document.createElement("span");
+ span.className = className;
+ span.appendChild(document.createTextNode(val.substr(pos, text.length)));
+ node.parentNode.insertBefore(span, node.parentNode.insertBefore(
+ document.createTextNode(val.substr(pos + text.length)),
+ node.nextSibling));
+ node.nodeValue = val.substr(0, pos);
+ }
+ }
+ else if (!jQuery(node).is("button, select, textarea")) {
+ jQuery.each(node.childNodes, function() {
+ highlight(this)
+ });
+ }
+ }
+ return this.each(function() {
+ highlight(this);
+ });
+}
+
+/**
+ * Small JavaScript module for the documentation.
+ */
+var Documentation = {
+
+ init : function() {
+ this.fixFirefoxAnchorBug();
+ this.highlightSearchWords();
+ this.initModIndex();
+ },
+
+ /**
+ * i18n support
+ */
+ TRANSLATIONS : {},
+ PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
+ LOCALE : 'unknown',
+
+ // gettext and ngettext don't access this so that the functions
+ // can savely bound to a different name (_ = Documentation.gettext)
+ gettext : function(string) {
+ var translated = Documentation.TRANSLATIONS[string];
+ if (typeof translated == 'undefined')
+ return string;
+ return (typeof translated == 'string') ? translated : translated[0];
+ },
+
+ ngettext : function(singular, plural, n) {
+ var translated = Documentation.TRANSLATIONS[singular];
+ if (typeof translated == 'undefined')
+ return (n == 1) ? singular : plural;
+ return translated[Documentation.PLURALEXPR(n)];
+ },
+
+ addTranslations : function(catalog) {
+ for (var key in catalog.messages)
+ this.TRANSLATIONS[key] = catalog.messages[key];
+ this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
+ this.LOCALE = catalog.locale;
+ },
+
+ /**
+ * add context elements like header anchor links
+ */
+ addContextElements : function() {
+ $('div[id] > :header:first').each(function() {
+ $('<a class="headerlink">\u00B6</a>').
+ attr('href', '#' + this.id).
+ attr('title', _('Permalink to this headline')).
+ appendTo(this);
+ });
+ $('dt[id]').each(function() {
+ $('<a class="headerlink">\u00B6</a>').
+ attr('href', '#' + this.id).
+ attr('title', _('Permalink to this definition')).
+ appendTo(this);
+ });
+ },
+
+ /**
+ * workaround a firefox stupidity
+ */
+ fixFirefoxAnchorBug : function() {
+ if (document.location.hash && $.browser.mozilla)
+ window.setTimeout(function() {
+ document.location.href += '';
+ }, 10);
+ },
+
+ /**
+ * highlight the search words provided in the url in the text
+ */
+ highlightSearchWords : function() {
+ var params = $.getQueryParameters();
+ var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
+ if (terms.length) {
+ var body = $('div.body');
+ window.setTimeout(function() {
+ $.each(terms, function() {
+ body.highlightText(this.toLowerCase(), 'highlight');
+ });
+ }, 10);
+ $('<li class="highlight-link"><a href="javascript:Documentation.' +
+ 'hideSearchWords()">' + _('Hide Search Matches') + '</a></li>')
+ .appendTo($('.sidebar .this-page-menu'));
+ }
+ },
+
+ /**
+ * init the modindex toggle buttons
+ */
+ initModIndex : function() {
+ var togglers = $('img.toggler').click(function() {
+ var src = $(this).attr('src');
+ var idnum = $(this).attr('id').substr(7);
+ console.log($('tr.cg-' + idnum).toggle());
+ if (src.substr(-9) == 'minus.png')
+ $(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
+ else
+ $(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
+ }).css('display', '');
+ if (DOCUMENTATION_OPTIONS.COLLAPSE_MODINDEX) {
+ togglers.click();
+ }
+ },
+
+ /**
+ * helper function to hide the search marks again
+ */
+ hideSearchWords : function() {
+ $('.sidebar .this-page-menu li.highlight-link').fadeOut(300);
+ $('span.highlight').removeClass('highlight');
+ },
+
+ /**
+ * make the url absolute
+ */
+ makeURL : function(relativeURL) {
+ return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
+ },
+
+ /**
+ * get the current relative url
+ */
+ getCurrentURL : function() {
+ var path = document.location.pathname;
+ var parts = path.split(/\//);
+ $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
+ if (this == '..')
+ parts.pop();
+ });
+ var url = parts.join('/');
+ return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
+ }
+};
+
+// quick alias for translations
+_ = Documentation.gettext;
+
+$(document).ready(function() {
+ Documentation.init();
+});
diff --git a/docs/_build/html/_static/file.png b/docs/_build/html/_static/file.png
new file mode 100644
index 0000000..d18082e
Binary files /dev/null and b/docs/_build/html/_static/file.png differ
diff --git a/docs/_build/html/_static/jquery.js b/docs/_build/html/_static/jquery.js
new file mode 100644
index 0000000..82b98e1
--- /dev/null
+++ b/docs/_build/html/_static/jquery.js
@@ -0,0 +1,32 @@
+/*
+ * jQuery 1.2.6 - New Wave Javascript
+ *
+ * Copyright (c) 2008 John Resig (jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
+ * $Rev: 5685 $
+ */
+(function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
+return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
+return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
+selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
+return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
+this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
+return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
+jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&©&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
+script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
+for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
+for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
+jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
+ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&¬xml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&¬xml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&¬xml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
+while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
+while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
+for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var props="altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
+jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
+xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
+jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
+for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
+s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
+e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})();
\ No newline at end of file
diff --git a/docs/_build/html/_static/minus.png b/docs/_build/html/_static/minus.png
new file mode 100644
index 0000000..da1c562
Binary files /dev/null and b/docs/_build/html/_static/minus.png differ
diff --git a/docs/_build/html/_static/plus.png b/docs/_build/html/_static/plus.png
new file mode 100644
index 0000000..b3cb374
Binary files /dev/null and b/docs/_build/html/_static/plus.png differ
diff --git a/docs/_build/html/_static/pygments.css b/docs/_build/html/_static/pygments.css
new file mode 100644
index 0000000..1f2d2b6
--- /dev/null
+++ b/docs/_build/html/_static/pygments.css
@@ -0,0 +1,61 @@
+.hll { background-color: #ffffcc }
+.c { color: #408090; font-style: italic } /* Comment */
+.err { border: 1px solid #FF0000 } /* Error */
+.k { color: #007020; font-weight: bold } /* Keyword */
+.o { color: #666666 } /* Operator */
+.cm { color: #408090; font-style: italic } /* Comment.Multiline */
+.cp { color: #007020 } /* Comment.Preproc */
+.c1 { color: #408090; font-style: italic } /* Comment.Single */
+.cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
+.gd { color: #A00000 } /* Generic.Deleted */
+.ge { font-style: italic } /* Generic.Emph */
+.gr { color: #FF0000 } /* Generic.Error */
+.gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.gi { color: #00A000 } /* Generic.Inserted */
+.go { color: #303030 } /* Generic.Output */
+.gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
+.gs { font-weight: bold } /* Generic.Strong */
+.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.gt { color: #0040D0 } /* Generic.Traceback */
+.kc { color: #007020; font-weight: bold } /* Keyword.Constant */
+.kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
+.kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
+.kp { color: #007020 } /* Keyword.Pseudo */
+.kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
+.kt { color: #902000 } /* Keyword.Type */
+.m { color: #208050 } /* Literal.Number */
+.s { color: #4070a0 } /* Literal.String */
+.na { color: #4070a0 } /* Name.Attribute */
+.nb { color: #007020 } /* Name.Builtin */
+.nc { color: #0e84b5; font-weight: bold } /* Name.Class */
+.no { color: #60add5 } /* Name.Constant */
+.nd { color: #555555; font-weight: bold } /* Name.Decorator */
+.ni { color: #d55537; font-weight: bold } /* Name.Entity */
+.ne { color: #007020 } /* Name.Exception */
+.nf { color: #06287e } /* Name.Function */
+.nl { color: #002070; font-weight: bold } /* Name.Label */
+.nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
+.nt { color: #062873; font-weight: bold } /* Name.Tag */
+.nv { color: #bb60d5 } /* Name.Variable */
+.ow { color: #007020; font-weight: bold } /* Operator.Word */
+.w { color: #bbbbbb } /* Text.Whitespace */
+.mf { color: #208050 } /* Literal.Number.Float */
+.mh { color: #208050 } /* Literal.Number.Hex */
+.mi { color: #208050 } /* Literal.Number.Integer */
+.mo { color: #208050 } /* Literal.Number.Oct */
+.sb { color: #4070a0 } /* Literal.String.Backtick */
+.sc { color: #4070a0 } /* Literal.String.Char */
+.sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
+.s2 { color: #4070a0 } /* Literal.String.Double */
+.se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
+.sh { color: #4070a0 } /* Literal.String.Heredoc */
+.si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
+.sx { color: #c65d09 } /* Literal.String.Other */
+.sr { color: #235388 } /* Literal.String.Regex */
+.s1 { color: #4070a0 } /* Literal.String.Single */
+.ss { color: #517918 } /* Literal.String.Symbol */
+.bp { color: #007020 } /* Name.Builtin.Pseudo */
+.vc { color: #bb60d5 } /* Name.Variable.Class */
+.vg { color: #bb60d5 } /* Name.Variable.Global */
+.vi { color: #bb60d5 } /* Name.Variable.Instance */
+.il { color: #208050 } /* Literal.Number.Integer.Long */
\ No newline at end of file
diff --git a/docs/_build/html/_static/searchtools.js b/docs/_build/html/_static/searchtools.js
new file mode 100644
index 0000000..e022625
--- /dev/null
+++ b/docs/_build/html/_static/searchtools.js
@@ -0,0 +1,467 @@
+/**
+ * helper function to return a node containing the
+ * search summary for a given text. keywords is a list
+ * of stemmed words, hlwords is the list of normal, unstemmed
+ * words. the first one is used to find the occurance, the
+ * latter for highlighting it.
+ */
+
+jQuery.makeSearchSummary = function(text, keywords, hlwords) {
+ var textLower = text.toLowerCase();
+ var start = 0;
+ $.each(keywords, function() {
+ var i = textLower.indexOf(this.toLowerCase());
+ if (i > -1)
+ start = i;
+ });
+ start = Math.max(start - 120, 0);
+ var excerpt = ((start > 0) ? '...' : '') +
+ $.trim(text.substr(start, 240)) +
+ ((start + 240 - text.length) ? '...' : '');
+ var rv = $('<div class="context"></div>').text(excerpt);
+ $.each(hlwords, function() {
+ rv = rv.highlightText(this, 'highlight');
+ });
+ return rv;
+}
+
+/**
+ * Porter Stemmer
+ */
+var PorterStemmer = function() {
+
+ var step2list = {
+ ational: 'ate',
+ tional: 'tion',
+ enci: 'ence',
+ anci: 'ance',
+ izer: 'ize',
+ bli: 'ble',
+ alli: 'al',
+ entli: 'ent',
+ eli: 'e',
+ ousli: 'ous',
+ ization: 'ize',
+ ation: 'ate',
+ ator: 'ate',
+ alism: 'al',
+ iveness: 'ive',
+ fulness: 'ful',
+ ousness: 'ous',
+ aliti: 'al',
+ iviti: 'ive',
+ biliti: 'ble',
+ logi: 'log'
+ };
+
+ var step3list = {
+ icate: 'ic',
+ ative: '',
+ alize: 'al',
+ iciti: 'ic',
+ ical: 'ic',
+ ful: '',
+ ness: ''
+ };
+
+ var c = "[^aeiou]"; // consonant
+ var v = "[aeiouy]"; // vowel
+ var C = c + "[^aeiouy]*"; // consonant sequence
+ var V = v + "[aeiou]*"; // vowel sequence
+
+ var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
+ var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
+ var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
+ var s_v = "^(" + C + ")?" + v; // vowel in stem
+
+ this.stemWord = function (w) {
+ var stem;
+ var suffix;
+ var firstch;
+ var origword = w;
+
+ if (w.length < 3)
+ return w;
+
+ var re;
+ var re2;
+ var re3;
+ var re4;
+
+ firstch = w.substr(0,1);
+ if (firstch == "y")
+ w = firstch.toUpperCase() + w.substr(1);
+
+ // Step 1a
+ re = /^(.+?)(ss|i)es$/;
+ re2 = /^(.+?)([^s])s$/;
+
+ if (re.test(w))
+ w = w.replace(re,"$1$2");
+ else if (re2.test(w))
+ w = w.replace(re2,"$1$2");
+
+ // Step 1b
+ re = /^(.+?)eed$/;
+ re2 = /^(.+?)(ed|ing)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ re = new RegExp(mgr0);
+ if (re.test(fp[1])) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+ }
+ else if (re2.test(w)) {
+ var fp = re2.exec(w);
+ stem = fp[1];
+ re2 = new RegExp(s_v);
+ if (re2.test(stem)) {
+ w = stem;
+ re2 = /(at|bl|iz)$/;
+ re3 = new RegExp("([^aeiouylsz])\\1$");
+ re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+ if (re2.test(w))
+ w = w + "e";
+ else if (re3.test(w)) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+ else if (re4.test(w))
+ w = w + "e";
+ }
+ }
+
+ // Step 1c
+ re = /^(.+?)y$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(s_v);
+ if (re.test(stem))
+ w = stem + "i";
+ }
+
+ // Step 2
+ re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ suffix = fp[2];
+ re = new RegExp(mgr0);
+ if (re.test(stem))
+ w = stem + step2list[suffix];
+ }
+
+ // Step 3
+ re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ suffix = fp[2];
+ re = new RegExp(mgr0);
+ if (re.test(stem))
+ w = stem + step3list[suffix];
+ }
+
+ // Step 4
+ re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
+ re2 = /^(.+?)(s|t)(ion)$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(mgr1);
+ if (re.test(stem))
+ w = stem;
+ }
+ else if (re2.test(w)) {
+ var fp = re2.exec(w);
+ stem = fp[1] + fp[2];
+ re2 = new RegExp(mgr1);
+ if (re2.test(stem))
+ w = stem;
+ }
+
+ // Step 5
+ re = /^(.+?)e$/;
+ if (re.test(w)) {
+ var fp = re.exec(w);
+ stem = fp[1];
+ re = new RegExp(mgr1);
+ re2 = new RegExp(meq1);
+ re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
+ if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
+ w = stem;
+ }
+ re = /ll$/;
+ re2 = new RegExp(mgr1);
+ if (re.test(w) && re2.test(w)) {
+ re = /.$/;
+ w = w.replace(re,"");
+ }
+
+ // and turn initial Y back to y
+ if (firstch == "y")
+ w = firstch.toLowerCase() + w.substr(1);
+ return w;
+ }
+}
+
+
+/**
+ * Search Module
+ */
+var Search = {
+
+ _index : null,
+ _queued_query : null,
+ _pulse_status : -1,
+
+ init : function() {
+ var params = $.getQueryParameters();
+ if (params.q) {
+ var query = params.q[0];
+ $('input[name="q"]')[0].value = query;
+ this.performSearch(query);
+ }
+ },
+
+ /**
+ * Sets the index
+ */
+ setIndex : function(index) {
+ var q;
+ this._index = index;
+ if ((q = this._queued_query) !== null) {
+ this._queued_query = null;
+ Search.query(q);
+ }
+ },
+
+ hasIndex : function() {
+ return this._index !== null;
+ },
+
+ deferQuery : function(query) {
+ this._queued_query = query;
+ },
+
+ stopPulse : function() {
+ this._pulse_status = 0;
+ },
+
+ startPulse : function() {
+ if (this._pulse_status >= 0)
+ return;
+ function pulse() {
+ Search._pulse_status = (Search._pulse_status + 1) % 4;
+ var dotString = '';
+ for (var i = 0; i < Search._pulse_status; i++)
+ dotString += '.';
+ Search.dots.text(dotString);
+ if (Search._pulse_status > -1)
+ window.setTimeout(pulse, 500);
+ };
+ pulse();
+ },
+
+ /**
+ * perform a search for something
+ */
+ performSearch : function(query) {
+ // create the required interface elements
+ this.out = $('#search-results');
+ this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
+ this.dots = $('<span></span>').appendTo(this.title);
+ this.status = $('<p style="display: none"></p>').appendTo(this.out);
+ this.output = $('<ul class="search"/>').appendTo(this.out);
+
+ $('#search-progress').text(_('Preparing search...'));
+ this.startPulse();
+
+ // index already loaded, the browser was quick!
+ if (this.hasIndex())
+ this.query(query);
+ else
+ this.deferQuery(query);
+ },
+
+ query : function(query) {
+ // stem the searchterms and add them to the
+ // correct list
+ var stemmer = new PorterStemmer();
+ var searchterms = [];
+ var excluded = [];
+ var hlterms = [];
+ var tmp = query.split(/\s+/);
+ var object = (tmp.length == 1) ? tmp[0].toLowerCase() : null;
+ for (var i = 0; i < tmp.length; i++) {
+ // stem the word
+ var word = stemmer.stemWord(tmp[i]).toLowerCase();
+ // select the correct list
+ if (word[0] == '-') {
+ var toAppend = excluded;
+ word = word.substr(1);
+ }
+ else {
+ var toAppend = searchterms;
+ hlterms.push(tmp[i].toLowerCase());
+ }
+ // only add if not already in the list
+ if (!$.contains(toAppend, word))
+ toAppend.push(word);
+ };
+ var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));
+
+ console.debug('SEARCH: searching for:');
+ console.info('required: ', searchterms);
+ console.info('excluded: ', excluded);
+
+ // prepare search
+ var filenames = this._index.filenames;
+ var titles = this._index.titles;
+ var terms = this._index.terms;
+ var descrefs = this._index.descrefs;
+ var modules = this._index.modules;
+ var desctypes = this._index.desctypes;
+ var fileMap = {};
+ var files = null;
+ var objectResults = [];
+ var regularResults = [];
+ $('#search-progress').empty();
+
+ // lookup as object
+ if (object != null) {
+ for (var module in modules) {
+ if (module.indexOf(object) > -1) {
+ fn = modules[module];
+ descr = _('module, in ') + titles[fn];
+ objectResults.push([filenames[fn], module, '#module-'+module, descr]);
+ }
+ }
+ for (var prefix in descrefs) {
+ for (var name in descrefs[prefix]) {
+ var fullname = (prefix ? prefix + '.' : '') + name;
+ if (fullname.toLowerCase().indexOf(object) > -1) {
+ match = descrefs[prefix][name];
+ descr = desctypes[match[1]] + _(', in ') + titles[match[0]];
+ objectResults.push([filenames[match[0]], fullname, '#'+fullname, descr]);
+ }
+ }
+ }
+ }
+
+ // sort results descending
+ objectResults.sort(function(a, b) {
+ return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
+ });
+
+
+ // perform the search on the required terms
+ for (var i = 0; i < searchterms.length; i++) {
+ var word = searchterms[i];
+ // no match but word was a required one
+ if ((files = terms[word]) == null)
+ break;
+ if (files.length == undefined) {
+ files = [files];
+ }
+ // create the mapping
+ for (var j = 0; j < files.length; j++) {
+ var file = files[j];
+ if (file in fileMap)
+ fileMap[file].push(word);
+ else
+ fileMap[file] = [word];
+ }
+ }
+
+ // now check if the files don't contain excluded terms
+ for (var file in fileMap) {
+ var valid = true;
+
+ // check if all requirements are matched
+ if (fileMap[file].length != searchterms.length)
+ continue;
+
+ // ensure that none of the excluded terms is in the
+ // search result.
+ for (var i = 0; i < excluded.length; i++) {
+ if (terms[excluded[i]] == file ||
+ $.contains(terms[excluded[i]] || [], file)) {
+ valid = false;
+ break;
+ }
+ }
+
+ // if we have still a valid result we can add it
+ // to the result list
+ if (valid)
+ regularResults.push([filenames[file], titles[file], '', null]);
+ }
+
+ // delete unused variables in order to not waste
+ // memory until list is retrieved completely
+ delete filenames, titles, terms;
+
+ // now sort the regular results descending by title
+ regularResults.sort(function(a, b) {
+ var left = a[1].toLowerCase();
+ var right = b[1].toLowerCase();
+ return (left > right) ? -1 : ((left < right) ? 1 : 0);
+ });
+
+ // combine both
+ var results = regularResults.concat(objectResults);
+
+ // print the results
+ var resultCount = results.length;
+ function displayNextItem() {
+ // results left, load the summary and display it
+ if (results.length) {
+ var item = results.pop();
+ var listItem = $('<li style="display:none"></li>');
+ listItem.append($('<a/>').attr(
+ 'href',
+ item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
+ highlightstring + item[2]).html(item[1]));
+ if (item[3]) {
+ listItem.append($('<span> (' + item[3] + ')</span>'));
+ Search.output.append(listItem);
+ listItem.slideDown(5, function() {
+ displayNextItem();
+ });
+ } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
+ $.get('_sources/' + item[0] + '.txt', function(data) {
+ listItem.append($.makeSearchSummary(data, searchterms, hlterms));
+ Search.output.append(listItem);
+ listItem.slideDown(5, function() {
+ displayNextItem();
+ });
+ });
+ } else {
+ // no source available, just display title
+ Search.output.append(listItem);
+ listItem.slideDown(5, function() {
+ displayNextItem();
+ });
+ }
+ }
+ // search finished, update title and status message
+ else {
+ Search.stopPulse();
+ Search.title.text(_('Search Results'));
+ if (!resultCount)
+ Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
+ else
+ Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
+ Search.status.fadeIn(500);
+ }
+ }
+ displayNextItem();
+ }
+}
+
+$(document).ready(function() {
+ Search.init();
+});
diff --git a/docs/_build/html/backwards.html b/docs/_build/html/backwards.html
new file mode 100644
index 0000000..17d8acd
--- /dev/null
+++ b/docs/_build/html/backwards.html
@@ -0,0 +1,120 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Backwards Incompatible Changes — Django Multilingual v0.2 documentation</title>
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.2',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <link rel="top" title="Django Multilingual v0.2 documentation" href="index.html" />
+ <link rel="prev" title="Multilingual Flatpages" href="flatpages.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="flatpages.html" title="Multilingual Flatpages"
+ accesskey="P">previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <div class="section" id="backwards-incompatible-changes">
+<h1>Backwards Incompatible Changes<a class="headerlink" href="#backwards-incompatible-changes" title="Permalink to this headline">¶</a></h1>
+<div class="section" id="translation-table-rename">
+<h2>Translation table rename<a class="headerlink" href="#translation-table-rename" title="Permalink to this headline">¶</a></h2>
+<p>In revision 98 the default name for translation tables was changed: instead of
+“modeltranslation” it is now “model_translation”. You don’t have to rename your
+tables, just upgrade to DM revision 102 or later and add a Meta class within
+your translation model:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
+ <span class="p">[</span><span class="o">...</span><span class="p">]</span>
+ <span class="k">class</span> <span class="nc">Translation</span><span class="p">(</span><span class="n">multilingual</span><span class="o">.</span><span class="n">Translation</span><span class="p">):</span>
+ <span class="n">my_field</span> <span class="o">=</span> <span class="o">...</span>
+ <span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
+ <span class="n">db_table</span><span class="o">=</span><span class="s">"my_modeltranslation"</span>
+</pre></div>
+</div>
+<p>Note that this “class Meta” is inside the inner Translation class.</p>
+</div>
+</div>
+
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+ <h3><a href="index.html">Table Of Contents</a></h3>
+ <ul>
+<li><a class="reference external" href="">Backwards Incompatible Changes</a><ul>
+<li><a class="reference external" href="#translation-table-rename">Translation table rename</a></li>
+</ul>
+</li>
+</ul>
+
+ <h4>Previous topic</h4>
+ <p class="topless"><a href="flatpages.html"
+ title="previous chapter">Multilingual Flatpages</a></p>
+ <h3>This Page</h3>
+ <ul class="this-page-menu">
+ <li><a href="_sources/backwards.txt"
+ rel="nofollow">Show Source</a></li>
+ </ul>
+ <div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="search.html" method="get">
+ <input type="text" name="q" size="18" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+ </div>
+ <script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="flatpages.html" title="Multilingual Flatpages"
+ >previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+ <div class="footer">
+ © Copyright 2009, Marcin Kaszynski.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/html/flatpages.html b/docs/_build/html/flatpages.html
new file mode 100644
index 0000000..f873684
--- /dev/null
+++ b/docs/_build/html/flatpages.html
@@ -0,0 +1,125 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Multilingual Flatpages — Django Multilingual v0.2 documentation</title>
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.2',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <link rel="top" title="Django Multilingual v0.2 documentation" href="index.html" />
+ <link rel="next" title="Backwards Incompatible Changes" href="backwards.html" />
+ <link rel="prev" title="Add middleware to set the default language" href="middleware.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="backwards.html" title="Backwards Incompatible Changes"
+ accesskey="N">next</a> |</li>
+ <li class="right" >
+ <a href="middleware.html" title="Add middleware to set the default language"
+ accesskey="P">previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <div class="section" id="multilingual-flatpages">
+<h1>Multilingual Flatpages<a class="headerlink" href="#multilingual-flatpages" title="Permalink to this headline">¶</a></h1>
+<p>The Django flatpages application is “[...] a simple object with a URL, title and
+content. Use it for one-off, special-case pages, such as ‘About’ or ‘Privacy Policy’
+pages, that you want to store in a database but for which you donât want to develop
+a custom Django application.”</p>
+<p>If you have a website in multiple languages you will want to have these pages in
+your supported languages. Django-multilingual comes with a version of flatpages
+that has translatable name and content fields. You install it by adding
+<tt class="docutils literal"><span class="pre">multilingual.flatpages</span></tt> to the installed applications list:</p>
+<div class="highlight-python"><pre>INSTALLED_APPS = (
+ ...
+ 'multilingual',
+ 'multilingual.flatpages',
+ ...
+)</pre>
+</div>
+<p>The multilingual flatpages should now be available in the admin interface. They
+use the same templates as the original flatpages application: <tt class="docutils literal"><span class="pre">flatpages/base.html</span></tt>.</p>
+<p>You will want to enable the middleware Django Multilingual provides if you want your
+pages to appear in the correct language automatically.</p>
+</div>
+
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+ <h4>Previous topic</h4>
+ <p class="topless"><a href="middleware.html"
+ title="previous chapter">Add middleware to set the default language</a></p>
+ <h4>Next topic</h4>
+ <p class="topless"><a href="backwards.html"
+ title="next chapter">Backwards Incompatible Changes</a></p>
+ <h3>This Page</h3>
+ <ul class="this-page-menu">
+ <li><a href="_sources/flatpages.txt"
+ rel="nofollow">Show Source</a></li>
+ </ul>
+ <div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="search.html" method="get">
+ <input type="text" name="q" size="18" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+ </div>
+ <script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="backwards.html" title="Backwards Incompatible Changes"
+ >next</a> |</li>
+ <li class="right" >
+ <a href="middleware.html" title="Add middleware to set the default language"
+ >previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+ <div class="footer">
+ © Copyright 2009, Marcin Kaszynski.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/html/genindex.html b/docs/_build/html/genindex.html
new file mode 100644
index 0000000..6d874d7
--- /dev/null
+++ b/docs/_build/html/genindex.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Index — Django Multilingual v0.2 documentation</title>
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.2',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <link rel="top" title="Django Multilingual v0.2 documentation" href="index.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="" title="General Index"
+ accesskey="I">index</a></li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+
+ <h1 id="index">Index</h1>
+
+
+
+ <hr />
+
+
+
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+
+
+
+ <div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="search.html" method="get">
+ <input type="text" name="q" size="18" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+ </div>
+ <script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="" title="General Index"
+ >index</a></li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+ <div class="footer">
+ © Copyright 2009, Marcin Kaszynski.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/html/index.html b/docs/_build/html/index.html
new file mode 100644
index 0000000..916e47f
--- /dev/null
+++ b/docs/_build/html/index.html
@@ -0,0 +1,127 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Welcome to Django Multilingualâs documentation! — Django Multilingual v0.2 documentation</title>
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.2',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <link rel="top" title="Django Multilingual v0.2 documentation" href="" />
+ <link rel="next" title="Django Multilingual" href="overview.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="overview.html" title="Django Multilingual"
+ accesskey="N">next</a> |</li>
+ <li><a href="">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <div class="section" id="welcome-to-django-multilingual-s-documentation">
+<h1>Welcome to Django Multilingual’s documentation!<a class="headerlink" href="#welcome-to-django-multilingual-s-documentation" title="Permalink to this headline">¶</a></h1>
+<p>Contents:</p>
+<ul>
+<li class="toctree-l1"><a class="reference external" href="overview.html">Django Multilingual</a><ul>
+<li class="toctree-l2"><a class="reference external" href="overview.html#configuration">Configuration</a></li>
+<li class="toctree-l2"><a class="reference external" href="overview.html#model-setup">Model Setup</a></li>
+<li class="toctree-l2"><a class="reference external" href="overview.html#meta-class"><tt class="docutils literal"><span class="pre">Meta</span></tt> Class</a></li>
+</ul>
+</li>
+<li class="toctree-l1"><a class="reference external" href="middleware.html">Add middleware to set the default language</a></li>
+<li class="toctree-l1"><a class="reference external" href="flatpages.html">Multilingual Flatpages</a></li>
+<li class="toctree-l1"><a class="reference external" href="backwards.html">Backwards Incompatible Changes</a><ul>
+<li class="toctree-l2"><a class="reference external" href="backwards.html#translation-table-rename">Translation table rename</a></li>
+</ul>
+</li>
+</ul>
+</div>
+<div class="section" id="indices-and-tables">
+<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
+<ul class="simple">
+<li><a class="reference external" href="genindex.html"><em>Index</em></a></li>
+<li><a class="reference external" href="modindex.html"><em>Module Index</em></a></li>
+<li><a class="reference external" href="search.html"><em>Search Page</em></a></li>
+</ul>
+</div>
+
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+ <h3><a href="">Table Of Contents</a></h3>
+ <ul>
+<li><a class="reference external" href="">Welcome to Django Multilingual’s documentation!</a><ul>
+</ul>
+</li>
+<li><a class="reference external" href="#indices-and-tables">Indices and tables</a></li>
+</ul>
+
+ <h4>Next topic</h4>
+ <p class="topless"><a href="overview.html"
+ title="next chapter">Django Multilingual</a></p>
+ <h3>This Page</h3>
+ <ul class="this-page-menu">
+ <li><a href="_sources/index.txt"
+ rel="nofollow">Show Source</a></li>
+ </ul>
+ <div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="search.html" method="get">
+ <input type="text" name="q" size="18" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+ </div>
+ <script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="overview.html" title="Django Multilingual"
+ >next</a> |</li>
+ <li><a href="">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+ <div class="footer">
+ © Copyright 2009, Marcin Kaszynski.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/html/middleware.html b/docs/_build/html/middleware.html
new file mode 100644
index 0000000..34cde7f
--- /dev/null
+++ b/docs/_build/html/middleware.html
@@ -0,0 +1,122 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Add middleware to set the default language — Django Multilingual v0.2 documentation</title>
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.2',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <link rel="top" title="Django Multilingual v0.2 documentation" href="index.html" />
+ <link rel="next" title="Multilingual Flatpages" href="flatpages.html" />
+ <link rel="prev" title="Django Multilingual" href="overview.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="flatpages.html" title="Multilingual Flatpages"
+ accesskey="N">next</a> |</li>
+ <li class="right" >
+ <a href="overview.html" title="Django Multilingual"
+ accesskey="P">previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <div class="section" id="add-middleware-to-set-the-default-language">
+<h1>Add middleware to set the default language<a class="headerlink" href="#add-middleware-to-set-the-default-language" title="Permalink to this headline">¶</a></h1>
+<p>Django contains middleware that automatically discovers the browser’s language
+and allows the user to change it. All translated strings in Python code and
+templates are then automatically shown in this language. (See the official
+Django documentation.) You can use the same language as the default translation
+for model fields.</p>
+<p>Add <tt class="docutils literal"><span class="pre">multilingual.middleware.DefaultLanguageMiddleware</span></tt> to your <tt class="docutils literal"><span class="pre">MIDDLEWARE_CLASSES</span></tt>:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">MIDDLEWARE_CLASSES</span> <span class="o">=</span> <span class="p">(</span>
+ <span class="c">#...</span>
+ <span class="s">'django.middleware.locale.LocaleMiddleware'</span><span class="p">,</span>
+ <span class="s">'multilingual.middleware.DefaultLanguageMiddleware'</span><span class="p">,</span>
+ <span class="c">#...</span>
+<span class="p">)</span>
+</pre></div>
+</div>
+<p>The multilingual middleware must come after the language discovery middleware,
+in this case <tt class="docutils literal"><span class="pre">django.middleware.locale.LocaleMiddleware</span></tt>.</p>
+</div>
+
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+ <h4>Previous topic</h4>
+ <p class="topless"><a href="overview.html"
+ title="previous chapter">Django Multilingual</a></p>
+ <h4>Next topic</h4>
+ <p class="topless"><a href="flatpages.html"
+ title="next chapter">Multilingual Flatpages</a></p>
+ <h3>This Page</h3>
+ <ul class="this-page-menu">
+ <li><a href="_sources/middleware.txt"
+ rel="nofollow">Show Source</a></li>
+ </ul>
+ <div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="search.html" method="get">
+ <input type="text" name="q" size="18" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+ </div>
+ <script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="flatpages.html" title="Multilingual Flatpages"
+ >next</a> |</li>
+ <li class="right" >
+ <a href="overview.html" title="Django Multilingual"
+ >previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+ <div class="footer">
+ © Copyright 2009, Marcin Kaszynski.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/html/objects.inv b/docs/_build/html/objects.inv
new file mode 100644
index 0000000..9989b0e
--- /dev/null
+++ b/docs/_build/html/objects.inv
@@ -0,0 +1,3 @@
+# Sphinx inventory version 1
+# Project: Django Multilingual
+# Version: 0.2
diff --git a/docs/_build/html/overview.html b/docs/_build/html/overview.html
new file mode 100644
index 0000000..e11ccc6
--- /dev/null
+++ b/docs/_build/html/overview.html
@@ -0,0 +1,204 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Django Multilingual — Django Multilingual v0.2 documentation</title>
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.2',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <link rel="top" title="Django Multilingual v0.2 documentation" href="index.html" />
+ <link rel="next" title="Add middleware to set the default language" href="middleware.html" />
+ <link rel="prev" title="Welcome to Django Multilingualâs documentation!" href="index.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="middleware.html" title="Add middleware to set the default language"
+ accesskey="N">next</a> |</li>
+ <li class="right" >
+ <a href="index.html" title="Welcome to Django Multilingualâs documentation!"
+ accesskey="P">previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <div class="section" id="django-multilingual">
+<h1>Django Multilingual<a class="headerlink" href="#django-multilingual" title="Permalink to this headline">¶</a></h1>
+<div class="section" id="configuration">
+<h2>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h2>
+<p>After following the instructions over at <tt class="docutils literal"><span class="pre">INSTALL</span></tt>, we need to configure our
+app’s <tt class="docutils literal"><span class="pre">settings.py</span></tt> file.</p>
+<ul>
+<li><p class="first">Add <tt class="docutils literal"><span class="pre">LANGUAGES</span></tt> setting this is the same setting that is used by Django’s
+i18n:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">LANGUAGES</span> <span class="o">=</span> <span class="p">(</span>
+ <span class="p">(</span><span class="s">'en'</span><span class="p">,</span> <span class="s">'English'</span><span class="p">),</span>
+ <span class="p">(</span><span class="s">'pl'</span><span class="p">,</span> <span class="s">'Polish'</span><span class="p">),</span>
+<span class="p">)</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">Add <tt class="docutils literal"><span class="pre">DEFAULT_LANGUAGE</span></tt>, in this example setting it to 1 would make the
+default English as it is first in the <tt class="docutils literal"><span class="pre">LANGUAGES</span></tt> list:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">DEFAULT_LANGUAGE</span> <span class="o">=</span> <span class="mi">1</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">Add multilingual.context_processors.multilingual to <tt class="docutils literal"><span class="pre">TEMPLATE_CONTEXT_PROCESSORS</span></tt>,
+it should look something like this:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">TEMPLATE_CONTEXT_PROCESSORS</span> <span class="o">=</span> <span class="p">(</span>
+ <span class="s">'django.core.context_processors.auth'</span><span class="p">,</span>
+ <span class="s">'django.core.context_processors.debug'</span><span class="p">,</span>
+ <span class="s">'django.core.context_processors.i18n'</span><span class="p">,</span>
+ <span class="s">'multilingual.context_processors.multilingual'</span><span class="p">,</span>
+<span class="p">)</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">Add multilingual to <tt class="docutils literal"><span class="pre">INSTALLED_APPS</span></tt>, it should look like this:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">INSTALLED_APPS</span> <span class="o">=</span> <span class="p">(</span>
+ <span class="s">'django.contrib.auth'</span><span class="p">,</span>
+ <span class="s">'django.contrib.contenttypes'</span><span class="p">,</span>
+ <span class="s">'django.contrib.sessions'</span><span class="p">,</span>
+ <span class="s">'django.contrib.sites'</span><span class="p">,</span>
+ <span class="s">'django.contrib.admin'</span><span class="p">,</span>
+ <span class="s">'multilingual'</span><span class="p">,</span>
+<span class="p">)</span>
+</pre></div>
+</div>
+</li>
+</ul>
+</div>
+<div class="section" id="model-setup">
+<h2>Model Setup<a class="headerlink" href="#model-setup" title="Permalink to this headline">¶</a></h2>
+<p>Once this is done, we need to setup our Model.</p>
+<ul>
+<li><p class="first">At the top of the model file import multilingual:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">multilingual</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">Create the model, the sub-class translation contains all the fields that
+will have multiple language data. For example:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Category</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
+ <span class="n">parent</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="s">'self'</span><span class="p">,</span> <span class="n">blank</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">null</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
+
+ <span class="k">class</span> <span class="nc">Translation</span><span class="p">(</span><span class="n">multilingual</span><span class="o">.</span><span class="n">Translation</span><span class="p">):</span>
+ <span class="n">name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">250</span><span class="p">)</span>
+
+ <span class="k">def</span> <span class="nf">__unicode__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
+ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
+</pre></div>
+</div>
+</li>
+</ul>
+</div>
+<div class="section" id="meta-class">
+<h2><tt class="docutils literal"><span class="pre">Meta</span></tt> Class<a class="headerlink" href="#meta-class" title="Permalink to this headline">¶</a></h2>
+<p>You may also add a <tt class="docutils literal"><span class="pre">Meta</span></tt> inner class to the <tt class="docutils literal"><span class="pre">Translation</span></tt> class to
+configure the translation mechanism. Currently, the only properties
+recognized is:</p>
+<div class="highlight-python"><pre>db_table sets the database table name (default: <model>_translation)</pre>
+</div>
+<p>An example:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Dog</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
+ <span class="n">owner</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="n">Human</span><span class="p">)</span>
+
+ <span class="k">class</span> <span class="nc">Translation</span><span class="p">(</span><span class="n">multilingual</span><span class="o">.</span><span class="n">Translation</span><span class="p">):</span>
+ <span class="n">breed</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">50</span><span class="p">)</span>
+
+ <span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
+ <span class="n">db_table</span> <span class="o">=</span> <span class="s">'dog_languages_table'</span>
+</pre></div>
+</div>
+</div>
+</div>
+
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+ <h3><a href="index.html">Table Of Contents</a></h3>
+ <ul>
+<li><a class="reference external" href="">Django Multilingual</a><ul>
+<li><a class="reference external" href="#configuration">Configuration</a></li>
+<li><a class="reference external" href="#model-setup">Model Setup</a></li>
+<li><a class="reference external" href="#meta-class"><tt class="docutils literal"><span class="pre">Meta</span></tt> Class</a></li>
+</ul>
+</li>
+</ul>
+
+ <h4>Previous topic</h4>
+ <p class="topless"><a href="index.html"
+ title="previous chapter">Welcome to Django Multilingual’s documentation!</a></p>
+ <h4>Next topic</h4>
+ <p class="topless"><a href="middleware.html"
+ title="next chapter">Add middleware to set the default language</a></p>
+ <h3>This Page</h3>
+ <ul class="this-page-menu">
+ <li><a href="_sources/overview.txt"
+ rel="nofollow">Show Source</a></li>
+ </ul>
+ <div id="searchbox" style="display: none">
+ <h3>Quick search</h3>
+ <form class="search" action="search.html" method="get">
+ <input type="text" name="q" size="18" />
+ <input type="submit" value="Go" />
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+ <p class="searchtip" style="font-size: 90%">
+ Enter search terms or a module, class or function name.
+ </p>
+ </div>
+ <script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="middleware.html" title="Add middleware to set the default language"
+ >next</a> |</li>
+ <li class="right" >
+ <a href="index.html" title="Welcome to Django Multilingualâs documentation!"
+ >previous</a> |</li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+ <div class="footer">
+ © Copyright 2009, Marcin Kaszynski.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/html/search.html b/docs/_build/html/search.html
new file mode 100644
index 0000000..f8de8a6
--- /dev/null
+++ b/docs/_build/html/search.html
@@ -0,0 +1,91 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Search — Django Multilingual v0.2 documentation</title>
+ <link rel="stylesheet" href="_static/default.css" type="text/css" />
+ <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '',
+ VERSION: '0.2',
+ COLLAPSE_MODINDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true
+ };
+ </script>
+ <script type="text/javascript" src="_static/jquery.js"></script>
+ <script type="text/javascript" src="_static/doctools.js"></script>
+ <script type="text/javascript" src="_static/searchtools.js"></script>
+ <link rel="top" title="Django Multilingual v0.2 documentation" href="index.html" />
+ </head>
+ <body>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body">
+
+ <h1 id="search-documentation">Search</h1>
+ <div id="fallback" class="admonition warning">
+ <script type="text/javascript">$('#fallback').hide();</script>
+ <p>
+ Please activate JavaScript to enable the search
+ functionality.
+ </p>
+ </div>
+ <p>
+ From here you can search these documents. Enter your search
+ words into the box below and click "search". Note that the search
+ function will automatically search for all of the words. Pages
+ containing fewer words won't appear in the result list.
+ </p>
+ <form action="" method="get">
+ <input type="text" name="q" value="" />
+ <input type="submit" value="search" />
+ <span id="search-progress" style="padding-left: 10px"></span>
+ </form>
+
+ <div id="search-results">
+
+ </div>
+
+ </div>
+ </div>
+ </div>
+ <div class="sphinxsidebar">
+ <div class="sphinxsidebarwrapper">
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="genindex.html" title="General Index"
+ >index</a></li>
+ <li><a href="index.html">Django Multilingual v0.2 documentation</a> »</li>
+ </ul>
+ </div>
+
+ <div class="footer">
+ © Copyright 2009, Marcin Kaszynski.
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
+ </div>
+ <script type="text/javascript" src="searchindex.js"></script>
+
+ </body>
+</html>
\ No newline at end of file
diff --git a/docs/_build/html/searchindex.js b/docs/_build/html/searchindex.js
new file mode 100644
index 0000000..f4bb0d9
--- /dev/null
+++ b/docs/_build/html/searchindex.js
@@ -0,0 +1 @@
+Search.setIndex({desctypes:{},terms:{multilingu:[0,1,2,3,4],code:1,defaultlanguagemiddlewar:1,just:2,over:4,all:[4,1],session:4,human:4,follow:4,renam:[0,2],languag:[0,1,3,4],content:[0,3],onli:4,also:4,polici:3,configur:[0,4],should:[4,3],add:[0,1,2,4],local:1,offici:1,applic:3,"return":4,string:1,thei:3,python:1,auth:4,context_processor:4,mechan:4,now:[2,3],enabl:3,contenttyp:4,like:4,list:[4,3],db_tabl:[4,2],"default":[0,1,2,4],flatpag:[0,3],contain:[4,1],debug:4,categori:4,page:[0,3],app:4,set:[0,1,4],localemiddlewar:1,owner:4,see:1,meta:[0,2,4],polish:4,our:4,special:3,dog_languages_t:4,index:0,shown:1,appear:3,databas:[4,3],someth:4,discoveri:1,current:4,version:3,"import":4,correct:3,core:4,after:[4,1],insid:2,base:3,come:[1,3],"__unicode__":4,about:3,admin:[4,3],charfield:4,chang:[0,1,2],top:4,first:4,origin:3,"_translat":4,onc:4,modul:0,within:2,automat:[1,3],instruct:4,done:4,blank:4,contrib:4,instal:[4,3],installed_app:[4,3],your:[1,2,3],middlewar:[0,1,3],avail:3,would:4,support:3,breed:4,my_modeltransl:2,upgrad:2,name:[4,2,3],websit:3,my_field:2,interfac:3,inner:[4,2],privaci:3,store:3,search:0,translat:[0,1,2,3,4],i18n:4,off:3,"true":4,must:1,"case":[1,3],look:4,provid:3,setup:[0,4],properti:4,can:1,foreignkei:4,def:4,browser:1,file:4,creat:4,site:4,templat:[1,3],template_context_processor:4,have:[4,2,3],tabl:[0,2,4],need:4,revis:2,incompat:[0,2],default_languag:4,modeltransl:2,parent:4,"null":4,develop:3,welcom:0,want:3,titl:3,make:4,custom:3,same:[4,1,3],note:2,field:[4,1,3],html:3,indic:0,instead:2,you:[4,1,2,3],document:[0,1],simpl:3,recogn:4,allow:1,max_length:4,object:3,middleware_class:1,discov:1,user:1,mai:4,multipl:[4,3],data:4,"class":[0,2,4],sub:4,don:[2,3],url:3,mymodel:2,later:2,dog:4,django:[0,1,3,4],which:3,exampl:4,thi:[4,1,2],english:4,model_transl:2,model:[0,1,2,4],backward:[0,2],self:4},titles:["Welcome to Django Multilingual’s documentation!","Add middleware to set the default language","Backwards Incompatible Changes","Multilingual Flatpages","Django Multilingual"],modules:{},descrefs:{},filenames:["index","middleware","backwards","flatpages","overview"]})
\ No newline at end of file
diff --git a/docs/backwards.rst b/docs/backwards.rst
new file mode 100644
index 0000000..02aaeda
--- /dev/null
+++ b/docs/backwards.rst
@@ -0,0 +1,21 @@
+==============================
+Backwards Incompatible Changes
+==============================
+
+
+Translation table rename
+========================
+
+In revision 98 the default name for translation tables was changed: instead of
+"modeltranslation" it is now "model_translation". You don't have to rename your
+tables, just upgrade to DM revision 102 or later and add a Meta class within
+your translation model::
+
+ class MyModel(models.Model):
+ [...]
+ class Translation(multilingual.Translation):
+ my_field = ...
+ class Meta:
+ db_table="my_modeltranslation"
+
+Note that this "class Meta" is inside the inner Translation class.
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..cc6ad3f
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,194 @@
+# -*- coding: utf-8 -*-
+#
+# Django Multilingual documentation build configuration file, created by
+# sphinx-quickstart on Mon Dec 14 21:00:06 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Django Multilingual'
+copyright = u'2009, Marcin Kaszynski'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.2'
+# The full version, including alpha/beta/rc tags.
+release = '0.2'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'DjangoMultilingualdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'DjangoMultilingual.tex', u'Django Multilingual Documentation',
+ u'Marcin Kaszynski', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True
diff --git a/docs/flatpages.rst b/docs/flatpages.rst
new file mode 100644
index 0000000..b3450d2
--- /dev/null
+++ b/docs/flatpages.rst
@@ -0,0 +1,29 @@
+======================
+Multilingual Flatpages
+======================
+
+
+The Django flatpages application is "[...] a simple object with a URL, title and
+content. Use it for one-off, special-case pages, such as 'About' or 'Privacy Policy'
+pages, that you want to store in a database but for which you donât want to develop
+a custom Django application."
+
+If you have a website in multiple languages you will want to have these pages in
+your supported languages. Django-multilingual comes with a version of flatpages
+that has translatable name and content fields. You install it by adding
+``multilingual.flatpages`` to the installed applications list::
+
+ INSTALLED_APPS = (
+ ...
+ 'multilingual',
+ 'multilingual.flatpages',
+ ...
+ )
+
+The multilingual flatpages should now be available in the admin interface. They
+use the same templates as the original flatpages application: ``flatpages/base.html``.
+
+You will want to enable the middleware Django Multilingual provides if you want your
+pages to appear in the correct language automatically.
+
+.. vi:ft=rst:expandtab:shiftwidth=4
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..c632ae1
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,25 @@
+.. Django Multilingual documentation master file, created by
+ sphinx-quickstart on Mon Dec 14 21:00:06 2009.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to Django Multilingual's documentation!
+===============================================
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ overview
+ middleware
+ flatpages
+ backwards
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..3d0f4f2
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,113 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=sphinx-build
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^<target^>` where ^<target^> is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+ del /q /s %BUILDDIR%\*
+ goto end
+)
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+ echo.
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\DjangoMultilingual.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\DjangoMultilingual.ghc
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+ echo.
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+ echo.
+ echo.The overview file is in %BUILDDIR%/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+ goto end
+)
+
+:end
diff --git a/docs/middleware.rst b/docs/middleware.rst
new file mode 100644
index 0000000..cb82b8f
--- /dev/null
+++ b/docs/middleware.rst
@@ -0,0 +1,23 @@
+==========================================
+Add middleware to set the default language
+==========================================
+
+Django contains middleware that automatically discovers the browser's language
+and allows the user to change it. All translated strings in Python code and
+templates are then automatically shown in this language. (See the official
+Django documentation.) You can use the same language as the default translation
+for model fields.
+
+Add ``multilingual.middleware.DefaultLanguageMiddleware`` to your ``MIDDLEWARE_CLASSES``::
+
+ MIDDLEWARE_CLASSES = (
+ #...
+ 'django.middleware.locale.LocaleMiddleware',
+ 'multilingual.middleware.DefaultLanguageMiddleware',
+ #...
+ )
+
+The multilingual middleware must come after the language discovery middleware,
+in this case ``django.middleware.locale.LocaleMiddleware``.
+
+.. vi:ft=rst:expandtab:shiftwidth=4
diff --git a/docs/overview.rst b/docs/overview.rst
new file mode 100644
index 0000000..94ff24c
--- /dev/null
+++ b/docs/overview.rst
@@ -0,0 +1,87 @@
+===================
+Django Multilingual
+===================
+
+
+Configuration
+=============
+
+After following the instructions over at ``INSTALL``, we need to configure our
+app's ``settings.py`` file.
+
+* Add ``LANGUAGES`` setting this is the same setting that is used by Django's
+ i18n::
+
+ LANGUAGES = (
+ ('en', 'English'),
+ ('pl', 'Polish'),
+ )
+
+* Add ``DEFAULT_LANGUAGE``, in this example setting it to 1 would make the
+ default English as it is first in the ``LANGUAGES`` list::
+
+ DEFAULT_LANGUAGE = 1
+
+* Add multilingual.context_processors.multilingual to ``TEMPLATE_CONTEXT_PROCESSORS``,
+ it should look something like this::
+
+ TEMPLATE_CONTEXT_PROCESSORS = (
+ 'django.core.context_processors.auth',
+ 'django.core.context_processors.debug',
+ 'django.core.context_processors.i18n',
+ 'multilingual.context_processors.multilingual',
+ )
+
+* Add multilingual to ``INSTALLED_APPS``, it should look like this::
+
+ INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ 'multilingual',
+ )
+
+Model Setup
+===========
+
+Once this is done, we need to setup our Model.
+
+* At the top of the model file import multilingual::
+
+ import multilingual
+
+* Create the model, the sub-class translation contains all the fields that
+ will have multiple language data. For example::
+
+ class Category(models.Model):
+ parent = models.ForeignKey('self', blank=True, null=True)
+
+ class Translation(multilingual.Translation):
+ name = models.CharField(max_length=250)
+
+ def __unicode__(self):
+ return self.name
+
+``Meta`` Class
+==============
+
+You may also add a ``Meta`` inner class to the ``Translation`` class to
+configure the translation mechanism. Currently, the only properties
+recognized is::
+
+ db_table sets the database table name (default: <model>_translation)
+
+An example::
+
+ class Dog(models.Model):
+ owner = models.ForeignKey(Human)
+
+ class Translation(multilingual.Translation):
+ breed = models.CharField(max_length=50)
+
+ class Meta:
+ db_table = 'dog_languages_table'
+
+.. vi:ft=rst:expandtab:shiftwidth=4
|
stefanfoulis/django-multilingual
|
e2874ff5dacc111c20fe428ce74652609cce63d8
|
Raise TranslationDoesNotExists in fallback code if the instance has no translation
|
diff --git a/multilingual/translation.py b/multilingual/translation.py
index 00639d6..19ac54d 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,370 +1,371 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from multilingual.admin import install_multilingual_modeladmin_new
# TODO: remove this import. It is here only because earlier versions
# of the library required importing TranslationModelAdmin from here
# instead of taking it directly from multilingual
from multilingual.admin import TranslationModelAdmin
from new import instancemethod
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None,
fallback=False):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
self.fallback = fallback
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id,
self.fallback)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None, fallback=False):
try:
return getattr(self.get_translation(language_id_or_code,
fallback=fallback),
field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False,
fallback=False):
"""
Get a translation instance for the given `language_id_or_code`.
If the translation does not exist:
1. if `create_if_necessary` is True, this function will create one
2. otherwise, if `fallback` is True, this function will search the
list of languages looking for the first existing translation
3. if all of the above fails to find a translation, raise the
TranslationDoesNotExist exception
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id in self._translation_cache:
return self._translation_cache.get(language_id, None)
if create_if_necessary:
# case 1
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return new_translation
elif fallback:
# case 2
for fb_lang_id in FALLBACK_LANGUAGE_IDS:
trans = self._translation_cache.get(fb_lang_id, None)
if trans:
return trans
+ raise TranslationDoesNotExist(language_id)
else:
# case 3
raise TranslationDoesNotExist(language_id)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# add the 'fname'_any fallback
setattr(main_cls, fname + FALLBACK_FIELD_SUFFIX,
TranslatedFieldProxy(fname, fname, field, fallback=True))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
# add the 'fname'_'language_code'_any fallback proxy
setattr(main_cls, fname_lng + FALLBACK_FIELD_SUFFIX,
TranslatedFieldProxy(fname, fname_lng, field,
language_id, fallback=True))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.Translation = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
install_multilingual_modeladmin_new()
# install the library
install_translation_library()
|
stefanfoulis/django-multilingual
|
74d273d8ec6f1244cf01abc6618360cf67a43ae9
|
Fixed test assertion
|
diff --git a/testproject/fallback/tests.py b/testproject/fallback/tests.py
index 1fb3b92..9bdca95 100644
--- a/testproject/fallback/tests.py
+++ b/testproject/fallback/tests.py
@@ -1,55 +1,55 @@
from django.test import TestCase
import multilingual
from testproject.fallback.models import Article
from testproject.fallback.models import Comment
class FallbackTestCase(TestCase):
def test_fallback(self):
# sanity check first
self.assertEqual(multilingual.FALLBACK_LANGUAGES,
['zh-cn', 'pl'])
# create test articles
Article.objects.all().delete()
Article.objects.create(title_pl = 'pl title 1',
content_pl = 'pl content 1',
title_zh_cn = 'zh-cn title 1',
content_zh_cn = 'zh-cn content 1')
Article.objects.create(title_pl = 'pl title 2',
content_pl = '',
title_zh_cn = 'zh-cn title 2',
content_zh_cn = 'zh-cn content 2')
#create test comment without translations
Comment.objects.all().delete()
Comment.objects.create(username='theuser')
# set english as the default language
multilingual.languages.set_default_language('en')
# fallback should not fail if instance has no translations
c = Comment.objects.get(username='theuser')
- c.body
+ self.assertTrue(c.body_any is None)
# the tests
a = Article.objects.get(title_zh_cn='zh-cn title 1')
self.assertEqual(a.title_any, 'zh-cn title 1')
self.assertEqual(a.content_any, 'zh-cn content 1')
self.assertEqual(a.title_en, None)
self.assertEqual(a.title_en_any, 'zh-cn title 1')
self.assertEqual(a.content_en, None)
self.assertEqual(a.content_en_any, 'zh-cn content 1')
self.assertEqual(a.title_pl_any, 'pl title 1')
self.assertEqual(a.content_pl_any, 'pl content 1')
a = Article.objects.get(title_zh_cn='zh-cn title 2')
self.assertEqual(a.title_any, 'zh-cn title 2')
self.assertEqual(a.content_any, 'zh-cn content 2')
self.assertEqual(a.title_en, None)
self.assertEqual(a.title_en_any, 'zh-cn title 2')
self.assertEqual(a.content_en, None)
self.assertEqual(a.content_en_any, 'zh-cn content 2')
self.assertEqual(a.title_pl_any, 'pl title 2')
self.assertEqual(a.content_pl_any, '')
|
stefanfoulis/django-multilingual
|
68c12835d85d08096e00c439c2a3721b947db301
|
Added test and model to check fallback errors related to empty translation cache
|
diff --git a/testproject/fallback/models.py b/testproject/fallback/models.py
index b99cdd4..60f1ee4 100644
--- a/testproject/fallback/models.py
+++ b/testproject/fallback/models.py
@@ -1,12 +1,17 @@
"""
Unit tests for the translation fallback feature.
"""
from django.db import models
import multilingual
class Article(models.Model):
class Translation(multilingual.Translation):
title = models.CharField(max_length=250, null=False, blank=False)
content = models.TextField(null=False, blank=True)
+ signature = models.TextField(null=True, blank=True)
+class Comment(models.Model):
+ username = models.CharField(blank=True, max_length=100)
+ class Translation(multilingual.Translation):
+ body = models.TextField(null=True, blank=True)
diff --git a/testproject/fallback/tests.py b/testproject/fallback/tests.py
index f3304b0..1fb3b92 100644
--- a/testproject/fallback/tests.py
+++ b/testproject/fallback/tests.py
@@ -1,46 +1,55 @@
from django.test import TestCase
import multilingual
from testproject.fallback.models import Article
+from testproject.fallback.models import Comment
class FallbackTestCase(TestCase):
def test_fallback(self):
# sanity check first
self.assertEqual(multilingual.FALLBACK_LANGUAGES,
['zh-cn', 'pl'])
# create test articles
Article.objects.all().delete()
Article.objects.create(title_pl = 'pl title 1',
content_pl = 'pl content 1',
title_zh_cn = 'zh-cn title 1',
content_zh_cn = 'zh-cn content 1')
Article.objects.create(title_pl = 'pl title 2',
content_pl = '',
title_zh_cn = 'zh-cn title 2',
content_zh_cn = 'zh-cn content 2')
-
+
+ #create test comment without translations
+ Comment.objects.all().delete()
+ Comment.objects.create(username='theuser')
+
# set english as the default language
multilingual.languages.set_default_language('en')
+
+ # fallback should not fail if instance has no translations
+ c = Comment.objects.get(username='theuser')
+ c.body
# the tests
a = Article.objects.get(title_zh_cn='zh-cn title 1')
self.assertEqual(a.title_any, 'zh-cn title 1')
self.assertEqual(a.content_any, 'zh-cn content 1')
self.assertEqual(a.title_en, None)
self.assertEqual(a.title_en_any, 'zh-cn title 1')
self.assertEqual(a.content_en, None)
self.assertEqual(a.content_en_any, 'zh-cn content 1')
self.assertEqual(a.title_pl_any, 'pl title 1')
self.assertEqual(a.content_pl_any, 'pl content 1')
-
+
a = Article.objects.get(title_zh_cn='zh-cn title 2')
self.assertEqual(a.title_any, 'zh-cn title 2')
self.assertEqual(a.content_any, 'zh-cn content 2')
self.assertEqual(a.title_en, None)
self.assertEqual(a.title_en_any, 'zh-cn title 2')
self.assertEqual(a.content_en, None)
self.assertEqual(a.content_en_any, 'zh-cn content 2')
self.assertEqual(a.title_pl_any, 'pl title 2')
self.assertEqual(a.content_pl_any, '')
|
stefanfoulis/django-multilingual
|
f7c1ad1ea7c21f5e6a6358d526ae5b4d04e2cf55
|
Fixed FALLBACK_LANGUAGE_IDS initialization
|
diff --git a/multilingual/languages.py b/multilingual/languages.py
index 23157a0..92c5202 100644
--- a/multilingual/languages.py
+++ b/multilingual/languages.py
@@ -1,127 +1,127 @@
"""
Django-multilingual: language-related settings and functions.
"""
# Note: this file did become a mess and will have to be refactored
# after the configuration changes get in place.
#retrieve language settings from settings.py
from django.conf import settings
LANGUAGES = settings.LANGUAGES
try:
FALLBACK_LANGUAGES = settings.MULTILINGUAL_FALLBACK_LANGUAGES
except AttributeError:
FALLBACK_LANGUAGES = [lang[0] for lang in settings.LANGUAGES]
from django.utils.translation import ugettext_lazy as _
from multilingual.exceptions import LanguageDoesNotExist
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
thread_locals = local()
def get_language_count():
return len(LANGUAGES)
def get_language_code(language_id):
return LANGUAGES[(int(language_id or get_default_language())) - 1][0]
def get_language_name(language_id):
return _(LANGUAGES[(int(language_id or get_default_language())) - 1][1])
def get_language_bidi(language_id):
return get_language_code(language_id) in settings.LANGUAGES_BIDI
def get_language_id_list():
return range(1, get_language_count() + 1)
def get_language_code_list():
return [lang[0] for lang in LANGUAGES]
def get_language_choices():
return [(language_id, get_language_code(language_id))
for language_id in get_language_id_list()]
def get_language_id_from_id_or_code(language_id_or_code, use_default=True):
if language_id_or_code is None:
if use_default:
return get_default_language()
else:
return None
if isinstance(language_id_or_code, int):
return language_id_or_code
i = 0
for (code, desc) in LANGUAGES:
i += 1
if code == language_id_or_code:
return i
if language_id_or_code.startswith("%s-" % code):
return i
raise LanguageDoesNotExist(language_id_or_code)
def get_language_idx(language_id_or_code):
# to do: optimize
language_id = get_language_id_from_id_or_code(language_id_or_code)
return get_language_id_list().index(language_id)
def set_default_language(language_id_or_code):
"""
Set the default language for the whole translation mechanism.
Accepts language codes or IDs.
"""
language_id = get_language_id_from_id_or_code(language_id_or_code)
thread_locals.DEFAULT_LANGUAGE = language_id
def get_default_language():
"""
Return the language ID set by set_default_language.
"""
return getattr(thread_locals, 'DEFAULT_LANGUAGE',
settings.DEFAULT_LANGUAGE)
def get_default_language_code():
"""
Return the language code of language ID set by set_default_language.
"""
language_id = get_language_id_from_id_or_code(get_default_language())
return get_language_code(language_id)
def _to_db_identifier(name):
"""
Convert name to something that is usable as a field name or table
alias in SQL.
For the time being assume that the only possible problem with name
is the presence of dashes.
"""
return name.replace('-', '_')
def get_translation_table_alias(translation_table_name, language_id):
"""
Return an alias for the translation table for a given language_id.
Used in SQL queries.
"""
return (translation_table_name
+ '_'
+ _to_db_identifier(get_language_code(language_id)))
def get_translated_field_alias(field_name, language_id=None):
"""
Return an alias for field_name field for a given language_id.
Used in SQL queries.
"""
return ('_trans_'
+ field_name
+ '_' + _to_db_identifier(get_language_code(language_id)))
-FALLBACK_LANGUAGE_IDS = [get_language_idx(lang_code) for lang_code in FALLBACK_LANGUAGES]
+FALLBACK_LANGUAGE_IDS = [get_language_id_from_id_or_code(lang_code) for lang_code in FALLBACK_LANGUAGES]
FALLBACK_FIELD_SUFFIX = '_any'
|
stefanfoulis/django-multilingual
|
bbbe22dd97560de16e418d41e3d1ecf53201b702
|
Added translation fallback fields (title_any, title_pl_any etc).
|
diff --git a/multilingual/__init__.py b/multilingual/__init__.py
index 2a31747..04dda91 100644
--- a/multilingual/__init__.py
+++ b/multilingual/__init__.py
@@ -1,10 +1,13 @@
"""
Django-multilingual: multilingual model support for Django.
"""
from multilingual import models
from multilingual.exceptions import TranslationDoesNotExist, LanguageDoesNotExist
-from multilingual.languages import set_default_language, get_default_language, get_language_code_list
+from multilingual.languages import (set_default_language, get_default_language,
+ get_language_code_list, FALLBACK_LANGUAGES)
from multilingual.translation import Translation
from multilingual.admin import ModelAdmin, TranslationModelAdmin
from multilingual.manager import Manager
+
+
diff --git a/multilingual/languages.py b/multilingual/languages.py
index 2fe79de..23157a0 100644
--- a/multilingual/languages.py
+++ b/multilingual/languages.py
@@ -1,117 +1,127 @@
"""
Django-multilingual: language-related settings and functions.
"""
# Note: this file did become a mess and will have to be refactored
# after the configuration changes get in place.
#retrieve language settings from settings.py
from django.conf import settings
LANGUAGES = settings.LANGUAGES
+try:
+ FALLBACK_LANGUAGES = settings.MULTILINGUAL_FALLBACK_LANGUAGES
+except AttributeError:
+ FALLBACK_LANGUAGES = [lang[0] for lang in settings.LANGUAGES]
+
from django.utils.translation import ugettext_lazy as _
from multilingual.exceptions import LanguageDoesNotExist
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
thread_locals = local()
def get_language_count():
return len(LANGUAGES)
def get_language_code(language_id):
return LANGUAGES[(int(language_id or get_default_language())) - 1][0]
def get_language_name(language_id):
return _(LANGUAGES[(int(language_id or get_default_language())) - 1][1])
def get_language_bidi(language_id):
return get_language_code(language_id) in settings.LANGUAGES_BIDI
def get_language_id_list():
return range(1, get_language_count() + 1)
def get_language_code_list():
return [lang[0] for lang in LANGUAGES]
def get_language_choices():
return [(language_id, get_language_code(language_id))
for language_id in get_language_id_list()]
def get_language_id_from_id_or_code(language_id_or_code, use_default=True):
if language_id_or_code is None:
if use_default:
return get_default_language()
else:
return None
if isinstance(language_id_or_code, int):
return language_id_or_code
i = 0
for (code, desc) in LANGUAGES:
i += 1
if code == language_id_or_code:
return i
if language_id_or_code.startswith("%s-" % code):
return i
raise LanguageDoesNotExist(language_id_or_code)
def get_language_idx(language_id_or_code):
# to do: optimize
language_id = get_language_id_from_id_or_code(language_id_or_code)
return get_language_id_list().index(language_id)
def set_default_language(language_id_or_code):
"""
Set the default language for the whole translation mechanism.
Accepts language codes or IDs.
"""
language_id = get_language_id_from_id_or_code(language_id_or_code)
thread_locals.DEFAULT_LANGUAGE = language_id
def get_default_language():
"""
Return the language ID set by set_default_language.
"""
return getattr(thread_locals, 'DEFAULT_LANGUAGE',
settings.DEFAULT_LANGUAGE)
def get_default_language_code():
"""
Return the language code of language ID set by set_default_language.
"""
language_id = get_language_id_from_id_or_code(get_default_language())
return get_language_code(language_id)
def _to_db_identifier(name):
"""
Convert name to something that is usable as a field name or table
alias in SQL.
For the time being assume that the only possible problem with name
is the presence of dashes.
"""
return name.replace('-', '_')
def get_translation_table_alias(translation_table_name, language_id):
"""
Return an alias for the translation table for a given language_id.
Used in SQL queries.
"""
return (translation_table_name
+ '_'
+ _to_db_identifier(get_language_code(language_id)))
def get_translated_field_alias(field_name, language_id=None):
"""
Return an alias for field_name field for a given language_id.
Used in SQL queries.
"""
return ('_trans_'
+ field_name
+ '_' + _to_db_identifier(get_language_code(language_id)))
+
+FALLBACK_LANGUAGE_IDS = [get_language_idx(lang_code) for lang_code in FALLBACK_LANGUAGES]
+
+FALLBACK_FIELD_SUFFIX = '_any'
+
diff --git a/multilingual/translation.py b/multilingual/translation.py
index 82d2cfe..00639d6 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,340 +1,370 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from multilingual.admin import install_multilingual_modeladmin_new
# TODO: remove this import. It is here only because earlier versions
# of the library required importing TranslationModelAdmin from here
# instead of taking it directly from multilingual
from multilingual.admin import TranslationModelAdmin
from new import instancemethod
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
- def __init__(self, field_name, alias, field, language_id=None):
+ def __init__(self, field_name, alias, field, language_id=None,
+ fallback=False):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
+ self.fallback = fallback
def __get__(self, obj, objtype=None):
if obj is None:
return self
- return getattr(obj, 'get_' + self.field_name)(self.language_id)
+ return getattr(obj, 'get_' + self.field_name)(self.language_id,
+ self.fallback)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
- def get_translation_field(self, language_id_or_code=None):
+ def get_translation_field(self, language_id_or_code=None, fallback=False):
try:
- return getattr(self.get_translation(language_id_or_code), field_name)
+ return getattr(self.get_translation(language_id_or_code,
+ fallback=fallback),
+ field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
- create_if_necessary=False):
+ create_if_necessary=False,
+ fallback=False):
"""
- Get a translation instance for the given language_id_or_code.
+ Get a translation instance for the given `language_id_or_code`.
- If it does not exist, either create one or raise the
- TranslationDoesNotExist exception, depending on the
- create_if_necessary argument.
+ If the translation does not exist:
+
+ 1. if `create_if_necessary` is True, this function will create one
+ 2. otherwise, if `fallback` is True, this function will search the
+ list of languages looking for the first existing translation
+ 3. if all of the above fails to find a translation, raise the
+ TranslationDoesNotExist exception
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
- if language_id not in self._translation_cache:
- if not create_if_necessary:
- raise TranslationDoesNotExist(language_id)
+ if language_id in self._translation_cache:
+ return self._translation_cache.get(language_id, None)
+
+ if create_if_necessary:
+ # case 1
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
- return self._translation_cache.get(language_id, None)
+ return new_translation
+ elif fallback:
+ # case 2
+ for fb_lang_id in FALLBACK_LANGUAGE_IDS:
+ trans = self._translation_cache.get(fb_lang_id, None)
+ if trans:
+ return trans
+ else:
+ # case 3
+ raise TranslationDoesNotExist(language_id)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
+ # add the 'fname'_any fallback
+ setattr(main_cls, fname + FALLBACK_FIELD_SUFFIX,
+ TranslatedFieldProxy(fname, fname, field, fallback=True))
+
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
+ # add the 'fname'_'language_code'_any fallback proxy
+ setattr(main_cls, fname_lng + FALLBACK_FIELD_SUFFIX,
+ TranslatedFieldProxy(fname, fname_lng, field,
+ language_id, fallback=True))
+
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.Translation = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
install_multilingual_modeladmin_new()
# install the library
install_translation_library()
diff --git a/testproject/fallback/__init__.py b/testproject/fallback/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/testproject/fallback/models.py b/testproject/fallback/models.py
new file mode 100644
index 0000000..b99cdd4
--- /dev/null
+++ b/testproject/fallback/models.py
@@ -0,0 +1,12 @@
+"""
+Unit tests for the translation fallback feature.
+"""
+
+from django.db import models
+import multilingual
+
+class Article(models.Model):
+ class Translation(multilingual.Translation):
+ title = models.CharField(max_length=250, null=False, blank=False)
+ content = models.TextField(null=False, blank=True)
+
diff --git a/testproject/fallback/tests.py b/testproject/fallback/tests.py
new file mode 100644
index 0000000..a9891df
--- /dev/null
+++ b/testproject/fallback/tests.py
@@ -0,0 +1,43 @@
+from django.test import TestCase
+import multilingual
+
+from testproject.fallback.models import Article
+
+class FallbackTestCase(TestCase):
+ def test_fallback(self):
+ # sanity check first
+ self.assertEqual(multilingual.FALLBACK_LANGUAGES,
+ ['pl', 'zh-cn'])
+
+ # create test articles
+ Article.objects.all().delete()
+ Article.objects.create(title_pl = 'pl title 1',
+ content_pl = 'pl content 1',
+ title_zh_cn = 'zh-cn title 1',
+ content_zh_cn = 'zh-cn content 1')
+ Article.objects.create(title_pl = 'pl title 2',
+ content_pl = '',
+ title_zh_cn = 'zh-cn title 2',
+ content_zh_cn = 'zh-cn content 2')
+
+ # the tests
+ a = Article.objects.get(title_pl='pl title 1')
+ self.assertEqual(a.title_any, 'pl title 1')
+ self.assertEqual(a.content_any, 'pl content 1')
+ self.assertEqual(a.title_en, None)
+ self.assertEqual(a.title_en_any, 'pl title 1')
+ self.assertEqual(a.content_en, None)
+ self.assertEqual(a.content_en_any, 'pl content 1')
+ self.assertEqual(a.title_zh_cn_any, 'zh-cn title 1')
+ self.assertEqual(a.content_zh_cn_any, 'zh-cn content 1')
+
+ a = Article.objects.get(title_pl='pl title 2')
+ self.assertEqual(a.title_any, 'pl title 2')
+ self.assertEqual(a.content_any, '')
+ self.assertEqual(a.title_en, None)
+ self.assertEqual(a.title_en_any, 'pl title 2')
+ self.assertEqual(a.content_en, None)
+ self.assertEqual(a.content_en_any, '')
+ self.assertEqual(a.title_zh_cn_any, 'zh-cn title 2')
+ self.assertEqual(a.content_zh_cn_any, 'zh-cn content 2')
+
diff --git a/testproject/settings.py b/testproject/settings.py
index 8fbbacb..e14fbe1 100644
--- a/testproject/settings.py
+++ b/testproject/settings.py
@@ -1,130 +1,133 @@
# Django settings for testproject project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'database.db3' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en'
# django-multilanguange #####################
# It is important that the language identifiers are consecutive
# numbers starting with 1.
LANGUAGES = [['en', 'English'], # id=1
['pl', 'Polish'], # id=2
['zh-cn', 'Simplified Chinese'], # id=3
]
DEFAULT_LANGUAGE = 1
##############################################
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '1+t11&r9nw+d7uw558+8=#j8!8^$nt97ecgv()-@x!tcef7f6)'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'multilingual.flatpages.middleware.FlatpageFallbackMiddleware',
)
ROOT_URLCONF = 'testproject.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'../multilingual/templates/',
'templates/',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'multilingual',
'multilingual.flatpages',
'testproject.articles',
+ 'testproject.fallback',
'testproject.inline_registrations',
'testproject.issue_15',
'testproject.issue_16',
'testproject.issue_23',
'testproject.issue_29',
'testproject.issue_37',
'testproject.issue_61',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'multilingual.context_processors.multilingual',
)
+MULTILINGUAL_FALLBACK_LANGUAGES = ['pl', 'zh-cn']
+
try:
# install the debug toolbar if available
import debug_toolbar
MIDDLEWARE_CLASSES = (
'debug_toolbar.middleware.DebugToolbarMiddleware',
) + MIDDLEWARE_CLASSES
INSTALLED_APPS += ('debug_toolbar',)
INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False
}
except ImportError:
pass
|
stefanfoulis/django-multilingual
|
0ed6d802e158a97a9c1c8373eac5d289124e9b28
|
Code cleanup, removing some pieces that are no longer necessary.
|
diff --git a/multilingual/translation.py b/multilingual/translation.py
index 374d335..82d2cfe 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,368 +1,340 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from multilingual.admin import install_multilingual_modeladmin_new
# TODO: remove this import. It is here only because earlier versions
# of the library required importing TranslationModelAdmin from here
# instead of taking it directly from multilingual
from multilingual.admin import TranslationModelAdmin
from new import instancemethod
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
-def translation_overwrite_previous(instance, **kwargs):
- """
- Delete previously existing translation with the same master and
- language_id values. To be called by translation model's pre_save
- signal.
-
- This most probably means I am abusing something here trying to use
- Django inline editor. Oh well, it will have to go anyway when we
- move to newforms.
- """
- qs = instance.__class__.objects
- try:
- qs = qs.filter(master=instance.master).filter(language_id=instance.language_id)
- qs.delete()
- except ObjectDoesNotExist:
- # We are probably loading a fixture that defines translation entities
- # before their master entity.
- pass
-
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None):
try:
return getattr(self.get_translation(language_id_or_code), field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False):
"""
Get a translation instance for the given language_id_or_code.
If it does not exist, either create one or raise the
TranslationDoesNotExist exception, depending on the
create_if_necessary argument.
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id not in self._translation_cache:
if not create_if_necessary:
raise TranslationDoesNotExist(language_id)
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return self._translation_cache.get(language_id, None)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.Translation = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
- # connect the pre_save signal on translation class to a
- # function removing previous translation entries.
- signals.pre_save.connect(translation_overwrite_previous,
- sender=trans_model, weak=False)
-
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
- # Install a hack to let add_multilingual_manipulators know
- # this is a translatable model (TODO: manipulators gone)
- attrs['is_translation_model'] = lambda self: True
-
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
install_multilingual_modeladmin_new()
# install the library
install_translation_library()
|
stefanfoulis/django-multilingual
|
a26bdfb96fd790b922565e96a97c92f503bf8b49
|
Bugfix: the "delete" checkbox would not work correctly in some situations.
|
diff --git a/multilingual/admin.py b/multilingual/admin.py
index 1203dfa..52e645c 100644
--- a/multilingual/admin.py
+++ b/multilingual/admin.py
@@ -1,204 +1,203 @@
from django.contrib import admin
from django.forms.models import BaseInlineFormSet
from django.forms.fields import BooleanField
from django.forms.formsets import DELETION_FIELD_NAME
from django.forms.util import ErrorDict
from django.utils.translation import ugettext as _
from multilingual.languages import *
from multilingual.utils import is_multilingual_model
def _translation_form_full_clean(self, previous_full_clean):
"""
There is a bug in Django that causes inline forms to be
validated even if they are marked for deletion.
This function fixes that by disabling validation
completely if the delete field is marked and only copying
the absolutely required fields: PK and FK to parent.
TODO: create a fix for Django, have it accepted into trunk and get
rid of this monkey patch.
"""
def cleaned_value(name):
field = self.fields[name]
val = field.widget.value_from_datadict(self.data, self.files,
self.add_prefix(name))
return field.clean(val)
delete = cleaned_value(DELETION_FIELD_NAME)
if delete:
# this object is to be skipped or deleted, so only
# construct the minimal cleaned_data
self.cleaned_data = {'DELETE': delete,
- 'id': cleaned_value('id'),
- 'master': cleaned_value('master')}
+ 'id': cleaned_value('id')}
self._errors = ErrorDict()
else:
return previous_full_clean()
class TranslationInlineFormSet(BaseInlineFormSet):
def _construct_forms(self):
## set the right default values for language_ids of empty (new) forms
super(TranslationInlineFormSet, self)._construct_forms()
empty_forms = []
lang_id_list = get_language_id_list()
lang_to_form = dict(zip(lang_id_list, [None] * len(lang_id_list)))
for form in self.forms:
language_id = form.initial.get('language_id')
if language_id:
lang_to_form[language_id] = form
else:
empty_forms.append(form)
for language_id in lang_id_list:
form = lang_to_form[language_id]
if form is None:
form = empty_forms.pop(0)
form.initial['language_id'] = language_id
def add_fields(self, form, index):
super(TranslationInlineFormSet, self).add_fields(form, index)
previous_full_clean = form.full_clean
form.full_clean = lambda: _translation_form_full_clean(form, previous_full_clean)
class TranslationModelAdmin(admin.StackedInline):
template = "admin/edit_inline_translations_newforms.html"
fk_name = 'master'
extra = get_language_count()
max_num = get_language_count()
formset = TranslationInlineFormSet
class ModelAdminClass(admin.ModelAdmin.__metaclass__):
"""
A metaclass for ModelAdmin below.
"""
def __new__(cls, name, bases, attrs):
# Move prepopulated_fields somewhere where Django won't see
# them. We have to handle them ourselves.
prepopulated_fields = attrs.get('prepopulated_fields', {})
attrs['prepopulated_fields'] = {}
attrs['_dm_prepopulated_fields'] = prepopulated_fields
return super(ModelAdminClass, cls).__new__(cls, name, bases, attrs)
class ModelAdmin(admin.ModelAdmin):
"""
All model admins for multilingual models must inherit this class
instead of django.contrib.admin.ModelAdmin.
"""
__metaclass__ = ModelAdminClass
def _media(self):
media = super(ModelAdmin, self)._media()
if getattr(self.__class__, '_dm_prepopulated_fields', None):
from django.conf import settings
media.add_js(['%sjs/urlify.js' % (settings.ADMIN_MEDIA_PREFIX,)])
return media
media = property(_media)
def render_change_form(self, request, context, add=False, change=False,
form_url='', obj=None):
# I'm overriding render_change_form to inject information
# about prepopulated_fields
trans_model = self.model._meta.translation_model
trans_fields = trans_model._meta.translated_fields
adminform = context['adminform']
form = adminform.form
def field_name_to_fake_field(field_name):
"""
Return something that looks like a form field enough to
fool prepopulated_fields_js.html
For field_names of real fields in self.model this actually
returns a real form field.
"""
try:
field, language_id = trans_fields[field_name]
if language_id is None:
language_id = get_default_language()
# TODO: we have this mapping between language_id and
# field id in two places -- here and in
# edit_inline_translations_newforms.html
# It is not DRY.
field_idx = language_id - 1
ret = {'auto_id': 'id_translations-%d-%s' % (field_idx, field.name)
}
except:
ret = form[field_name]
return ret
adminform.prepopulated_fields = [{
'field': field_name_to_fake_field(field_name),
'dependencies': [field_name_to_fake_field(f) for f in dependencies]
} for field_name, dependencies in self._dm_prepopulated_fields.items()]
return super(ModelAdmin, self).render_change_form(request, context,
add, change, form_url, obj)
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
return tr_cls
# TODO: multilingual_modeladmin_new should go away soon. The code will
# be split between the ModelAdmin class, its metaclass and validation
# code.
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
if is_multilingual_model(model):
if cls is admin.ModelAdmin:
# the model is being registered with the default
# django.contrib.admin.options.ModelAdmin. Replace it
# with our ModelAdmin, since it is safe to assume it is a
# simple call to admin.site.register without just model
# passed
# subclass it, because we need to set the inlines class
# attribute below
cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
# make sure it subclasses multilingual.ModelAdmin
if not issubclass(cls, ModelAdmin):
from warnings import warn
warn("%s should be registered with a subclass of "
" of multilingual.ModelAdmin." % model, DeprecationWarning)
# if the inlines already contain a class for the
# translation model, use it and don't create another one
translation_modeladmin = None
for inline in getattr(cls, 'inlines', []):
if inline.model == model._meta.translation_model:
translation_modeladmin = inline
if not translation_modeladmin:
translation_modeladmin = get_translation_modeladmin(cls, model)
if cls.inlines:
cls.inlines.insert(0, translation_modeladmin)
else:
cls.inlines = [translation_modeladmin]
return admin.ModelAdmin._original_new_before_dm(cls, model, admin_site, obj)
def install_multilingual_modeladmin_new():
"""
Override ModelAdmin.__new__ to create automatic inline
editor for multilingual models.
"""
admin.ModelAdmin._original_new_before_dm = admin.ModelAdmin.__new__
admin.ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
|
stefanfoulis/django-multilingual
|
5795426396dcf88bf1246096074e026bdf8d6fb3
|
Fixing #92: changed the MultilingualFlatPage model to allow empty content.
|
diff --git a/AUTHORS b/AUTHORS
index 73ad4fd..800bf09 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,24 +1,26 @@
django-multilingual was originally created in 2007 by Marcin Kaszynski.
Current or former committers:
Ashley Camba
Joost Cassee
Fabio Corneti
Marcin Kaszynski
Matthias Urlichs
Contributors:
Jure Cuhalev
[email protected]
Yann Malet
mkriheli
Manuel Saelices
Florian Sening
Jakub WiÅniowski
alberto.paro
m.meylan
gonzalosaavedra
JustinLilly
Jannis Leidel
+ panos.laganakos
+
diff --git a/multilingual/flatpages/models.py b/multilingual/flatpages/models.py
index 12a9a1b..970a1fb 100644
--- a/multilingual/flatpages/models.py
+++ b/multilingual/flatpages/models.py
@@ -1,48 +1,48 @@
from django.db import models
from django.contrib.sites.models import Site
import multilingual
from django.utils.translation import ugettext as _
class MultilingualFlatPage(models.Model):
# non-translatable fields first
url = models.CharField(_('URL'), max_length=100, db_index=True,
help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes."))
enable_comments = models.BooleanField(_('enable comments'))
template_name = models.CharField(_('template name'), max_length=70, blank=True,
help_text=_("Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'."))
registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page."))
sites = models.ManyToManyField(Site)
# And now the translatable fields
class Translation(multilingual.Translation):
"""
The definition of translation model.
The multilingual machinery will automatically add these to the
Category class:
* get_title(language_id=None)
* set_title(value, language_id=None)
* get_content(language_id=None)
* set_content(value, language_id=None)
* title and content properties using the methods above
"""
title = models.CharField(_('title'), max_length=200)
- content = models.TextField(_('content'))
+ content = models.TextField(_('content'), blank=True)
class Meta:
db_table = 'multilingual_flatpage'
verbose_name = _('multilingual flat page')
verbose_name_plural = _('multilingual flat pages')
ordering = ('url',)
def __unicode__(self):
# note that you can use name and description fields as usual
try:
return u"%s -- %s" % (self.url, self.title)
except multilingual.TranslationDoesNotExist:
return u"-not-available-"
def get_absolute_url(self):
return self.url
|
stefanfoulis/django-multilingual
|
137f2aad6ffde9dfd6c392cdbeafb3a1320a800c
|
Added a special case for counting, so that the most common COUNT, without any WHEREs, does not do the translation joins.
|
diff --git a/multilingual/query.py b/multilingual/query.py
index f911a2b..adb3d1c 100644
--- a/multilingual/query.py
+++ b/multilingual/query.py
@@ -1,540 +1,572 @@
"""
Django-multilingual: a QuerySet subclass for models with translatable
fields.
This file contains the implementation for QSRF Django.
"""
import datetime
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models.fields import FieldDoesNotExist
from django.db.models.query import QuerySet, Q
from django.db.models.sql.query import Query
from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin
from django.db.models.sql.constants import *
from django.db.models.sql.where import WhereNode, EverythingNode, AND, OR
try:
# handle internal API changes in Django rev. 9700
from django.db.models.sql.where import Constraint
def constraint_tuple(alias, col, field, lookup_type, value):
return (Constraint(alias, col, field), lookup_type, value)
except ImportError:
# backwards compatibility, for Django versions 1.0 to rev. 9699
def constraint_tuple(alias, col, field, lookup_type, value):
return (alias, col, field, lookup_type, value)
from multilingual.languages import (get_translation_table_alias, get_language_id_list,
get_default_language, get_translated_field_alias,
get_language_id_from_id_or_code)
__ALL__ = ['MultilingualModelQuerySet']
class MultilingualQuery(Query):
def __init__(self, model, connection, where=WhereNode):
self.extra_join = {}
+ self.include_translation_data = True
extra_select = {}
super(MultilingualQuery, self).__init__(model, connection, where=where)
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
for language_id in get_language_id_list():
for fname in [f.attname for f in translation_opts.fields]:
table_alias = get_translation_table_alias(trans_table_name,
language_id)
field_alias = get_translated_field_alias(fname,
language_id)
extra_select[field_alias] = qn2(table_alias) + '.' + qn2(fname)
self.add_extra(extra_select, None,None,None,None,None)
+ self._trans_extra_select_count = len(self.extra_select)
def clone(self, klass=None, **kwargs):
- obj = super(MultilingualQuery, self).clone(klass=klass, **kwargs)
- obj.extra_join = self.extra_join
- return obj
+ defaults = {
+ 'extra_join': self.extra_join,
+ 'include_translation_data': self.include_translation_data,
+ }
+ defaults.update(kwargs)
+ return super(MultilingualQuery, self).clone(klass=klass, **defaults)
def pre_sql_setup(self):
"""Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualQuery, self).pre_sql_setup()
+
+ if not self.include_translation_data:
+ return
+
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_id in get_language_id_list():
table_alias = get_translation_table_alias(trans_table_name,
language_id)
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(self.model._meta.pk.column),
qn2(table_alias),
language_id))
self.extra_join[table_alias] = trans_join
def get_from_clause(self):
"""Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualQuery, self).get_from_clause()
+
+ if not self.include_translation_data:
+ return result
+
from_ = result[0]
for join in self.extra_join.values():
from_.append(join)
return (from_, result[1])
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None, process_extras=True):
"""Copied from add_filter to generate WHERES for translation fields.
"""
arg, value = filter_expr
parts = arg.split(LOOKUP_SEP)
if not parts:
raise FieldError("Cannot parse keyword query %r" % arg)
# Work out the lookup type and remove it from 'parts', if necessary.
if len(parts) == 1 or parts[-1] not in self.query_terms:
lookup_type = 'exact'
else:
lookup_type = parts.pop()
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
# uses of None as a query value.
if value is None:
if lookup_type != 'exact':
raise ValueError("Cannot use None as a query value")
lookup_type = 'isnull'
value = True
elif (value == '' and lookup_type == 'exact' and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value = True
elif callable(value):
value = value()
opts = self.get_meta()
alias = self.get_initial_alias()
allow_many = trim or not negate
try:
field, target, opts, join_list, last, extra_filters = self.setup_joins(
parts, opts, alias, True, allow_many, can_reuse=can_reuse,
negate=negate, process_extras=process_extras)
except MultiJoin, e:
self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]),
can_reuse)
return
#NOTE: here comes Django Multilingual
if hasattr(opts, 'translation_model'):
field_name = parts[-1]
if field_name == 'pk':
field_name = opts.pk.name
translation_opts = opts.translation_model._meta
if field_name in translation_opts.translated_fields.keys():
field, model, direct, m2m = opts.get_field_by_name(field_name)
if model == opts.translation_model:
language_id = translation_opts.translated_fields[field_name][1]
if language_id is None:
language_id = get_default_language()
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
self.where.add(constraint_tuple(new_table, field.column, field, lookup_type, value), connector)
return
final = len(join_list)
penultimate = last.pop()
if penultimate == final:
penultimate = last.pop()
if trim and len(join_list) > 1:
extra = join_list[penultimate:]
join_list = join_list[:penultimate]
final = penultimate
penultimate = last.pop()
col = self.alias_map[extra[0]][LHS_JOIN_COL]
for alias in extra:
self.unref_alias(alias)
else:
col = target.column
alias = join_list[-1]
while final > 1:
# An optimization: if the final join is against the same column as
# we are comparing against, we can go back one step in the join
# chain and compare against the lhs of the join instead (and then
# repeat the optimization). The result, potentially, involves less
# table joins.
join = self.alias_map[alias]
if col != join[RHS_JOIN_COL]:
break
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
join_list = join_list[:-1]
final -= 1
if final == penultimate:
penultimate = last.pop()
if (lookup_type == 'isnull' and value is True and not negate and
final > 1):
# If the comparison is against NULL, we need to use a left outer
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed as it's less
# efficient at the database level.
self.promote_alias(join_list[penultimate])
if connector == OR:
# Some joins may need to be promoted when adding a new filter to a
# disjunction. We walk the list of new joins and where it diverges
# from any previous joins (ref count is 1 in the table list), we
# make the new additions (and any existing ones not used in the new
# join list) an outer join.
join_it = iter(join_list)
table_it = iter(self.tables)
join_it.next(), table_it.next()
table_promote = False
join_promote = False
for join in join_it:
table = table_it.next()
if join == table and self.alias_refcount[join] > 1:
continue
join_promote = self.promote_alias(join)
if table != join:
table_promote = self.promote_alias(table)
break
self.promote_alias_chain(join_it, join_promote)
self.promote_alias_chain(table_it, table_promote)
self.where.add(constraint_tuple(alias, col, field, lookup_type, value), connector)
if negate:
self.promote_alias_chain(join_list)
if lookup_type != 'isnull':
if final > 1:
for alias in join_list:
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
j_col = self.alias_map[alias][RHS_JOIN_COL]
entry = self.where_class()
entry.add(constraint_tuple(alias, j_col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
break
elif not (lookup_type == 'in' and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# it's short-circuited in the Where class.
entry = self.where_class()
entry.add(constraint_tuple(alias, col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
if can_reuse is not None:
can_reuse.update(join_list)
if process_extras:
for filter in extra_filters:
self.add_filter(filter, negate=negate, can_reuse=can_reuse,
process_extras=False)
def _setup_joins_with_translation(self, names, opts, alias,
dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None,
negate=False, process_extras=True):
"""
This is based on a full copy of Query.setup_joins because
currently I see no way to handle it differently.
TO DO: there might actually be a way, by splitting a single
multi-name setup_joins call into separate calls. Check it.
-- [email protected]
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are joining to), 'alias' is the alias for the
table we are joining to. If dupe_multis is True, any many-to-many or
many-to-one joins will always create a new alias (necessary for
disjunctive filters).
Returns the final field involved in the join, the target database
column (used for any 'where' constraint), the final 'opts' value and the
list of tables joined.
"""
joins = [alias]
last = [0]
dupe_set = set()
exclusions = set()
extra_filters = []
for pos, name in enumerate(names):
try:
exclusions.add(int_alias)
except NameError:
pass
exclusions.add(alias)
last.append(len(joins))
if name == 'pk':
name = opts.pk.name
try:
field, model, direct, m2m = opts.get_field_by_name(name)
except FieldDoesNotExist:
for f in opts.fields:
if allow_explicit_fk and name == f.attname:
# XXX: A hack to allow foo_id to work in values() for
# backwards compatibility purposes. If we dropped that
# feature, this could be removed.
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
names = opts.get_all_field_names()
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
if not allow_many and (m2m or not direct):
for alias in joins:
self.unref_alias(alias)
raise MultiJoin(pos + 1)
#NOTE: Start Django Multilingual specific code
if hasattr(opts, 'translation_model'):
translation_opts = opts.translation_model._meta
if model == opts.translation_model:
language_id = translation_opts.translated_fields[name][1]
if language_id is None:
language_id = get_default_language()
#TODO: check alias
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(model._meta.db_table),
qn2(new_table),
qn2(new_table),
qn(master_table_name),
qn2(model._meta.pk.column),
qn2(new_table),
language_id))
self.extra_join[new_table] = trans_join
target = field
continue
#NOTE: End Django Multilingual specific code
elif model:
# The field lives on a base class of the current model.
for int_model in opts.get_base_chain(model):
lhs_col = opts.parents[int_model].column
dedupe = lhs_col in opts.duplicate_targets
if dedupe:
exclusions.update(self.dupe_avoidance.get(
(id(opts), lhs_col), ()))
dupe_set.add((opts, lhs_col))
opts = int_model._meta
alias = self.join((alias, opts.db_table, lhs_col,
opts.pk.column), exclusions=exclusions)
joins.append(alias)
exclusions.add(alias)
for (dupe_opts, dupe_col) in dupe_set:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
cached_data = opts._join_cache.get(name)
orig_opts = opts
dupe_col = direct and field.column or field.field.column
dedupe = dupe_col in opts.duplicate_targets
if dupe_set or dedupe:
if dedupe:
dupe_set.add((opts, dupe_col))
exclusions.update(self.dupe_avoidance.get((id(opts), dupe_col),
()))
if process_extras and hasattr(field, 'extra_filters'):
extra_filters.extend(field.extra_filters(names, pos, negate))
if direct:
if m2m:
# Many-to-many field defined on the current model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_column_name()
opts = field.rel.to._meta
table2 = opts.db_table
from_col2 = field.m2m_reverse_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
if int_alias == table2 and from_col2 == to_col2:
joins.append(int_alias)
alias = int_alias
else:
alias = self.join(
(int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
elif field.rel:
# One-to-one or many-to-one field
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
opts = field.rel.to._meta
target = field.rel.get_related_field()
table = opts.db_table
from_col = field.column
to_col = target.column
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
exclusions=exclusions, nullable=field.null)
joins.append(alias)
else:
# Non-relation fields.
target = field
break
else:
orig_field = field
field = field.field
if m2m:
# Many-to-many field defined on the target model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_reverse_name()
opts = orig_field.opts
table2 = opts.db_table
from_col2 = field.m2m_column_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
alias = self.join((int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
else:
# One-to-many field (ForeignKey defined on the target model)
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
local_field = opts.get_field_by_name(
field.rel.field_name)[0]
opts = orig_field.opts
table = opts.db_table
from_col = local_field.column
to_col = field.column
target = opts.pk
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.append(alias)
for (dupe_opts, dupe_col) in dupe_set:
try:
self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias)
except NameError:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None, negate=False,
process_extras=True):
- return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
- allow_many, allow_explicit_fk,
- can_reuse, negate, process_extras)
+ if not self.include_translation_data:
+ return super(MultilingualQuery, self).setup_joins(names, opts, alias,
+ dupe_multis, allow_many,
+ allow_explicit_fk,
+ can_reuse, negate,
+ process_extras)
+ else:
+ return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
+ allow_many, allow_explicit_fk,
+ can_reuse, negate, process_extras)
+
+ def get_count(self):
+ # optimize for the common special case: count without any
+ # filters
+ if ((not (self.select or self.where or self.extra_where))
+ and self.include_translation_data):
+ obj = self.clone(extra_select = {},
+ extra_join = {},
+ include_translation_data = False)
+ return obj.get_count()
+ else:
+ return super(MultilingualQuery, self).get_count()
class MultilingualModelQuerySet(QuerySet):
"""
A specialized QuerySet that knows how to handle translatable
fields in ordering and filtering methods.
"""
def __init__(self, model=None, query=None):
query = query or MultilingualQuery(model, connection)
super(MultilingualModelQuerySet, self).__init__(model, query)
def for_language(self, language_id_or_code):
"""
Set the default language for all objects returned with this
query.
"""
clone = self._clone()
clone._default_language = get_language_id_from_id_or_code(language_id_or_code)
return clone
def iterator(self):
"""
Add the default language information to all returned objects.
"""
default_language = getattr(self, '_default_language', None)
for obj in super(MultilingualModelQuerySet, self).iterator():
obj._default_language = default_language
yield obj
def _clone(self, klass=None, **kwargs):
"""
Override _clone to preserve additional information needed by
MultilingualModelQuerySet.
"""
clone = super(MultilingualModelQuerySet, self)._clone(klass, **kwargs)
clone._default_language = getattr(self, '_default_language', None)
return clone
def order_by(self, *field_names):
if hasattr(self.model._meta, 'translation_model'):
trans_opts = self.model._meta.translation_model._meta
new_field_names = []
for field_name in field_names:
prefix = ''
if field_name[0] == '-':
prefix = '-'
field_name = field_name[1:]
field_and_lang = trans_opts.translated_fields.get(field_name)
if field_and_lang:
field, language_id = field_and_lang
if language_id is None:
language_id = getattr(self, '_default_language', None)
real_name = get_translated_field_alias(field.attname,
language_id)
new_field_names.append(prefix + real_name)
else:
new_field_names.append(prefix + field_name)
return super(MultilingualModelQuerySet, self).extra(order_by=new_field_names)
else:
return super(MultilingualModelQuerySet, self).order_by(*field_names)
|
stefanfoulis/django-multilingual
|
63bf4a04db38aa7dd3731ee016103cc41c0d20dc
|
Changed the testproject settings to install the debug toolbar if available.
|
diff --git a/testproject/settings.py b/testproject/settings.py
index f38dba7..8fbbacb 100644
--- a/testproject/settings.py
+++ b/testproject/settings.py
@@ -1,112 +1,130 @@
# Django settings for testproject project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'database.db3' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en'
# django-multilanguange #####################
# It is important that the language identifiers are consecutive
# numbers starting with 1.
LANGUAGES = [['en', 'English'], # id=1
['pl', 'Polish'], # id=2
['zh-cn', 'Simplified Chinese'], # id=3
]
DEFAULT_LANGUAGE = 1
##############################################
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '1+t11&r9nw+d7uw558+8=#j8!8^$nt97ecgv()-@x!tcef7f6)'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'multilingual.flatpages.middleware.FlatpageFallbackMiddleware',
)
ROOT_URLCONF = 'testproject.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'../multilingual/templates/',
'templates/',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'multilingual',
'multilingual.flatpages',
'testproject.articles',
'testproject.inline_registrations',
'testproject.issue_15',
'testproject.issue_16',
'testproject.issue_23',
'testproject.issue_29',
'testproject.issue_37',
'testproject.issue_61',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'multilingual.context_processors.multilingual',
)
+
+try:
+ # install the debug toolbar if available
+ import debug_toolbar
+
+ MIDDLEWARE_CLASSES = (
+ 'debug_toolbar.middleware.DebugToolbarMiddleware',
+ ) + MIDDLEWARE_CLASSES
+ INSTALLED_APPS += ('debug_toolbar',)
+
+ INTERNAL_IPS = ('127.0.0.1',)
+
+ DEBUG_TOOLBAR_CONFIG = {
+ 'INTERCEPT_REDIRECTS': False
+ }
+
+except ImportError:
+ pass
|
stefanfoulis/django-multilingual
|
fb15beab9828656f08cd3fc11eacf03cbd2a5b62
|
Changed the multilingual admin UI so that it allows partial translations.
|
diff --git a/multilingual/admin.py b/multilingual/admin.py
index 3d11e0e..1203dfa 100644
--- a/multilingual/admin.py
+++ b/multilingual/admin.py
@@ -1,136 +1,204 @@
from django.contrib import admin
+from django.forms.models import BaseInlineFormSet
+from django.forms.fields import BooleanField
+from django.forms.formsets import DELETION_FIELD_NAME
+from django.forms.util import ErrorDict
+from django.utils.translation import ugettext as _
+
from multilingual.languages import *
from multilingual.utils import is_multilingual_model
+def _translation_form_full_clean(self, previous_full_clean):
+ """
+ There is a bug in Django that causes inline forms to be
+ validated even if they are marked for deletion.
+
+ This function fixes that by disabling validation
+ completely if the delete field is marked and only copying
+ the absolutely required fields: PK and FK to parent.
+
+ TODO: create a fix for Django, have it accepted into trunk and get
+ rid of this monkey patch.
+
+ """
+
+ def cleaned_value(name):
+ field = self.fields[name]
+ val = field.widget.value_from_datadict(self.data, self.files,
+ self.add_prefix(name))
+ return field.clean(val)
+
+ delete = cleaned_value(DELETION_FIELD_NAME)
+
+ if delete:
+ # this object is to be skipped or deleted, so only
+ # construct the minimal cleaned_data
+ self.cleaned_data = {'DELETE': delete,
+ 'id': cleaned_value('id'),
+ 'master': cleaned_value('master')}
+ self._errors = ErrorDict()
+ else:
+ return previous_full_clean()
+
+class TranslationInlineFormSet(BaseInlineFormSet):
+
+ def _construct_forms(self):
+ ## set the right default values for language_ids of empty (new) forms
+ super(TranslationInlineFormSet, self)._construct_forms()
+
+ empty_forms = []
+ lang_id_list = get_language_id_list()
+ lang_to_form = dict(zip(lang_id_list, [None] * len(lang_id_list)))
+
+ for form in self.forms:
+ language_id = form.initial.get('language_id')
+ if language_id:
+ lang_to_form[language_id] = form
+ else:
+ empty_forms.append(form)
+
+ for language_id in lang_id_list:
+ form = lang_to_form[language_id]
+ if form is None:
+ form = empty_forms.pop(0)
+ form.initial['language_id'] = language_id
+
+ def add_fields(self, form, index):
+ super(TranslationInlineFormSet, self).add_fields(form, index)
+
+ previous_full_clean = form.full_clean
+ form.full_clean = lambda: _translation_form_full_clean(form, previous_full_clean)
+
class TranslationModelAdmin(admin.StackedInline):
template = "admin/edit_inline_translations_newforms.html"
fk_name = 'master'
extra = get_language_count()
max_num = get_language_count()
+ formset = TranslationInlineFormSet
class ModelAdminClass(admin.ModelAdmin.__metaclass__):
"""
A metaclass for ModelAdmin below.
"""
def __new__(cls, name, bases, attrs):
# Move prepopulated_fields somewhere where Django won't see
# them. We have to handle them ourselves.
prepopulated_fields = attrs.get('prepopulated_fields', {})
attrs['prepopulated_fields'] = {}
attrs['_dm_prepopulated_fields'] = prepopulated_fields
return super(ModelAdminClass, cls).__new__(cls, name, bases, attrs)
class ModelAdmin(admin.ModelAdmin):
"""
All model admins for multilingual models must inherit this class
instead of django.contrib.admin.ModelAdmin.
"""
__metaclass__ = ModelAdminClass
def _media(self):
media = super(ModelAdmin, self)._media()
if getattr(self.__class__, '_dm_prepopulated_fields', None):
from django.conf import settings
media.add_js(['%sjs/urlify.js' % (settings.ADMIN_MEDIA_PREFIX,)])
return media
media = property(_media)
def render_change_form(self, request, context, add=False, change=False,
form_url='', obj=None):
# I'm overriding render_change_form to inject information
# about prepopulated_fields
trans_model = self.model._meta.translation_model
trans_fields = trans_model._meta.translated_fields
adminform = context['adminform']
form = adminform.form
def field_name_to_fake_field(field_name):
"""
Return something that looks like a form field enough to
fool prepopulated_fields_js.html
For field_names of real fields in self.model this actually
returns a real form field.
"""
try:
field, language_id = trans_fields[field_name]
if language_id is None:
language_id = get_default_language()
# TODO: we have this mapping between language_id and
# field id in two places -- here and in
# edit_inline_translations_newforms.html
# It is not DRY.
field_idx = language_id - 1
ret = {'auto_id': 'id_translations-%d-%s' % (field_idx, field.name)
}
except:
ret = form[field_name]
return ret
adminform.prepopulated_fields = [{
'field': field_name_to_fake_field(field_name),
'dependencies': [field_name_to_fake_field(f) for f in dependencies]
} for field_name, dependencies in self._dm_prepopulated_fields.items()]
return super(ModelAdmin, self).render_change_form(request, context,
add, change, form_url, obj)
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
return tr_cls
# TODO: multilingual_modeladmin_new should go away soon. The code will
# be split between the ModelAdmin class, its metaclass and validation
# code.
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
if is_multilingual_model(model):
if cls is admin.ModelAdmin:
# the model is being registered with the default
# django.contrib.admin.options.ModelAdmin. Replace it
# with our ModelAdmin, since it is safe to assume it is a
# simple call to admin.site.register without just model
# passed
# subclass it, because we need to set the inlines class
# attribute below
cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
# make sure it subclasses multilingual.ModelAdmin
if not issubclass(cls, ModelAdmin):
from warnings import warn
warn("%s should be registered with a subclass of "
" of multilingual.ModelAdmin." % model, DeprecationWarning)
# if the inlines already contain a class for the
# translation model, use it and don't create another one
translation_modeladmin = None
for inline in getattr(cls, 'inlines', []):
if inline.model == model._meta.translation_model:
translation_modeladmin = inline
if not translation_modeladmin:
translation_modeladmin = get_translation_modeladmin(cls, model)
if cls.inlines:
cls.inlines.insert(0, translation_modeladmin)
else:
cls.inlines = [translation_modeladmin]
return admin.ModelAdmin._original_new_before_dm(cls, model, admin_site, obj)
def install_multilingual_modeladmin_new():
"""
Override ModelAdmin.__new__ to create automatic inline
editor for multilingual models.
"""
admin.ModelAdmin._original_new_before_dm = admin.ModelAdmin.__new__
admin.ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
diff --git a/multilingual/templates/admin/edit_inline_translations_newforms.html b/multilingual/templates/admin/edit_inline_translations_newforms.html
index c6c6677..cd57dc2 100644
--- a/multilingual/templates/admin/edit_inline_translations_newforms.html
+++ b/multilingual/templates/admin/edit_inline_translations_newforms.html
@@ -1,21 +1,22 @@
{% load i18n %}
{% load multilingual_tags %}
<div class="inline-group">
{{ inline_admin_formset.formset.management_form }}
-{% for inline_admin_form in inline_admin_formset %}
+{% for inline_admin_form in inline_admin_formset|reorder_translation_formset_by_language_id %}
<div class="inline-related {% if forloop.last %}last-related{% endif %}">
- <h2>Language: {{ forloop.counter|language_name }}
- {% if inline_admin_formset.formset.deletable %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
- </h2>
+ <h3>Language: {{ forloop.counter|language_name }}
+ {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
+ </h3>
{% if inline_admin_form.show_url %}
<p><a href="/r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a></p>
{% endif %}
{% for fieldset in inline_admin_form %}
{% include "admin/fieldset.html" %}
{% endfor %}
{{ inline_admin_form.pk_field.field }}
+ {{ inline_admin_form.fk_field.field }}
</div>
{% endfor %}
</div>
diff --git a/multilingual/templates/admin/fieldset.html b/multilingual/templates/admin/fieldset.html
index ab2e9c5..10c7746 100644
--- a/multilingual/templates/admin/fieldset.html
+++ b/multilingual/templates/admin/fieldset.html
@@ -1,30 +1,30 @@
{% load multilingual_tags %}
<fieldset class="module aligned {{ fieldset.classes }}">
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
{% if fieldset.description %}<div class="description">{{ fieldset.description }}</div>{% endif %}
{% for line in fieldset %}
<div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ field.field.name }} {% endfor %} ">
{{ field.name }}
{{ line.errors }}
{% for field in line %}
{{ field.field. }}
{% if field.is_checkbox %}
{{ field.field }}{{ field.label_tag }}
{% else %}
- {% ifequal field.field.name "language_id" %}
+ {% ifequal field.field.name "language_id" %}
<input type="hidden" name="{{ field.field.html_name }}"
- value="{{ forloop.parentloop.parentloop.parentloop.counter }}" />
- {% else %}
+ value="{{ forloop.parentloop.parentloop.parentloop.counter }}" />
+ {% else %}
{{ field.label_tag }}
{% if forloop.parentloop.parentloop.parentloop.counter|language_bidi %}
<span style="direction: rtl; text-align: right;">{{ field.field }}</span>
{% else %}
<span style="direction: ltr; text-align: left;">{{ field.field }}</span>
{% endif %}
{% endifequal %}
{% endif %}
{% if field.field.field.help_text %}<p class="help">{{ field.field.field.help_text|safe }}</p>{% endif %}
{% endfor %}
</div>
{% endfor %}
</fieldset>
diff --git a/multilingual/templatetags/multilingual_tags.py b/multilingual/templatetags/multilingual_tags.py
index dd9f758..9b5c0f5 100644
--- a/multilingual/templatetags/multilingual_tags.py
+++ b/multilingual/templatetags/multilingual_tags.py
@@ -1,71 +1,84 @@
from django import template
from django import forms
from django.template import Node, NodeList, Template, Context, resolve_variable
from django.template.loader import get_template, render_to_string
from django.conf import settings
from django.utils.html import escape
-from multilingual.languages import get_language_idx, get_default_language
+from multilingual.languages import (get_language_idx, get_default_language,
+ get_language_id_list)
import math
import StringIO
import tokenize
register = template.Library()
from multilingual.languages import get_language_code, get_language_name, get_language_bidi
def language_code(language_id):
"""
Return the code of the language with id=language_id
"""
return get_language_code(language_id)
register.filter(language_code)
def language_name(language_id):
"""
Return the name of the language with id=language_id
"""
return get_language_name(language_id)
register.filter(language_name)
def language_bidi(language_id):
"""
Return whether the language with id=language_id is written right-to-left.
"""
return get_language_bidi(language_id)
register.filter(language_bidi)
class EditTranslationNode(template.Node):
def __init__(self, form_name, field_name, language=None):
self.form_name = form_name
self.field_name = field_name
self.language = language
def render(self, context):
form = resolve_variable(self.form_name, context)
model = form._meta.model
trans_model = model._meta.translation_model
if self.language:
language_id = self.language.resolve(context)
else:
language_id = get_default_language()
real_name = "%s.%s.%s.%s" % (self.form_name,
trans_model._meta.object_name.lower(),
get_language_idx(language_id),
self.field_name)
return str(resolve_variable(real_name, context))
def do_edit_translation(parser, token):
bits = token.split_contents()
if len(bits) not in [3, 4]:
raise template.TemplateSyntaxError, \
"%r tag requires 3 or 4 arguments" % bits[0]
if len(bits) == 4:
language = parser.compile_filter(bits[3])
else:
language = None
return EditTranslationNode(bits[1], bits[2], language)
register.tag('edit_translation', do_edit_translation)
+
+def reorder_translation_formset_by_language_id(inline_admin_form):
+ """
+ Shuffle the forms in the formset of multilingual model in the
+ order of their language_ids.
+ """
+ lang_to_form = dict([(form.form.initial['language_id'], form)
+ for form in inline_admin_form])
+ return [lang_to_form[language_id] for language_id in get_language_id_list()]
+
+register.filter(reorder_translation_formset_by_language_id)
+
diff --git a/testproject/articles/models.py b/testproject/articles/models.py
index 48edda3..2992a03 100644
--- a/testproject/articles/models.py
+++ b/testproject/articles/models.py
@@ -1,301 +1,339 @@
"""
Test models for the multilingual library.
# Note: the to_str() calls in all the tests are here only to make it
# easier to test both pre-unicode and current Django.
>>> from testproject.utils import to_str
# make sure the settings are right
>>> from multilingual.languages import LANGUAGES
>>> LANGUAGES
[['en', 'English'], ['pl', 'Polish'], ['zh-cn', 'Simplified Chinese']]
>>> from multilingual import set_default_language
>>> from django.db.models import Q
>>> set_default_language(1)
### Check the table names
>>> Category._meta.translation_model._meta.db_table
'category_language'
>>> Article._meta.translation_model._meta.db_table
'articles_article_translation'
### Create the test data
# Check both assigning via the proxy properties and set_* functions
>>> c = Category()
>>> c.name_en = 'category 1'
>>> c.name_pl = 'kategoria 1'
>>> c.save()
>>> c = Category()
>>> c.set_name('category 2', 'en')
>>> c.set_name('kategoria 2', 'pl')
>>> c.save()
### See if the test data was saved correctly
### Note: first object comes from the initial fixture.
>>> c = Category.objects.all().order_by('id')[1]
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('category 1', 'category 1', 'kategoria 1')
>>> c = Category.objects.all().order_by('id')[2]
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('category 2', 'category 2', 'kategoria 2')
### Check translation changes.
### Make sure the name and description properties obey
### set_default_language.
>>> c = Category.objects.all().order_by('id')[1]
# set language: pl
>>> set_default_language(2)
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('kategoria 1', 'category 1', 'kategoria 1')
>>> c.name = 'kat 1'
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('kat 1', 'category 1', 'kat 1')
# set language: en
>>> set_default_language('en')
>>> c.name = 'cat 1'
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('cat 1', 'cat 1', 'kat 1')
>>> c.save()
# Read the entire Category objects from the DB again to see if
# everything was saved correctly.
>>> c = Category.objects.all().order_by('id')[1]
>>> to_str((c.name, c.get_name('en'), c.get_name('pl')))
('cat 1', 'cat 1', 'kat 1')
>>> c = Category.objects.all().order_by('id')[2]
>>> to_str((c.name, c.get_name('en'), c.get_name('pl')))
('category 2', 'category 2', 'kategoria 2')
### Check ordering
>>> set_default_language(1)
>>> to_str([c.name for c in Category.objects.all().order_by('name_en')])
['Fixture category', 'cat 1', 'category 2']
### Check ordering
# start with renaming one of the categories so that the order actually
# depends on the default language
>>> set_default_language(1)
>>> c = Category.objects.get(name='cat 1')
>>> c.name = 'zzz cat 1'
>>> c.save()
>>> to_str([c.name for c in Category.objects.all().order_by('name_en')])
['Fixture category', 'category 2', 'zzz cat 1']
>>> to_str([c.name for c in Category.objects.all().order_by('name')])
['Fixture category', 'category 2', 'zzz cat 1']
>>> to_str([c.name for c in Category.objects.all().order_by('-name')])
['zzz cat 1', 'category 2', 'Fixture category']
>>> set_default_language(2)
>>> to_str([c.name for c in Category.objects.all().order_by('name')])
['Fixture kategoria', 'kat 1', 'kategoria 2']
>>> to_str([c.name for c in Category.objects.all().order_by('-name')])
['kategoria 2', 'kat 1', 'Fixture kategoria']
### Check filtering
# Check for filtering defined by Q objects as well. This is a recent
# improvement: the translation fields are being handled by an
# extension of lookup_inner instead of overridden
# QuerySet._filter_or_exclude
>>> set_default_language('en')
>>> to_str([c.name for c in Category.objects.all().filter(name__contains='2')])
['category 2']
>>> set_default_language('en')
>>> to_str([c.name for c in Category.objects.all().filter(Q(name__contains='2'))])
['category 2']
>>> set_default_language(1)
>>> to_str([c.name for c in
... Category.objects.all().filter(Q(name__contains='2')|Q(name_pl__contains='kat'))])
['Fixture category', 'zzz cat 1', 'category 2']
>>> set_default_language(1)
>>> to_str([c.name for c in Category.objects.all().filter(name_en__contains='2')])
['category 2']
>>> set_default_language(1)
>>> to_str([c.name for c in Category.objects.all().filter(Q(name_pl__contains='kat'))])
['Fixture category', 'zzz cat 1', 'category 2']
>>> set_default_language('pl')
>>> to_str([c.name for c in Category.objects.all().filter(name__contains='k')])
['Fixture kategoria', 'kat 1', 'kategoria 2']
>>> set_default_language('pl')
>>> to_str([c.name for c in Category.objects.all().filter(Q(name__contains='kategoria'))])
['Fixture kategoria', 'kategoria 2']
### Check specifying query set language
>>> c_en = Category.objects.all().for_language('en')
>>> c_pl = Category.objects.all().for_language(2) # both ID and code work here
>>> to_str(c_en.get(name__contains='1').name)
'zzz cat 1'
>>> to_str(c_pl.get(name__contains='1').name)
'kat 1'
>>> to_str([c.name for c in c_en.order_by('name')])
['Fixture category', 'category 2', 'zzz cat 1']
>>> to_str([c.name for c in c_pl.order_by('-name')])
['kategoria 2', 'kat 1', 'Fixture kategoria']
>>> c = c_en.get(id=2)
>>> c.name = 'test'
>>> to_str((c.name, c.name_en, c.name_pl))
('test', 'test', 'kat 1')
>>> c = c_pl.get(id=2)
>>> c.name = 'test'
>>> to_str((c.name, c.name_en, c.name_pl))
('test', 'zzz cat 1', 'test')
### Check filtering spanning more than one model
>>> set_default_language(1)
>>> cat_1 = Category.objects.get(name='zzz cat 1')
>>> cat_2 = Category.objects.get(name='category 2')
>>> a = Article(category=cat_1)
>>> a.set_title('article 1', 1)
>>> a.set_title('artykul 1', 2)
>>> a.set_contents('contents 1', 1)
>>> a.set_contents('zawartosc 1', 1)
>>> a.save()
>>> a = Article(category=cat_2)
>>> a.set_title('article 2', 1)
>>> a.set_title('artykul 2', 2)
>>> a.set_contents('contents 2', 1)
>>> a.set_contents('zawartosc 2', 1)
>>> a.save()
>>> to_str([a.title for a in Article.objects.filter(category=cat_1)])
['article 1']
>>> to_str([a.title for a in Article.objects.filter(category__name=cat_1.name)])
['article 1']
>>> to_str([a.title for a in Article.objects.filter(Q(category__name=cat_1.name)|Q(category__name_pl__contains='2')).order_by('-title')])
['article 2', 'article 1']
### Test the creation of new objects using keywords passed to the
### constructor
>>> set_default_language(2)
>>> c_n = Category.objects.create(name_en='new category', name_pl='nowa kategoria')
>>> to_str((c_n.name, c_n.name_en, c_n.name_pl))
('nowa kategoria', 'new category', 'nowa kategoria')
>>> c_n.save()
>>> c_n2 = Category.objects.get(name_en='new category')
>>> to_str((c_n2.name, c_n2.name_en, c_n2.name_pl))
('nowa kategoria', 'new category', 'nowa kategoria')
>>> set_default_language(2)
>>> c_n3 = Category.objects.create(name='nowa kategoria 2')
>>> to_str((c_n3.name, c_n3.name_en, c_n3.name_pl))
('nowa kategoria 2', None, 'nowa kategoria 2')
+
+########################################
+###### Check if the admin behaviour for categories with incomplete translations
+
+>>> from django.contrib.auth.models import User
+>>> User.objects.create_superuser('test', 'test_email', 'test_password')
+
+>>> from django.test.client import Client
+>>> c = Client()
+>>> c.login(username='test', password='test_password')
+True
+
+# create a category with only 2 translations, skipping the
+# first language
+>>> resp = c.post('/admin/articles/category/add/',
+... {'creator': 1,
+... 'translations-TOTAL_FORMS': '3',
+... 'translations-INITIAL_FORMS': '0',
+... 'translations-0-language_id': '1',
+... 'translations-1-language_id': '2',
+... 'translations-2-language_id': '3',
+... 'translations-1-name': 'pl name',
+... 'translations-2-name': 'zh-cn name',
+... })
+
+>>> resp.status_code
+302
+
+>>> cat = Category.objects.order_by('-id')[0]
+>>> cat.name_en
+
+>>> cat.name_pl
+u'pl name'
+>>> cat.name_zh_cn
+u'zh-cn name'
+
+>>> cat.translations.count()
+2
"""
from django.db import models
from django.contrib.auth.models import User
import multilingual
try:
from django.utils.translation import ugettext as _
except:
# if this fails then _ is a builtin
pass
class Category(models.Model):
"""
Test model for multilingual content: a simplified Category.
"""
# First, some fields that do not need translations
creator = models.ForeignKey(User, verbose_name=_("Created by"),
blank=True, null=True)
created = models.DateTimeField(verbose_name=_("Created at"),
auto_now_add=True)
parent = models.ForeignKey('self', verbose_name=_("Parent category"),
blank=True, null=True)
# And now the translatable fields
class Translation(multilingual.Translation):
"""
The definition of translation model.
The multilingual machinery will automatically add these to the
Category class:
* get_name(language_id=None)
* set_name(value, language_id=None)
* get_description(language_id=None)
* set_description(value, language_id=None)
* name and description properties using the methods above
"""
name = models.CharField(verbose_name=_("The name"),
max_length=250)
description = models.TextField(verbose_name=_("The description"),
blank=True, null=False)
class Meta:
db_table = 'category_language'
def get_absolute_url(self):
return "/" + str(self.id) + "/"
def __unicode__(self):
# note that you can use name and description fields as usual
try:
return str(self.name)
except multilingual.TranslationDoesNotExist:
return "-not-available-"
def __str__(self):
# compatibility
return str(self.__unicode__())
class Meta:
verbose_name_plural = 'categories'
ordering = ('id',)
class CustomArticleManager(multilingual.Manager):
pass
class Article(models.Model):
"""
Test model for multilingual content: a simplified article
belonging to a single category.
"""
# non-translatable fields first
creator = models.ForeignKey(User, verbose_name=_("Created by"),
- blank=True, null=True)
+ blank=False, null=True)
created = models.DateTimeField(verbose_name=_("Created at"),
auto_now_add=True)
category = models.ForeignKey(Category, verbose_name=_("Parent category"),
blank=True, null=True)
objects = CustomArticleManager()
# And now the translatable fields
class Translation(multilingual.Translation):
title = models.CharField(verbose_name=_("The title"),
blank=True, null=False, max_length=250)
contents = models.TextField(verbose_name=_("The contents"),
blank=True, null=False)
|
stefanfoulis/django-multilingual
|
cf6e40133bde8999edc487edf838ddbc1f595293
|
Added the templates and fixtures to setup.py. Thanks, Jannis Leidel!
|
diff --git a/AUTHORS b/AUTHORS
index c7483ed..73ad4fd 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,23 +1,24 @@
django-multilingual was originally created in 2007 by Marcin Kaszynski.
Current or former committers:
Ashley Camba
Joost Cassee
Fabio Corneti
Marcin Kaszynski
Matthias Urlichs
Contributors:
Jure Cuhalev
[email protected]
Yann Malet
mkriheli
Manuel Saelices
Florian Sening
Jakub WiÅniowski
alberto.paro
m.meylan
gonzalosaavedra
JustinLilly
+ Jannis Leidel
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..ad7f8a7
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+include MANIFEST.in
+recursive-include multilingual/templates *
+recursive-include multilingual/flatpages/templates *
+recursive-include testproject/templates *
+recursive-include testproject/articles/fixtures/initial_data.xml
diff --git a/setup.py b/setup.py
index 952dc94..394ba84 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,14 @@
-from setuptools import setup
+from setuptools import setup, find_packages
setup(
name = 'django-multilingual',
+ version = '0.1.0',
description = 'Multilingual extension for Django',
author = 'Marcin Kaszynski',
url = 'http://code.google.com/p/django-multilingual/',
- packages = ['multilingual'],
+ packages = find_packages(exclude=["testproject", "testproject.*"]),
+ zip_safe=False,
+ package_data = {
+ '': ['templates/*/*.html'],
+ },
)
|
stefanfoulis/django-multilingual
|
739a7ae47a0a4352703ea1ca7282155f9188200e
|
Added a simple setup.py script, as suggested in issue #91. Thanks, JustinLilly!
|
diff --git a/AUTHORS b/AUTHORS
index 3afab00..c7483ed 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,22 +1,23 @@
django-multilingual was originally created in 2007 by Marcin Kaszynski.
Current or former committers:
Ashley Camba
Joost Cassee
Fabio Corneti
Marcin Kaszynski
Matthias Urlichs
Contributors:
Jure Cuhalev
[email protected]
Yann Malet
mkriheli
Manuel Saelices
Florian Sening
Jakub WiÅniowski
alberto.paro
m.meylan
gonzalosaavedra
+ JustinLilly
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..952dc94
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,9 @@
+from setuptools import setup
+
+setup(
+ name = 'django-multilingual',
+ description = 'Multilingual extension for Django',
+ author = 'Marcin Kaszynski',
+ url = 'http://code.google.com/p/django-multilingual/',
+ packages = ['multilingual'],
+)
|
stefanfoulis/django-multilingual
|
7873d5f00060362cb5f80678fe55c2c22bfb2d9a
|
Added the contributors of recently-used patches to the AUTHORS file. Thanks!
|
diff --git a/AUTHORS b/AUTHORS
index 9ffa253..3afab00 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,19 +1,22 @@
django-multilingual was originally created in 2007 by Marcin Kaszynski.
Current or former committers:
Ashley Camba
Joost Cassee
Fabio Corneti
Marcin Kaszynski
Matthias Urlichs
Contributors:
Jure Cuhalev
[email protected]
Yann Malet
mkriheli
Manuel Saelices
Florian Sening
Jakub WiÅniowski
+ alberto.paro
+ m.meylan
+ gonzalosaavedra
|
stefanfoulis/django-multilingual
|
19394512a74d69d383460369d2094a8bad2793f7
|
Made the internal Translation class available as (ModelName).Translation.
|
diff --git a/multilingual/translation.py b/multilingual/translation.py
index ced81eb..374d335 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,367 +1,368 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from multilingual.admin import install_multilingual_modeladmin_new
# TODO: remove this import. It is here only because earlier versions
# of the library required importing TranslationModelAdmin from here
# instead of taking it directly from multilingual
from multilingual.admin import TranslationModelAdmin
from new import instancemethod
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def translation_overwrite_previous(instance, **kwargs):
"""
Delete previously existing translation with the same master and
language_id values. To be called by translation model's pre_save
signal.
This most probably means I am abusing something here trying to use
Django inline editor. Oh well, it will have to go anyway when we
move to newforms.
"""
qs = instance.__class__.objects
try:
qs = qs.filter(master=instance.master).filter(language_id=instance.language_id)
qs.delete()
except ObjectDoesNotExist:
# We are probably loading a fixture that defines translation entities
# before their master entity.
pass
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None):
try:
return getattr(self.get_translation(language_id_or_code), field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False):
"""
Get a translation instance for the given language_id_or_code.
If it does not exist, either create one or raise the
TranslationDoesNotExist exception, depending on the
create_if_necessary argument.
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id not in self._translation_cache:
if not create_if_necessary:
raise TranslationDoesNotExist(language_id)
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return self._translation_cache.get(language_id, None)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
+ main_cls.Translation = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
# connect the pre_save signal on translation class to a
# function removing previous translation entries.
signals.pre_save.connect(translation_overwrite_previous,
sender=trans_model, weak=False)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
# Install a hack to let add_multilingual_manipulators know
# this is a translatable model (TODO: manipulators gone)
attrs['is_translation_model'] = lambda self: True
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
install_multilingual_modeladmin_new()
# install the library
install_translation_library()
|
stefanfoulis/django-multilingual
|
b0c919e2aeba52ae6655096b43fc5fc592ed863a
|
Bugfix #84, #85, #87: Django rev. 9700 changed the interface of one of the functions DM used for queries. Thanks amit.ramon, m.meylan and gonzalosaavedra!
|
diff --git a/multilingual/query.py b/multilingual/query.py
index bb0bbd0..f911a2b 100644
--- a/multilingual/query.py
+++ b/multilingual/query.py
@@ -1,528 +1,540 @@
"""
Django-multilingual: a QuerySet subclass for models with translatable
fields.
This file contains the implementation for QSRF Django.
"""
import datetime
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models.fields import FieldDoesNotExist
from django.db.models.query import QuerySet, Q
from django.db.models.sql.query import Query
from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin
from django.db.models.sql.constants import *
from django.db.models.sql.where import WhereNode, EverythingNode, AND, OR
+try:
+ # handle internal API changes in Django rev. 9700
+ from django.db.models.sql.where import Constraint
+
+ def constraint_tuple(alias, col, field, lookup_type, value):
+ return (Constraint(alias, col, field), lookup_type, value)
+
+except ImportError:
+ # backwards compatibility, for Django versions 1.0 to rev. 9699
+ def constraint_tuple(alias, col, field, lookup_type, value):
+ return (alias, col, field, lookup_type, value)
+
from multilingual.languages import (get_translation_table_alias, get_language_id_list,
get_default_language, get_translated_field_alias,
get_language_id_from_id_or_code)
__ALL__ = ['MultilingualModelQuerySet']
class MultilingualQuery(Query):
def __init__(self, model, connection, where=WhereNode):
self.extra_join = {}
extra_select = {}
super(MultilingualQuery, self).__init__(model, connection, where=where)
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
for language_id in get_language_id_list():
for fname in [f.attname for f in translation_opts.fields]:
table_alias = get_translation_table_alias(trans_table_name,
language_id)
field_alias = get_translated_field_alias(fname,
language_id)
extra_select[field_alias] = qn2(table_alias) + '.' + qn2(fname)
self.add_extra(extra_select, None,None,None,None,None)
def clone(self, klass=None, **kwargs):
obj = super(MultilingualQuery, self).clone(klass=klass, **kwargs)
obj.extra_join = self.extra_join
return obj
def pre_sql_setup(self):
"""Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualQuery, self).pre_sql_setup()
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_id in get_language_id_list():
table_alias = get_translation_table_alias(trans_table_name,
language_id)
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(self.model._meta.pk.column),
qn2(table_alias),
language_id))
self.extra_join[table_alias] = trans_join
def get_from_clause(self):
"""Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualQuery, self).get_from_clause()
from_ = result[0]
for join in self.extra_join.values():
from_.append(join)
return (from_, result[1])
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None, process_extras=True):
"""Copied from add_filter to generate WHERES for translation fields.
"""
arg, value = filter_expr
parts = arg.split(LOOKUP_SEP)
if not parts:
raise FieldError("Cannot parse keyword query %r" % arg)
# Work out the lookup type and remove it from 'parts', if necessary.
if len(parts) == 1 or parts[-1] not in self.query_terms:
lookup_type = 'exact'
else:
lookup_type = parts.pop()
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
# uses of None as a query value.
if value is None:
if lookup_type != 'exact':
raise ValueError("Cannot use None as a query value")
lookup_type = 'isnull'
value = True
elif (value == '' and lookup_type == 'exact' and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value = True
elif callable(value):
value = value()
opts = self.get_meta()
alias = self.get_initial_alias()
allow_many = trim or not negate
try:
field, target, opts, join_list, last, extra_filters = self.setup_joins(
parts, opts, alias, True, allow_many, can_reuse=can_reuse,
negate=negate, process_extras=process_extras)
except MultiJoin, e:
self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]),
can_reuse)
return
#NOTE: here comes Django Multilingual
if hasattr(opts, 'translation_model'):
field_name = parts[-1]
if field_name == 'pk':
field_name = opts.pk.name
translation_opts = opts.translation_model._meta
if field_name in translation_opts.translated_fields.keys():
field, model, direct, m2m = opts.get_field_by_name(field_name)
if model == opts.translation_model:
language_id = translation_opts.translated_fields[field_name][1]
if language_id is None:
language_id = get_default_language()
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
- self.where.add((new_table, field.column, field, lookup_type, value), connector)
+ self.where.add(constraint_tuple(new_table, field.column, field, lookup_type, value), connector)
return
final = len(join_list)
penultimate = last.pop()
if penultimate == final:
penultimate = last.pop()
if trim and len(join_list) > 1:
extra = join_list[penultimate:]
join_list = join_list[:penultimate]
final = penultimate
penultimate = last.pop()
col = self.alias_map[extra[0]][LHS_JOIN_COL]
for alias in extra:
self.unref_alias(alias)
else:
col = target.column
alias = join_list[-1]
while final > 1:
# An optimization: if the final join is against the same column as
# we are comparing against, we can go back one step in the join
# chain and compare against the lhs of the join instead (and then
# repeat the optimization). The result, potentially, involves less
# table joins.
join = self.alias_map[alias]
if col != join[RHS_JOIN_COL]:
break
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
join_list = join_list[:-1]
final -= 1
if final == penultimate:
penultimate = last.pop()
if (lookup_type == 'isnull' and value is True and not negate and
final > 1):
# If the comparison is against NULL, we need to use a left outer
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed as it's less
# efficient at the database level.
self.promote_alias(join_list[penultimate])
if connector == OR:
# Some joins may need to be promoted when adding a new filter to a
# disjunction. We walk the list of new joins and where it diverges
# from any previous joins (ref count is 1 in the table list), we
# make the new additions (and any existing ones not used in the new
# join list) an outer join.
join_it = iter(join_list)
table_it = iter(self.tables)
join_it.next(), table_it.next()
table_promote = False
join_promote = False
for join in join_it:
table = table_it.next()
if join == table and self.alias_refcount[join] > 1:
continue
join_promote = self.promote_alias(join)
if table != join:
table_promote = self.promote_alias(table)
break
self.promote_alias_chain(join_it, join_promote)
self.promote_alias_chain(table_it, table_promote)
- self.where.add((alias, col, field, lookup_type, value), connector)
+ self.where.add(constraint_tuple(alias, col, field, lookup_type, value), connector)
if negate:
self.promote_alias_chain(join_list)
if lookup_type != 'isnull':
if final > 1:
for alias in join_list:
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
j_col = self.alias_map[alias][RHS_JOIN_COL]
entry = self.where_class()
- entry.add((alias, j_col, None, 'isnull', True), AND)
+ entry.add(constraint_tuple(alias, j_col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
break
elif not (lookup_type == 'in' and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# it's short-circuited in the Where class.
entry = self.where_class()
- entry.add((alias, col, None, 'isnull', True), AND)
+ entry.add(constraint_tuple(alias, col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
if can_reuse is not None:
can_reuse.update(join_list)
if process_extras:
for filter in extra_filters:
self.add_filter(filter, negate=negate, can_reuse=can_reuse,
process_extras=False)
def _setup_joins_with_translation(self, names, opts, alias,
dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None,
negate=False, process_extras=True):
"""
This is based on a full copy of Query.setup_joins because
currently I see no way to handle it differently.
TO DO: there might actually be a way, by splitting a single
multi-name setup_joins call into separate calls. Check it.
-- [email protected]
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are joining to), 'alias' is the alias for the
table we are joining to. If dupe_multis is True, any many-to-many or
many-to-one joins will always create a new alias (necessary for
disjunctive filters).
Returns the final field involved in the join, the target database
column (used for any 'where' constraint), the final 'opts' value and the
list of tables joined.
"""
joins = [alias]
last = [0]
dupe_set = set()
exclusions = set()
extra_filters = []
for pos, name in enumerate(names):
try:
exclusions.add(int_alias)
except NameError:
pass
exclusions.add(alias)
last.append(len(joins))
if name == 'pk':
name = opts.pk.name
try:
field, model, direct, m2m = opts.get_field_by_name(name)
except FieldDoesNotExist:
for f in opts.fields:
if allow_explicit_fk and name == f.attname:
# XXX: A hack to allow foo_id to work in values() for
# backwards compatibility purposes. If we dropped that
# feature, this could be removed.
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
names = opts.get_all_field_names()
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
if not allow_many and (m2m or not direct):
for alias in joins:
self.unref_alias(alias)
raise MultiJoin(pos + 1)
#NOTE: Start Django Multilingual specific code
if hasattr(opts, 'translation_model'):
translation_opts = opts.translation_model._meta
if model == opts.translation_model:
language_id = translation_opts.translated_fields[name][1]
if language_id is None:
language_id = get_default_language()
#TODO: check alias
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(model._meta.db_table),
qn2(new_table),
qn2(new_table),
qn(master_table_name),
qn2(model._meta.pk.column),
qn2(new_table),
language_id))
self.extra_join[new_table] = trans_join
target = field
continue
#NOTE: End Django Multilingual specific code
elif model:
# The field lives on a base class of the current model.
for int_model in opts.get_base_chain(model):
lhs_col = opts.parents[int_model].column
dedupe = lhs_col in opts.duplicate_targets
if dedupe:
exclusions.update(self.dupe_avoidance.get(
(id(opts), lhs_col), ()))
dupe_set.add((opts, lhs_col))
opts = int_model._meta
alias = self.join((alias, opts.db_table, lhs_col,
opts.pk.column), exclusions=exclusions)
joins.append(alias)
exclusions.add(alias)
for (dupe_opts, dupe_col) in dupe_set:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
cached_data = opts._join_cache.get(name)
orig_opts = opts
dupe_col = direct and field.column or field.field.column
dedupe = dupe_col in opts.duplicate_targets
if dupe_set or dedupe:
if dedupe:
dupe_set.add((opts, dupe_col))
exclusions.update(self.dupe_avoidance.get((id(opts), dupe_col),
()))
if process_extras and hasattr(field, 'extra_filters'):
extra_filters.extend(field.extra_filters(names, pos, negate))
if direct:
if m2m:
# Many-to-many field defined on the current model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_column_name()
opts = field.rel.to._meta
table2 = opts.db_table
from_col2 = field.m2m_reverse_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
if int_alias == table2 and from_col2 == to_col2:
joins.append(int_alias)
alias = int_alias
else:
alias = self.join(
(int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
elif field.rel:
# One-to-one or many-to-one field
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
opts = field.rel.to._meta
target = field.rel.get_related_field()
table = opts.db_table
from_col = field.column
to_col = target.column
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
exclusions=exclusions, nullable=field.null)
joins.append(alias)
else:
# Non-relation fields.
target = field
break
else:
orig_field = field
field = field.field
if m2m:
# Many-to-many field defined on the target model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_reverse_name()
opts = orig_field.opts
table2 = opts.db_table
from_col2 = field.m2m_column_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
alias = self.join((int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
else:
# One-to-many field (ForeignKey defined on the target model)
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
local_field = opts.get_field_by_name(
field.rel.field_name)[0]
opts = orig_field.opts
table = opts.db_table
from_col = local_field.column
to_col = field.column
target = opts.pk
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.append(alias)
for (dupe_opts, dupe_col) in dupe_set:
try:
self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias)
except NameError:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None, negate=False,
process_extras=True):
return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
allow_many, allow_explicit_fk,
can_reuse, negate, process_extras)
class MultilingualModelQuerySet(QuerySet):
"""
A specialized QuerySet that knows how to handle translatable
fields in ordering and filtering methods.
"""
def __init__(self, model=None, query=None):
query = query or MultilingualQuery(model, connection)
super(MultilingualModelQuerySet, self).__init__(model, query)
def for_language(self, language_id_or_code):
"""
Set the default language for all objects returned with this
query.
"""
clone = self._clone()
clone._default_language = get_language_id_from_id_or_code(language_id_or_code)
return clone
def iterator(self):
"""
Add the default language information to all returned objects.
"""
default_language = getattr(self, '_default_language', None)
for obj in super(MultilingualModelQuerySet, self).iterator():
obj._default_language = default_language
yield obj
def _clone(self, klass=None, **kwargs):
"""
Override _clone to preserve additional information needed by
MultilingualModelQuerySet.
"""
clone = super(MultilingualModelQuerySet, self)._clone(klass, **kwargs)
clone._default_language = getattr(self, '_default_language', None)
return clone
def order_by(self, *field_names):
if hasattr(self.model._meta, 'translation_model'):
trans_opts = self.model._meta.translation_model._meta
new_field_names = []
for field_name in field_names:
prefix = ''
if field_name[0] == '-':
prefix = '-'
field_name = field_name[1:]
field_and_lang = trans_opts.translated_fields.get(field_name)
if field_and_lang:
field, language_id = field_and_lang
if language_id is None:
language_id = getattr(self, '_default_language', None)
real_name = get_translated_field_alias(field.attname,
language_id)
new_field_names.append(prefix + real_name)
else:
new_field_names.append(prefix + field_name)
return super(MultilingualModelQuerySet, self).extra(order_by=new_field_names)
else:
return super(MultilingualModelQuerySet, self).order_by(*field_names)
|
stefanfoulis/django-multilingual
|
195d51848f11968d38c0ae9d9d82f21a8166b0c9
|
Bugfix: #86, imported a non-existant Count name. Thanks, alberto.paro!
|
diff --git a/multilingual/query.py b/multilingual/query.py
index c699321..bb0bbd0 100644
--- a/multilingual/query.py
+++ b/multilingual/query.py
@@ -1,527 +1,527 @@
"""
Django-multilingual: a QuerySet subclass for models with translatable
fields.
This file contains the implementation for QSRF Django.
"""
import datetime
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models.fields import FieldDoesNotExist
from django.db.models.query import QuerySet, Q
from django.db.models.sql.query import Query
-from django.db.models.sql.datastructures import Count, EmptyResultSet, Empty, MultiJoin
+from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin
from django.db.models.sql.constants import *
from django.db.models.sql.where import WhereNode, EverythingNode, AND, OR
from multilingual.languages import (get_translation_table_alias, get_language_id_list,
get_default_language, get_translated_field_alias,
get_language_id_from_id_or_code)
__ALL__ = ['MultilingualModelQuerySet']
class MultilingualQuery(Query):
def __init__(self, model, connection, where=WhereNode):
self.extra_join = {}
extra_select = {}
super(MultilingualQuery, self).__init__(model, connection, where=where)
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
for language_id in get_language_id_list():
for fname in [f.attname for f in translation_opts.fields]:
table_alias = get_translation_table_alias(trans_table_name,
language_id)
field_alias = get_translated_field_alias(fname,
language_id)
extra_select[field_alias] = qn2(table_alias) + '.' + qn2(fname)
self.add_extra(extra_select, None,None,None,None,None)
def clone(self, klass=None, **kwargs):
obj = super(MultilingualQuery, self).clone(klass=klass, **kwargs)
obj.extra_join = self.extra_join
return obj
def pre_sql_setup(self):
"""Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualQuery, self).pre_sql_setup()
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_id in get_language_id_list():
table_alias = get_translation_table_alias(trans_table_name,
language_id)
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(self.model._meta.pk.column),
qn2(table_alias),
language_id))
self.extra_join[table_alias] = trans_join
def get_from_clause(self):
"""Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualQuery, self).get_from_clause()
from_ = result[0]
for join in self.extra_join.values():
from_.append(join)
return (from_, result[1])
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None, process_extras=True):
"""Copied from add_filter to generate WHERES for translation fields.
"""
arg, value = filter_expr
parts = arg.split(LOOKUP_SEP)
if not parts:
raise FieldError("Cannot parse keyword query %r" % arg)
# Work out the lookup type and remove it from 'parts', if necessary.
if len(parts) == 1 or parts[-1] not in self.query_terms:
lookup_type = 'exact'
else:
lookup_type = parts.pop()
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
# uses of None as a query value.
if value is None:
if lookup_type != 'exact':
raise ValueError("Cannot use None as a query value")
lookup_type = 'isnull'
value = True
elif (value == '' and lookup_type == 'exact' and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value = True
elif callable(value):
value = value()
opts = self.get_meta()
alias = self.get_initial_alias()
allow_many = trim or not negate
try:
field, target, opts, join_list, last, extra_filters = self.setup_joins(
parts, opts, alias, True, allow_many, can_reuse=can_reuse,
negate=negate, process_extras=process_extras)
except MultiJoin, e:
self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]),
can_reuse)
return
#NOTE: here comes Django Multilingual
if hasattr(opts, 'translation_model'):
field_name = parts[-1]
if field_name == 'pk':
field_name = opts.pk.name
translation_opts = opts.translation_model._meta
if field_name in translation_opts.translated_fields.keys():
field, model, direct, m2m = opts.get_field_by_name(field_name)
if model == opts.translation_model:
language_id = translation_opts.translated_fields[field_name][1]
if language_id is None:
language_id = get_default_language()
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
self.where.add((new_table, field.column, field, lookup_type, value), connector)
return
final = len(join_list)
penultimate = last.pop()
if penultimate == final:
penultimate = last.pop()
if trim and len(join_list) > 1:
extra = join_list[penultimate:]
join_list = join_list[:penultimate]
final = penultimate
penultimate = last.pop()
col = self.alias_map[extra[0]][LHS_JOIN_COL]
for alias in extra:
self.unref_alias(alias)
else:
col = target.column
alias = join_list[-1]
while final > 1:
# An optimization: if the final join is against the same column as
# we are comparing against, we can go back one step in the join
# chain and compare against the lhs of the join instead (and then
# repeat the optimization). The result, potentially, involves less
# table joins.
join = self.alias_map[alias]
if col != join[RHS_JOIN_COL]:
break
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
join_list = join_list[:-1]
final -= 1
if final == penultimate:
penultimate = last.pop()
if (lookup_type == 'isnull' and value is True and not negate and
final > 1):
# If the comparison is against NULL, we need to use a left outer
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed as it's less
# efficient at the database level.
self.promote_alias(join_list[penultimate])
if connector == OR:
# Some joins may need to be promoted when adding a new filter to a
# disjunction. We walk the list of new joins and where it diverges
# from any previous joins (ref count is 1 in the table list), we
# make the new additions (and any existing ones not used in the new
# join list) an outer join.
join_it = iter(join_list)
table_it = iter(self.tables)
join_it.next(), table_it.next()
table_promote = False
join_promote = False
for join in join_it:
table = table_it.next()
if join == table and self.alias_refcount[join] > 1:
continue
join_promote = self.promote_alias(join)
if table != join:
table_promote = self.promote_alias(table)
break
self.promote_alias_chain(join_it, join_promote)
self.promote_alias_chain(table_it, table_promote)
self.where.add((alias, col, field, lookup_type, value), connector)
if negate:
self.promote_alias_chain(join_list)
if lookup_type != 'isnull':
if final > 1:
for alias in join_list:
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
j_col = self.alias_map[alias][RHS_JOIN_COL]
entry = self.where_class()
entry.add((alias, j_col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
break
elif not (lookup_type == 'in' and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# it's short-circuited in the Where class.
entry = self.where_class()
entry.add((alias, col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
if can_reuse is not None:
can_reuse.update(join_list)
if process_extras:
for filter in extra_filters:
self.add_filter(filter, negate=negate, can_reuse=can_reuse,
process_extras=False)
def _setup_joins_with_translation(self, names, opts, alias,
dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None,
negate=False, process_extras=True):
"""
This is based on a full copy of Query.setup_joins because
currently I see no way to handle it differently.
TO DO: there might actually be a way, by splitting a single
multi-name setup_joins call into separate calls. Check it.
-- [email protected]
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are joining to), 'alias' is the alias for the
table we are joining to. If dupe_multis is True, any many-to-many or
many-to-one joins will always create a new alias (necessary for
disjunctive filters).
Returns the final field involved in the join, the target database
column (used for any 'where' constraint), the final 'opts' value and the
list of tables joined.
"""
joins = [alias]
last = [0]
dupe_set = set()
exclusions = set()
extra_filters = []
for pos, name in enumerate(names):
try:
exclusions.add(int_alias)
except NameError:
pass
exclusions.add(alias)
last.append(len(joins))
if name == 'pk':
name = opts.pk.name
try:
field, model, direct, m2m = opts.get_field_by_name(name)
except FieldDoesNotExist:
for f in opts.fields:
if allow_explicit_fk and name == f.attname:
# XXX: A hack to allow foo_id to work in values() for
# backwards compatibility purposes. If we dropped that
# feature, this could be removed.
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
names = opts.get_all_field_names()
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
if not allow_many and (m2m or not direct):
for alias in joins:
self.unref_alias(alias)
raise MultiJoin(pos + 1)
#NOTE: Start Django Multilingual specific code
if hasattr(opts, 'translation_model'):
translation_opts = opts.translation_model._meta
if model == opts.translation_model:
language_id = translation_opts.translated_fields[name][1]
if language_id is None:
language_id = get_default_language()
#TODO: check alias
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(model._meta.db_table),
qn2(new_table),
qn2(new_table),
qn(master_table_name),
qn2(model._meta.pk.column),
qn2(new_table),
language_id))
self.extra_join[new_table] = trans_join
target = field
continue
#NOTE: End Django Multilingual specific code
elif model:
# The field lives on a base class of the current model.
for int_model in opts.get_base_chain(model):
lhs_col = opts.parents[int_model].column
dedupe = lhs_col in opts.duplicate_targets
if dedupe:
exclusions.update(self.dupe_avoidance.get(
(id(opts), lhs_col), ()))
dupe_set.add((opts, lhs_col))
opts = int_model._meta
alias = self.join((alias, opts.db_table, lhs_col,
opts.pk.column), exclusions=exclusions)
joins.append(alias)
exclusions.add(alias)
for (dupe_opts, dupe_col) in dupe_set:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
cached_data = opts._join_cache.get(name)
orig_opts = opts
dupe_col = direct and field.column or field.field.column
dedupe = dupe_col in opts.duplicate_targets
if dupe_set or dedupe:
if dedupe:
dupe_set.add((opts, dupe_col))
exclusions.update(self.dupe_avoidance.get((id(opts), dupe_col),
()))
if process_extras and hasattr(field, 'extra_filters'):
extra_filters.extend(field.extra_filters(names, pos, negate))
if direct:
if m2m:
# Many-to-many field defined on the current model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_column_name()
opts = field.rel.to._meta
table2 = opts.db_table
from_col2 = field.m2m_reverse_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
if int_alias == table2 and from_col2 == to_col2:
joins.append(int_alias)
alias = int_alias
else:
alias = self.join(
(int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
elif field.rel:
# One-to-one or many-to-one field
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
opts = field.rel.to._meta
target = field.rel.get_related_field()
table = opts.db_table
from_col = field.column
to_col = target.column
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
exclusions=exclusions, nullable=field.null)
joins.append(alias)
else:
# Non-relation fields.
target = field
break
else:
orig_field = field
field = field.field
if m2m:
# Many-to-many field defined on the target model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_reverse_name()
opts = orig_field.opts
table2 = opts.db_table
from_col2 = field.m2m_column_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
alias = self.join((int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
else:
# One-to-many field (ForeignKey defined on the target model)
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
local_field = opts.get_field_by_name(
field.rel.field_name)[0]
opts = orig_field.opts
table = opts.db_table
from_col = local_field.column
to_col = field.column
target = opts.pk
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.append(alias)
for (dupe_opts, dupe_col) in dupe_set:
try:
self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias)
except NameError:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None, negate=False,
process_extras=True):
return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
allow_many, allow_explicit_fk,
can_reuse, negate, process_extras)
class MultilingualModelQuerySet(QuerySet):
"""
A specialized QuerySet that knows how to handle translatable
fields in ordering and filtering methods.
"""
def __init__(self, model=None, query=None):
query = query or MultilingualQuery(model, connection)
super(MultilingualModelQuerySet, self).__init__(model, query)
def for_language(self, language_id_or_code):
"""
Set the default language for all objects returned with this
query.
"""
clone = self._clone()
clone._default_language = get_language_id_from_id_or_code(language_id_or_code)
return clone
def iterator(self):
"""
Add the default language information to all returned objects.
"""
default_language = getattr(self, '_default_language', None)
for obj in super(MultilingualModelQuerySet, self).iterator():
obj._default_language = default_language
yield obj
def _clone(self, klass=None, **kwargs):
"""
Override _clone to preserve additional information needed by
MultilingualModelQuerySet.
"""
clone = super(MultilingualModelQuerySet, self)._clone(klass, **kwargs)
clone._default_language = getattr(self, '_default_language', None)
return clone
def order_by(self, *field_names):
if hasattr(self.model._meta, 'translation_model'):
trans_opts = self.model._meta.translation_model._meta
new_field_names = []
for field_name in field_names:
prefix = ''
if field_name[0] == '-':
prefix = '-'
field_name = field_name[1:]
field_and_lang = trans_opts.translated_fields.get(field_name)
if field_and_lang:
field, language_id = field_and_lang
if language_id is None:
language_id = getattr(self, '_default_language', None)
real_name = get_translated_field_alias(field.attname,
language_id)
new_field_names.append(prefix + real_name)
else:
new_field_names.append(prefix + field_name)
return super(MultilingualModelQuerySet, self).extra(order_by=new_field_names)
else:
|
stefanfoulis/django-multilingual
|
f107481480a2dc04ce1be5add18350b10daf55fc
|
Added AUTHORS and LICENSE files.
|
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..9ffa253
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,19 @@
+django-multilingual was originally created in 2007 by Marcin Kaszynski.
+
+Current or former committers:
+
+ Ashley Camba
+ Joost Cassee
+ Fabio Corneti
+ Marcin Kaszynski
+ Matthias Urlichs
+
+Contributors:
+
+ Jure Cuhalev
+ [email protected]
+ Yann Malet
+ mkriheli
+ Manuel Saelices
+ Florian Sening
+ Jakub WiÅniowski
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..ee8d676
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2007-2008 individual contributors (see AUTHORS.txt)
+
+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.
\ No newline at end of file
|
stefanfoulis/django-multilingual
|
7b616162ff84a25163dca0a4eccc2a46c0bd9f2c
|
Added prepopulated_fields validation code (it was disabled for multilingual models). Changed DM behavior when a model is registered with the admin site with a modeladmin not inheriting multilingual.ModelAdmin: it now signals a DeprecationWarning instead of throwing an error.
|
diff --git a/multilingual/admin.py b/multilingual/admin.py
index 2d0d043..3d11e0e 100644
--- a/multilingual/admin.py
+++ b/multilingual/admin.py
@@ -1,131 +1,136 @@
from django.contrib import admin
from multilingual.languages import *
+from multilingual.utils import is_multilingual_model
class TranslationModelAdmin(admin.StackedInline):
template = "admin/edit_inline_translations_newforms.html"
fk_name = 'master'
extra = get_language_count()
max_num = get_language_count()
class ModelAdminClass(admin.ModelAdmin.__metaclass__):
+ """
+ A metaclass for ModelAdmin below.
+ """
+
def __new__(cls, name, bases, attrs):
# Move prepopulated_fields somewhere where Django won't see
# them. We have to handle them ourselves.
prepopulated_fields = attrs.get('prepopulated_fields', {})
attrs['prepopulated_fields'] = {}
attrs['_dm_prepopulated_fields'] = prepopulated_fields
return super(ModelAdminClass, cls).__new__(cls, name, bases, attrs)
class ModelAdmin(admin.ModelAdmin):
"""
All model admins for multilingual models must inherit this class
instead of django.contrib.admin.ModelAdmin.
"""
__metaclass__ = ModelAdminClass
def _media(self):
media = super(ModelAdmin, self)._media()
if getattr(self.__class__, '_dm_prepopulated_fields', None):
from django.conf import settings
media.add_js(['%sjs/urlify.js' % (settings.ADMIN_MEDIA_PREFIX,)])
return media
media = property(_media)
def render_change_form(self, request, context, add=False, change=False,
form_url='', obj=None):
# I'm overriding render_change_form to inject information
# about prepopulated_fields
trans_model = self.model._meta.translation_model
trans_fields = trans_model._meta.translated_fields
adminform = context['adminform']
form = adminform.form
def field_name_to_fake_field(field_name):
"""
Return something that looks like a form field enough to
fool prepopulated_fields_js.html
For field_names of real fields in self.model this actually
returns a real form field.
"""
try:
field, language_id = trans_fields[field_name]
if language_id is None:
language_id = get_default_language()
# TODO: we have this mapping between language_id and
# field id in two places -- here and in
# edit_inline_translations_newforms.html
# It is not DRY.
field_idx = language_id - 1
ret = {'auto_id': 'id_translations-%d-%s' % (field_idx, field.name)
}
except:
ret = form[field_name]
return ret
adminform.prepopulated_fields = [{
'field': field_name_to_fake_field(field_name),
'dependencies': [field_name_to_fake_field(f) for f in dependencies]
} for field_name, dependencies in self._dm_prepopulated_fields.items()]
return super(ModelAdmin, self).render_change_form(request, context,
add, change, form_url, obj)
-
-def is_multilingual_model(model):
- return hasattr(model._meta, 'translation_model')
-
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
return tr_cls
+# TODO: multilingual_modeladmin_new should go away soon. The code will
+# be split between the ModelAdmin class, its metaclass and validation
+# code.
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
if is_multilingual_model(model):
if cls is admin.ModelAdmin:
# the model is being registered with the default
# django.contrib.admin.options.ModelAdmin. Replace it
# with our ModelAdmin, since it is safe to assume it is a
# simple call to admin.site.register without just model
# passed
# subclass it, because we need to set the inlines class
# attribute below
cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
# make sure it subclasses multilingual.ModelAdmin
if not issubclass(cls, ModelAdmin):
- raise ValueError, ("%s must be registered with a subclass of "
- + " of multilingual.ModelAdmin.") % model
+ from warnings import warn
+ warn("%s should be registered with a subclass of "
+ " of multilingual.ModelAdmin." % model, DeprecationWarning)
# if the inlines already contain a class for the
# translation model, use it and don't create another one
translation_modeladmin = None
for inline in getattr(cls, 'inlines', []):
if inline.model == model._meta.translation_model:
translation_modeladmin = inline
if not translation_modeladmin:
translation_modeladmin = get_translation_modeladmin(cls, model)
if cls.inlines:
cls.inlines.insert(0, translation_modeladmin)
else:
cls.inlines = [translation_modeladmin]
return admin.ModelAdmin._original_new_before_dm(cls, model, admin_site, obj)
def install_multilingual_modeladmin_new():
"""
Override ModelAdmin.__new__ to create automatic inline
editor for multilingual models.
"""
- admin.ModelAdmin._original_new_before_dm = ModelAdmin.__new__
+ admin.ModelAdmin._original_new_before_dm = admin.ModelAdmin.__new__
admin.ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
diff --git a/multilingual/models.py b/multilingual/models.py
index 0f2c2fd..68d4865 100644
--- a/multilingual/models.py
+++ b/multilingual/models.py
@@ -1,17 +1,20 @@
"""
Multilingual model support.
This code is put in multilingual.models to make Django execute it
during application initialization.
TO DO: remove it. Right now multilingual must be imported directly
into any file that defines translatable models, so it will be
installed anyway.
This module is here only to make it easier to upgrade from versions
that did not require TranslatableModel.Translation classes to subclass
multilingual.Translation to versions that do.
"""
from translation import install_translation_library
install_translation_library()
+
+from validation import install_multilingual_admin_validation
+install_multilingual_admin_validation()
diff --git a/multilingual/translation.py b/multilingual/translation.py
index 4df3886..ced81eb 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,362 +1,367 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from multilingual.admin import install_multilingual_modeladmin_new
+# TODO: remove this import. It is here only because earlier versions
+# of the library required importing TranslationModelAdmin from here
+# instead of taking it directly from multilingual
+from multilingual.admin import TranslationModelAdmin
+
from new import instancemethod
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def translation_overwrite_previous(instance, **kwargs):
"""
Delete previously existing translation with the same master and
language_id values. To be called by translation model's pre_save
signal.
This most probably means I am abusing something here trying to use
Django inline editor. Oh well, it will have to go anyway when we
move to newforms.
"""
qs = instance.__class__.objects
try:
qs = qs.filter(master=instance.master).filter(language_id=instance.language_id)
qs.delete()
except ObjectDoesNotExist:
# We are probably loading a fixture that defines translation entities
# before their master entity.
pass
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None):
try:
return getattr(self.get_translation(language_id_or_code), field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False):
"""
Get a translation instance for the given language_id_or_code.
If it does not exist, either create one or raise the
TranslationDoesNotExist exception, depending on the
create_if_necessary argument.
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id not in self._translation_cache:
if not create_if_necessary:
raise TranslationDoesNotExist(language_id)
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return self._translation_cache.get(language_id, None)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
# connect the pre_save signal on translation class to a
# function removing previous translation entries.
signals.pre_save.connect(translation_overwrite_previous,
sender=trans_model, weak=False)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
# Install a hack to let add_multilingual_manipulators know
# this is a translatable model (TODO: manipulators gone)
attrs['is_translation_model'] = lambda self: True
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
install_multilingual_modeladmin_new()
# install the library
install_translation_library()
|
stefanfoulis/django-multilingual
|
8c2e1276a37243afeb28237b206c8cac409b482e
|
Prepopulated_fields seems to be working correctly. Also, added missing tests for inline editing classes.
|
diff --git a/multilingual/admin.py b/multilingual/admin.py
index e63e94b..2d0d043 100644
--- a/multilingual/admin.py
+++ b/multilingual/admin.py
@@ -1,132 +1,131 @@
from django.contrib import admin
from multilingual.languages import *
class TranslationModelAdmin(admin.StackedInline):
template = "admin/edit_inline_translations_newforms.html"
fk_name = 'master'
extra = get_language_count()
max_num = get_language_count()
class ModelAdminClass(admin.ModelAdmin.__metaclass__):
def __new__(cls, name, bases, attrs):
# Move prepopulated_fields somewhere where Django won't see
# them. We have to handle them ourselves.
- prepopulated_fields = attrs.get('prepopulated_fields')
- if prepopulated_fields:
- attrs['_dm_prepopulated_fields'] = prepopulated_fields
- attrs['prepopulated_fields'] = {}
+ prepopulated_fields = attrs.get('prepopulated_fields', {})
+ attrs['prepopulated_fields'] = {}
+ attrs['_dm_prepopulated_fields'] = prepopulated_fields
return super(ModelAdminClass, cls).__new__(cls, name, bases, attrs)
class ModelAdmin(admin.ModelAdmin):
"""
All model admins for multilingual models must inherit this class
instead of django.contrib.admin.ModelAdmin.
"""
__metaclass__ = ModelAdminClass
def _media(self):
media = super(ModelAdmin, self)._media()
if getattr(self.__class__, '_dm_prepopulated_fields', None):
from django.conf import settings
media.add_js(['%sjs/urlify.js' % (settings.ADMIN_MEDIA_PREFIX,)])
return media
media = property(_media)
def render_change_form(self, request, context, add=False, change=False,
form_url='', obj=None):
# I'm overriding render_change_form to inject information
# about prepopulated_fields
trans_model = self.model._meta.translation_model
trans_fields = trans_model._meta.translated_fields
adminform = context['adminform']
form = adminform.form
def field_name_to_fake_field(field_name):
"""
Return something that looks like a form field enough to
fool prepopulated_fields_js.html
For field_names of real fields in self.model this actually
returns a real form field.
"""
try:
field, language_id = trans_fields[field_name]
if language_id is None:
language_id = get_default_language()
# TODO: we have this mapping between language_id and
# field id in two places -- here and in
# edit_inline_translations_newforms.html
# It is not DRY.
field_idx = language_id - 1
ret = {'auto_id': 'id_translations-%d-%s' % (field_idx, field.name)
}
except:
ret = form[field_name]
return ret
adminform.prepopulated_fields = [{
'field': field_name_to_fake_field(field_name),
'dependencies': [field_name_to_fake_field(f) for f in dependencies]
} for field_name, dependencies in self._dm_prepopulated_fields.items()]
return super(ModelAdmin, self).render_change_form(request, context,
add, change, form_url, obj)
def is_multilingual_model(model):
return hasattr(model._meta, 'translation_model')
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
return tr_cls
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
if is_multilingual_model(model):
if cls is admin.ModelAdmin:
# the model is being registered with the default
# django.contrib.admin.options.ModelAdmin. Replace it
# with our ModelAdmin, since it is safe to assume it is a
# simple call to admin.site.register without just model
# passed
# subclass it, because we need to set the inlines class
# attribute below
cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
# make sure it subclasses multilingual.ModelAdmin
if not issubclass(cls, ModelAdmin):
raise ValueError, ("%s must be registered with a subclass of "
+ " of multilingual.ModelAdmin.") % model
# if the inlines already contain a class for the
# translation model, use it and don't create another one
translation_modeladmin = None
for inline in getattr(cls, 'inlines', []):
if inline.model == model._meta.translation_model:
translation_modeladmin = inline
if not translation_modeladmin:
translation_modeladmin = get_translation_modeladmin(cls, model)
if cls.inlines:
cls.inlines.insert(0, translation_modeladmin)
else:
cls.inlines = [translation_modeladmin]
return admin.ModelAdmin._original_new_before_dm(cls, model, admin_site, obj)
def install_multilingual_modeladmin_new():
"""
Override ModelAdmin.__new__ to create automatic inline
editor for multilingual models.
"""
admin.ModelAdmin._original_new_before_dm = ModelAdmin.__new__
admin.ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
diff --git a/testproject/inline_registrations/__init__.py b/testproject/inline_registrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/testproject/inline_registrations/admin.py b/testproject/inline_registrations/admin.py
new file mode 100644
index 0000000..d61e4ce
--- /dev/null
+++ b/testproject/inline_registrations/admin.py
@@ -0,0 +1,31 @@
+from django.contrib import admin
+from testproject.inline_registrations.models import (ArticleWithSimpleRegistration,
+ ArticleWithExternalInline,
+ ArticleWithInternalInline)
+import multilingual
+
+##########################################
+# for ArticleWithSimpleRegistration
+
+admin.site.register(ArticleWithSimpleRegistration)
+
+########################################
+# for ArticleWithExternalInline
+
+class TranslationAdmin(multilingual.TranslationModelAdmin):
+ model = ArticleWithExternalInline._meta.translation_model
+ prepopulated_fields = {'slug_local': ('title',)}
+
+class ArticleWithExternalInlineAdmin(multilingual.ModelAdmin):
+ inlines = [TranslationAdmin]
+
+admin.site.register(ArticleWithExternalInline, ArticleWithExternalInlineAdmin)
+
+########################################
+# for ArticleWithInternalInline
+
+class ArticleWithInternalInlineAdmin(multilingual.ModelAdmin):
+ class Translation(multilingual.TranslationModelAdmin):
+ prepopulated_fields = {'slug_local': ('title',)}
+
+admin.site.register(ArticleWithInternalInline, ArticleWithInternalInlineAdmin)
diff --git a/testproject/inline_registrations/models.py b/testproject/inline_registrations/models.py
new file mode 100644
index 0000000..5d1e972
--- /dev/null
+++ b/testproject/inline_registrations/models.py
@@ -0,0 +1,38 @@
+from django.db import models
+import multilingual
+
+class ArticleWithSimpleRegistration(models.Model):
+ """
+ This model will be registered without specifying a ModelAdmin.
+ """
+ slug_global = models.SlugField(blank=True, null=False)
+
+ class Translation(multilingual.Translation):
+ slug_local = models.SlugField(blank=True, null=False)
+ title = models.CharField(blank=True, null=False, max_length=250)
+ contents = models.TextField(blank=True, null=False)
+
+class ArticleWithExternalInline(models.Model):
+ """
+ This model will be registered with a ModelAdmin and an
+ externally-defined TranslationModelAdmin class.
+ """
+ slug_global = models.SlugField(blank=True, null=False)
+
+ class Translation(multilingual.Translation):
+ slug_local = models.SlugField(blank=True, null=False)
+ title = models.CharField(blank=True, null=False, max_length=250)
+ contents = models.TextField(blank=True, null=False)
+
+class ArticleWithInternalInline(models.Model):
+ """
+ This model will be registered with a ModelAdmin having an inner
+ Translation class.
+ """
+ slug_global = models.SlugField(blank=True, null=False)
+
+ class Translation(multilingual.Translation):
+ slug_local = models.SlugField(blank=True, null=False)
+ title = models.CharField(blank=True, null=False, max_length=250)
+ contents = models.TextField(blank=True, null=False)
+
diff --git a/testproject/inline_registrations/tests.py b/testproject/inline_registrations/tests.py
new file mode 100644
index 0000000..c629f78
--- /dev/null
+++ b/testproject/inline_registrations/tests.py
@@ -0,0 +1,148 @@
+from testproject.utils import AdminTestCase
+from testproject.inline_registrations.models import (ArticleWithSimpleRegistration,
+ ArticleWithExternalInline,
+ ArticleWithInternalInline)
+
+class SimpleRegistrationTestCase(AdminTestCase):
+ def test_add(self):
+ ArticleWithSimpleRegistration.objects.all().delete()
+
+ path = '/admin/inline_registrations/articlewithsimpleregistration/'
+
+ # get the list
+ resp = self.client.get(path)
+ self.assertEqual(resp.status_code, 200)
+
+ # check the 'add' form
+ resp = self.client.get(path + 'add/')
+ self.assertEqual(resp.status_code, 200)
+ self.assert_('adminform' in resp.context[0])
+
+ # submit a new article
+ resp = self.client.post(path + 'add/',
+ {'slug_global': 'new-article',
+ 'translations-TOTAL_FORMS': '3',
+ 'translations-INITIAL_FORMS': '0',
+ 'translations-0-slug_local': 'slug-en',
+ 'translations-0-title': 'title en',
+ 'translations-0-contents': 'contents en',
+ 'translations-0-language_id': '1',
+ 'translations-1-slug_local': 'slug-pl',
+ 'translations-1-title': 'title pl',
+ 'translations-1-contents': 'contents pl',
+ 'translations-1-language_id': '2',
+ 'translations-2-slug_local': 'slug-cn',
+ 'translations-2-title': 'title cn',
+ 'translations-2-contents': 'contents cn',
+ 'translations-2-language_id': '3',
+ })
+ # a successful POST ends with a 302 redirect
+ self.assertEqual(resp.status_code, 302)
+ art = ArticleWithSimpleRegistration.objects.all()[0]
+ self.assertEqual(art.slug_global, 'new-article')
+ self.assertEqual(art.slug_local_en, 'slug-en')
+ self.assertEqual(art.slug_local_pl, 'slug-pl')
+ self.assertEqual(art.slug_local_zh_cn, 'slug-cn')
+
+
+class ExternalInlineTestCase(AdminTestCase):
+ def test_add(self):
+ ArticleWithExternalInline.objects.all().delete()
+
+ path = '/admin/inline_registrations/articlewithexternalinline/'
+
+ # get the list
+ resp = self.client.get(path)
+ self.assertEqual(resp.status_code, 200)
+
+ # check the 'add' form
+ resp = self.client.get(path + 'add/')
+ self.assertEqual(resp.status_code, 200)
+ self.assert_('adminform' in resp.context[0])
+
+ # make sure it contains the JS code for prepopulated_fields
+ self.assertContains(resp,
+ 'getElementById("id_translations-0-slug_local").onchange')
+ self.assertContains(resp,
+ 'getElementById("id_translations-1-slug_local").onchange')
+ self.assertContains(resp,
+ 'getElementById("id_translations-2-slug_local").onchange')
+
+ # submit a new article
+ resp = self.client.post(path + 'add/',
+ {'slug_global': 'new-article',
+ 'translations-TOTAL_FORMS': '3',
+ 'translations-INITIAL_FORMS': '0',
+ 'translations-0-slug_local': 'slug-en',
+ 'translations-0-title': 'title en',
+ 'translations-0-contents': 'contents en',
+ 'translations-0-language_id': '1',
+ 'translations-1-slug_local': 'slug-pl',
+ 'translations-1-title': 'title pl',
+ 'translations-1-contents': 'contents pl',
+ 'translations-1-language_id': '2',
+ 'translations-2-slug_local': 'slug-cn',
+ 'translations-2-title': 'title cn',
+ 'translations-2-contents': 'contents cn',
+ 'translations-2-language_id': '3',
+ })
+ # a successful POST ends with a 302 redirect
+ self.assertEqual(resp.status_code, 302)
+ art = ArticleWithExternalInline.objects.all()[0]
+ self.assertEqual(art.slug_global, 'new-article')
+ self.assertEqual(art.slug_local_en, 'slug-en')
+ self.assertEqual(art.slug_local_pl, 'slug-pl')
+ self.assertEqual(art.slug_local_zh_cn, 'slug-cn')
+
+
+
+class InternalInlineTestCase(AdminTestCase):
+ def test_add(self):
+ ArticleWithInternalInline.objects.all().delete()
+
+ path = '/admin/inline_registrations/articlewithinternalinline/'
+
+ # get the list
+ resp = self.client.get(path)
+ self.assertEqual(resp.status_code, 200)
+
+ # check the 'add' form
+ resp = self.client.get(path + 'add/')
+ self.assertEqual(resp.status_code, 200)
+ self.assert_('adminform' in resp.context[0])
+
+ # make sure it contains the JS code for prepopulated_fields
+ self.assertContains(resp,
+ 'getElementById("id_translations-0-slug_local").onchange')
+ self.assertContains(resp,
+ 'getElementById("id_translations-1-slug_local").onchange')
+ self.assertContains(resp,
+ 'getElementById("id_translations-2-slug_local").onchange')
+
+ # submit a new article
+ resp = self.client.post(path + 'add/',
+ {'slug_global': 'new-article',
+ 'translations-TOTAL_FORMS': '3',
+ 'translations-INITIAL_FORMS': '0',
+ 'translations-0-slug_local': 'slug-en',
+ 'translations-0-title': 'title en',
+ 'translations-0-contents': 'contents en',
+ 'translations-0-language_id': '1',
+ 'translations-1-slug_local': 'slug-pl',
+ 'translations-1-title': 'title pl',
+ 'translations-1-contents': 'contents pl',
+ 'translations-1-language_id': '2',
+ 'translations-2-slug_local': 'slug-cn',
+ 'translations-2-title': 'title cn',
+ 'translations-2-contents': 'contents cn',
+ 'translations-2-language_id': '3',
+ })
+ # a successful POST ends with a 302 redirect
+ self.assertEqual(resp.status_code, 302)
+ art = ArticleWithInternalInline.objects.all()[0]
+ self.assertEqual(art.slug_global, 'new-article')
+ self.assertEqual(art.slug_local_en, 'slug-en')
+ self.assertEqual(art.slug_local_pl, 'slug-pl')
+ self.assertEqual(art.slug_local_zh_cn, 'slug-cn')
+
+
diff --git a/testproject/issue_23/admin.py b/testproject/issue_23/admin.py
index 69bd82a..47b8851 100644
--- a/testproject/issue_23/admin.py
+++ b/testproject/issue_23/admin.py
@@ -1,14 +1,8 @@
from django.contrib import admin
from testproject.issue_23.models import ArticleWithSlug
import multilingual
-from multilingual.languages import get_language_count
-
-class TranslationAdmin(multilingual.TranslationModelAdmin):
-# prepopulated_fields = {'slug_local': ('title',)}
- model = ArticleWithSlug._meta.translation_model
class ArticleWithSlugAdmin(multilingual.ModelAdmin):
- inlines = [TranslationAdmin]
- prepopulated_fields = {'slug_global': ('title_en',)}
+ prepopulated_fields = {'slug_global': ('title', 'title_pl')}
admin.site.register(ArticleWithSlug, ArticleWithSlugAdmin)
diff --git a/testproject/settings.py b/testproject/settings.py
index 8546512..f38dba7 100644
--- a/testproject/settings.py
+++ b/testproject/settings.py
@@ -1,111 +1,112 @@
# Django settings for testproject project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'database.db3' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en'
# django-multilanguange #####################
# It is important that the language identifiers are consecutive
# numbers starting with 1.
LANGUAGES = [['en', 'English'], # id=1
['pl', 'Polish'], # id=2
['zh-cn', 'Simplified Chinese'], # id=3
]
DEFAULT_LANGUAGE = 1
##############################################
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '1+t11&r9nw+d7uw558+8=#j8!8^$nt97ecgv()-@x!tcef7f6)'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'multilingual.flatpages.middleware.FlatpageFallbackMiddleware',
)
ROOT_URLCONF = 'testproject.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'../multilingual/templates/',
'templates/',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'multilingual',
'multilingual.flatpages',
'testproject.articles',
+ 'testproject.inline_registrations',
'testproject.issue_15',
'testproject.issue_16',
'testproject.issue_23',
'testproject.issue_29',
'testproject.issue_37',
'testproject.issue_61',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'multilingual.context_processors.multilingual',
)
|
stefanfoulis/django-multilingual
|
6dee10ea37dbc802fabd0a151cd4dffd19d5f78c
|
Added support for using prepopulated_fields with dependencies from translatable fields.
|
diff --git a/multilingual/__init__.py b/multilingual/__init__.py
index ed6a5b6..2a31747 100644
--- a/multilingual/__init__.py
+++ b/multilingual/__init__.py
@@ -1,9 +1,10 @@
"""
Django-multilingual: multilingual model support for Django.
"""
from multilingual import models
from multilingual.exceptions import TranslationDoesNotExist, LanguageDoesNotExist
from multilingual.languages import set_default_language, get_default_language, get_language_code_list
from multilingual.translation import Translation
+from multilingual.admin import ModelAdmin, TranslationModelAdmin
from multilingual.manager import Manager
diff --git a/multilingual/admin.py b/multilingual/admin.py
new file mode 100644
index 0000000..e63e94b
--- /dev/null
+++ b/multilingual/admin.py
@@ -0,0 +1,132 @@
+from django.contrib import admin
+from multilingual.languages import *
+
+class TranslationModelAdmin(admin.StackedInline):
+ template = "admin/edit_inline_translations_newforms.html"
+ fk_name = 'master'
+ extra = get_language_count()
+ max_num = get_language_count()
+
+class ModelAdminClass(admin.ModelAdmin.__metaclass__):
+ def __new__(cls, name, bases, attrs):
+ # Move prepopulated_fields somewhere where Django won't see
+ # them. We have to handle them ourselves.
+ prepopulated_fields = attrs.get('prepopulated_fields')
+ if prepopulated_fields:
+ attrs['_dm_prepopulated_fields'] = prepopulated_fields
+ attrs['prepopulated_fields'] = {}
+ return super(ModelAdminClass, cls).__new__(cls, name, bases, attrs)
+
+class ModelAdmin(admin.ModelAdmin):
+ """
+ All model admins for multilingual models must inherit this class
+ instead of django.contrib.admin.ModelAdmin.
+ """
+ __metaclass__ = ModelAdminClass
+
+ def _media(self):
+ media = super(ModelAdmin, self)._media()
+ if getattr(self.__class__, '_dm_prepopulated_fields', None):
+ from django.conf import settings
+ media.add_js(['%sjs/urlify.js' % (settings.ADMIN_MEDIA_PREFIX,)])
+ return media
+ media = property(_media)
+
+ def render_change_form(self, request, context, add=False, change=False,
+ form_url='', obj=None):
+ # I'm overriding render_change_form to inject information
+ # about prepopulated_fields
+
+ trans_model = self.model._meta.translation_model
+ trans_fields = trans_model._meta.translated_fields
+ adminform = context['adminform']
+ form = adminform.form
+
+ def field_name_to_fake_field(field_name):
+ """
+ Return something that looks like a form field enough to
+ fool prepopulated_fields_js.html
+
+ For field_names of real fields in self.model this actually
+ returns a real form field.
+ """
+ try:
+ field, language_id = trans_fields[field_name]
+ if language_id is None:
+ language_id = get_default_language()
+
+ # TODO: we have this mapping between language_id and
+ # field id in two places -- here and in
+ # edit_inline_translations_newforms.html
+ # It is not DRY.
+ field_idx = language_id - 1
+ ret = {'auto_id': 'id_translations-%d-%s' % (field_idx, field.name)
+ }
+ except:
+ ret = form[field_name]
+ return ret
+
+ adminform.prepopulated_fields = [{
+ 'field': field_name_to_fake_field(field_name),
+ 'dependencies': [field_name_to_fake_field(f) for f in dependencies]
+ } for field_name, dependencies in self._dm_prepopulated_fields.items()]
+
+ return super(ModelAdmin, self).render_change_form(request, context,
+ add, change, form_url, obj)
+
+
+def is_multilingual_model(model):
+ return hasattr(model._meta, 'translation_model')
+
+def get_translation_modeladmin(cls, model):
+ if hasattr(cls, 'Translation'):
+ tr_cls = cls.Translation
+ if not issubclass(tr_cls, TranslationModelAdmin):
+ raise ValueError, ("%s.Translation must be a subclass "
+ + " of multilingual.TranslationModelAdmin.") % cls.name
+ else:
+ tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
+ tr_cls.model = model._meta.translation_model
+ return tr_cls
+
+def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
+ if is_multilingual_model(model):
+ if cls is admin.ModelAdmin:
+ # the model is being registered with the default
+ # django.contrib.admin.options.ModelAdmin. Replace it
+ # with our ModelAdmin, since it is safe to assume it is a
+ # simple call to admin.site.register without just model
+ # passed
+
+ # subclass it, because we need to set the inlines class
+ # attribute below
+ cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
+
+ # make sure it subclasses multilingual.ModelAdmin
+ if not issubclass(cls, ModelAdmin):
+ raise ValueError, ("%s must be registered with a subclass of "
+ + " of multilingual.ModelAdmin.") % model
+
+ # if the inlines already contain a class for the
+ # translation model, use it and don't create another one
+ translation_modeladmin = None
+ for inline in getattr(cls, 'inlines', []):
+ if inline.model == model._meta.translation_model:
+ translation_modeladmin = inline
+
+ if not translation_modeladmin:
+ translation_modeladmin = get_translation_modeladmin(cls, model)
+ if cls.inlines:
+ cls.inlines.insert(0, translation_modeladmin)
+ else:
+ cls.inlines = [translation_modeladmin]
+ return admin.ModelAdmin._original_new_before_dm(cls, model, admin_site, obj)
+
+def install_multilingual_modeladmin_new():
+ """
+ Override ModelAdmin.__new__ to create automatic inline
+ editor for multilingual models.
+ """
+ admin.ModelAdmin._original_new_before_dm = ModelAdmin.__new__
+ admin.ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
+
diff --git a/multilingual/flatpages/admin.py b/multilingual/flatpages/admin.py
index 81de9c5..5e70ad1 100644
--- a/multilingual/flatpages/admin.py
+++ b/multilingual/flatpages/admin.py
@@ -1,13 +1,14 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from multilingual.flatpages.models import MultilingualFlatPage
+import multilingual
-class MultilingualFlatPageAdmin(admin.ModelAdmin):
+class MultilingualFlatPageAdmin(multilingual.ModelAdmin):
fieldsets = (
(None, {'fields': ('url', 'sites')}),
(_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
)
list_filter = ('sites',)
search_fields = ('url', 'title')
admin.site.register(MultilingualFlatPage, MultilingualFlatPageAdmin)
diff --git a/multilingual/translation.py b/multilingual/translation.py
index 43967b6..4df3886 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,408 +1,362 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
-from django.contrib.admin import StackedInline, ModelAdmin
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
+from multilingual.admin import install_multilingual_modeladmin_new
from new import instancemethod
-class TranslationModelAdmin(StackedInline):
- template = "admin/edit_inline_translations_newforms.html"
-
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def translation_overwrite_previous(instance, **kwargs):
"""
Delete previously existing translation with the same master and
language_id values. To be called by translation model's pre_save
signal.
This most probably means I am abusing something here trying to use
Django inline editor. Oh well, it will have to go anyway when we
move to newforms.
"""
qs = instance.__class__.objects
try:
qs = qs.filter(master=instance.master).filter(language_id=instance.language_id)
qs.delete()
except ObjectDoesNotExist:
# We are probably loading a fixture that defines translation entities
# before their master entity.
pass
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None):
try:
return getattr(self.get_translation(language_id_or_code), field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False):
"""
Get a translation instance for the given language_id_or_code.
If it does not exist, either create one or raise the
TranslationDoesNotExist exception, depending on the
create_if_necessary argument.
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id not in self._translation_cache:
if not create_if_necessary:
raise TranslationDoesNotExist(language_id)
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return self._translation_cache.get(language_id, None)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
# connect the pre_save signal on translation class to a
# function removing previous translation entries.
signals.pre_save.connect(translation_overwrite_previous,
sender=trans_model, weak=False)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
# Install a hack to let add_multilingual_manipulators know
# this is a translatable model (TODO: manipulators gone)
attrs['is_translation_model'] = lambda self: True
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
- # Override ModelAdmin.__new__ to create automatic inline
- # editor for multilingual models.
- _old_admin_new = ModelAdmin.__new__
-
- def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
- #TODO: is this check really necessary?
- if isinstance(model.objects, manager.Manager):
- # Don't change ModelAdmin.inlines
- # If our model is being registered with this base class,
- # then subclass it before changing its inlines attribute
- if cls is ModelAdmin:
- cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
-
- # if the inlines already contain a class for the
- # translation model, use it and don't create another one
- translation_modeladmin = None
- for inline in getattr(cls, 'inlines', []):
- if inline.model == model._meta.translation_model:
- translation_modeladmin = inline
-
- if not translation_modeladmin:
- translation_modeladmin = cls.get_translation_modeladmin(model)
- if cls.inlines:
- cls.inlines.insert(0, translation_modeladmin)
- else:
- cls.inlines = [translation_modeladmin]
- return _old_admin_new(cls, model, admin_site, obj)
-
- def get_translation_modeladmin(cls, model):
- if hasattr(cls, 'Translation'):
- tr_cls = cls.Translation
- if not issubclass(tr_cls, TranslationModelAdmin):
- raise ValueError, ("%s.Translation must be a subclass "
- + " of multilingual.TranslationModelAdmin.") % cls.name
- else:
- tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
- tr_cls.model = model._meta.translation_model
- tr_cls.fk_name = 'master'
- tr_cls.extra = get_language_count()
- tr_cls.max_num = get_language_count()
- return tr_cls
-
- ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
- ModelAdmin.get_translation_modeladmin = classmethod(get_translation_modeladmin)
+ install_multilingual_modeladmin_new()
# install the library
install_translation_library()
diff --git a/testproject/articles/admin.py b/testproject/articles/admin.py
index d256756..dc17388 100644
--- a/testproject/articles/admin.py
+++ b/testproject/articles/admin.py
@@ -1,22 +1,22 @@
from django import forms
from django.contrib import admin
-from multilingual import translation
from articles import models
+import multilingual
-class CategoryAdmin(admin.ModelAdmin):
+class CategoryAdmin(multilingual.ModelAdmin):
# Field names would just work here, but if you need
# correct list headers (from field.verbose_name) you have to
# use the get_'field_name' functions here.
list_display = ('id', 'creator', 'created', 'name', 'description')
search_fields = ('name', 'description')
-class ArticleAdmin(admin.ModelAdmin):
- class Translation(translation.TranslationModelAdmin):
+class ArticleAdmin(multilingual.ModelAdmin):
+ class Translation(multilingual.TranslationModelAdmin):
def formfield_for_dbfield(self, db_field, **kwargs):
- field = super(translation.TranslationModelAdmin, self).formfield_for_dbfield(db_field, **kwargs)
+ field = super(multilingual.TranslationModelAdmin, self).formfield_for_dbfield(db_field, **kwargs)
if db_field.name == 'contents':
field.widget = forms.Textarea(attrs={'cols': 50})
return field
admin.site.register(models.Article, ArticleAdmin)
admin.site.register(models.Category, CategoryAdmin)
diff --git a/testproject/issue_23/__init__.py b/testproject/issue_23/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/testproject/issue_23/admin.py b/testproject/issue_23/admin.py
new file mode 100644
index 0000000..69bd82a
--- /dev/null
+++ b/testproject/issue_23/admin.py
@@ -0,0 +1,14 @@
+from django.contrib import admin
+from testproject.issue_23.models import ArticleWithSlug
+import multilingual
+from multilingual.languages import get_language_count
+
+class TranslationAdmin(multilingual.TranslationModelAdmin):
+# prepopulated_fields = {'slug_local': ('title',)}
+ model = ArticleWithSlug._meta.translation_model
+
+class ArticleWithSlugAdmin(multilingual.ModelAdmin):
+ inlines = [TranslationAdmin]
+ prepopulated_fields = {'slug_global': ('title_en',)}
+
+admin.site.register(ArticleWithSlug, ArticleWithSlugAdmin)
diff --git a/testproject/issue_23/models.py b/testproject/issue_23/models.py
new file mode 100644
index 0000000..33af1a1
--- /dev/null
+++ b/testproject/issue_23/models.py
@@ -0,0 +1,10 @@
+from django.db import models
+import multilingual
+
+class ArticleWithSlug(models.Model):
+ slug_global = models.SlugField(blank=True, null=False)
+
+ class Translation(multilingual.Translation):
+ title = models.CharField(blank=True, null=False, max_length=250)
+ contents = models.TextField(blank=True, null=False)
+ slug_local = models.SlugField(blank=True, null=False)
diff --git a/testproject/issue_23/tests.py b/testproject/issue_23/tests.py
new file mode 100644
index 0000000..dc64e7c
--- /dev/null
+++ b/testproject/issue_23/tests.py
@@ -0,0 +1,9 @@
+from django.contrib.auth.models import User
+from testproject.utils import AdminTestCase
+
+class TestIssue23(AdminTestCase):
+ def test_issue_23(self):
+ # the next line failed with "Key 'title_en' not found in Form"
+ resp = self.client.get('/admin/issue_23/articlewithslug/add/')
+ self.assertEqual(resp.status_code, 200)
+
diff --git a/testproject/settings.py b/testproject/settings.py
index 2925720..8546512 100644
--- a/testproject/settings.py
+++ b/testproject/settings.py
@@ -1,110 +1,111 @@
# Django settings for testproject project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'database.db3' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en'
# django-multilanguange #####################
# It is important that the language identifiers are consecutive
# numbers starting with 1.
LANGUAGES = [['en', 'English'], # id=1
['pl', 'Polish'], # id=2
['zh-cn', 'Simplified Chinese'], # id=3
]
DEFAULT_LANGUAGE = 1
##############################################
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '1+t11&r9nw+d7uw558+8=#j8!8^$nt97ecgv()-@x!tcef7f6)'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'multilingual.flatpages.middleware.FlatpageFallbackMiddleware',
)
ROOT_URLCONF = 'testproject.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'../multilingual/templates/',
'templates/',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'multilingual',
'multilingual.flatpages',
'testproject.articles',
'testproject.issue_15',
'testproject.issue_16',
+ 'testproject.issue_23',
'testproject.issue_29',
'testproject.issue_37',
'testproject.issue_61',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'multilingual.context_processors.multilingual',
)
|
stefanfoulis/django-multilingual
|
3647cad0e00295ba451a6adf75f84ce9e74b2c50
|
Added a generic AdminTestCase to make it simpler to test stuff in the
|
diff --git a/testproject/issue_61/tests.py b/testproject/issue_61/tests.py
index 9fe4077..003f291 100644
--- a/testproject/issue_61/tests.py
+++ b/testproject/issue_61/tests.py
@@ -1,20 +1,10 @@
-from django.contrib.auth.models import User
-from django.test import TestCase
+from testproject.utils import AdminTestCase
-class TestIssue61(TestCase):
- def setUp(self):
- self.user = User.objects.get_or_create(username='admin',
- email='[email protected]')[0]
- self.user.set_password('admin')
- self.user.is_staff = True
- self.user.is_superuser = True
- self.user.save()
-
+class TestIssue61(AdminTestCase):
def test_the_issue(self):
- self.client.login(username = 'admin', password = 'admin')
resp = self.client.get('/admin/issue_61/othermodel/')
self.assertEqual(resp.status_code, 200)
# the next line failed in #61
resp = self.client.get('/admin/issue_61/othermodel/add/')
self.assertEqual(resp.status_code, 200)
diff --git a/testproject/utils.py b/testproject/utils.py
index 196ffc8..0e9cf9d 100644
--- a/testproject/utils.py
+++ b/testproject/utils.py
@@ -1,15 +1,34 @@
+from django.test import TestCase
+from django.contrib.auth.models import User
+
+class AdminTestCase(TestCase):
+ """
+ A base class for test cases that need to access the admin
+ interface.
+
+ All it does is logging in as a superuser in setUp.
+ """
+ def setUp(self):
+ self.user = User.objects.get_or_create(username='admin',
+ email='[email protected]')[0]
+ self.user.set_password('admin')
+ self.user.is_staff = True
+ self.user.is_superuser = True
+ self.user.save()
+ self.client.login(username = 'admin', password = 'admin')
+
def to_str(arg):
"""
Convert all unicode strings in a structure into 'str' strings.
Utility function to make it easier to write tests for both
unicode and non-unicode Django.
"""
if type(arg) == list:
return [to_str(el) for el in arg]
elif type(arg) == tuple:
return tuple([to_str(el) for el in arg])
elif arg is None:
return None
else:
return str(arg)
|
stefanfoulis/django-multilingual
|
4379b87bdfce20cf5e6b36d9b2a3439af9ba7f83
|
Changed the way DM handles inline editor classes so that it is
|
diff --git a/multilingual/translation.py b/multilingual/translation.py
index 6b2f528..43967b6 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,403 +1,408 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
from django.contrib.admin import StackedInline, ModelAdmin
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from new import instancemethod
class TranslationModelAdmin(StackedInline):
template = "admin/edit_inline_translations_newforms.html"
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def translation_overwrite_previous(instance, **kwargs):
"""
Delete previously existing translation with the same master and
language_id values. To be called by translation model's pre_save
signal.
This most probably means I am abusing something here trying to use
Django inline editor. Oh well, it will have to go anyway when we
move to newforms.
"""
qs = instance.__class__.objects
try:
qs = qs.filter(master=instance.master).filter(language_id=instance.language_id)
qs.delete()
except ObjectDoesNotExist:
# We are probably loading a fixture that defines translation entities
# before their master entity.
pass
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None):
try:
return getattr(self.get_translation(language_id_or_code), field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False):
"""
Get a translation instance for the given language_id_or_code.
If it does not exist, either create one or raise the
TranslationDoesNotExist exception, depending on the
create_if_necessary argument.
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id not in self._translation_cache:
if not create_if_necessary:
raise TranslationDoesNotExist(language_id)
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return self._translation_cache.get(language_id, None)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
# connect the pre_save signal on translation class to a
# function removing previous translation entries.
signals.pre_save.connect(translation_overwrite_previous,
sender=trans_model, weak=False)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
# Install a hack to let add_multilingual_manipulators know
# this is a translatable model (TODO: manipulators gone)
attrs['is_translation_model'] = lambda self: True
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
# Override ModelAdmin.__new__ to create automatic inline
# editor for multilingual models.
_old_admin_new = ModelAdmin.__new__
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
#TODO: is this check really necessary?
if isinstance(model.objects, manager.Manager):
# Don't change ModelAdmin.inlines
# If our model is being registered with this base class,
# then subclass it before changing its inlines attribute
if cls is ModelAdmin:
cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
- X = cls.get_translation_modeladmin(model)
- if cls.inlines:
- for inline in cls.inlines:
- if X.__name__ == inline.__name__:
- cls.inlines.remove(inline)
- break
- cls.inlines.append(X)
- else:
- cls.inlines = [X]
+
+ # if the inlines already contain a class for the
+ # translation model, use it and don't create another one
+ translation_modeladmin = None
+ for inline in getattr(cls, 'inlines', []):
+ if inline.model == model._meta.translation_model:
+ translation_modeladmin = inline
+
+ if not translation_modeladmin:
+ translation_modeladmin = cls.get_translation_modeladmin(model)
+ if cls.inlines:
+ cls.inlines.insert(0, translation_modeladmin)
+ else:
+ cls.inlines = [translation_modeladmin]
return _old_admin_new(cls, model, admin_site, obj)
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
tr_cls.fk_name = 'master'
tr_cls.extra = get_language_count()
tr_cls.max_num = get_language_count()
return tr_cls
ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
ModelAdmin.get_translation_modeladmin = classmethod(get_translation_modeladmin)
# install the library
install_translation_library()
|
stefanfoulis/django-multilingual
|
0740c6fdcd96ef6c992a26e48fcc3f7763b56147
|
Fixing issues #61 and #76. Patch provided by jdemoor - thanks!
|
diff --git a/multilingual/translation.py b/multilingual/translation.py
index fdce7fc..6b2f528 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,398 +1,403 @@
"""
Support for models' internal Translation class.
"""
##TODO: this is messy and needs to be cleaned up
from django.contrib.admin import StackedInline, ModelAdmin
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from new import instancemethod
class TranslationModelAdmin(StackedInline):
template = "admin/edit_inline_translations_newforms.html"
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def translation_overwrite_previous(instance, **kwargs):
"""
Delete previously existing translation with the same master and
language_id values. To be called by translation model's pre_save
signal.
This most probably means I am abusing something here trying to use
Django inline editor. Oh well, it will have to go anyway when we
move to newforms.
"""
qs = instance.__class__.objects
try:
qs = qs.filter(master=instance.master).filter(language_id=instance.language_id)
qs.delete()
except ObjectDoesNotExist:
# We are probably loading a fixture that defines translation entities
# before their master entity.
pass
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None):
try:
return getattr(self.get_translation(language_id_or_code), field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False):
"""
Get a translation instance for the given language_id_or_code.
If it does not exist, either create one or raise the
TranslationDoesNotExist exception, depending on the
create_if_necessary argument.
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id not in self._translation_cache:
if not create_if_necessary:
raise TranslationDoesNotExist(language_id)
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return self._translation_cache.get(language_id, None)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
# connect the pre_save signal on translation class to a
# function removing previous translation entries.
signals.pre_save.connect(translation_overwrite_previous,
sender=trans_model, weak=False)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
# Install a hack to let add_multilingual_manipulators know
# this is a translatable model (TODO: manipulators gone)
attrs['is_translation_model'] = lambda self: True
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
# Override ModelAdmin.__new__ to create automatic inline
# editor for multilingual models.
_old_admin_new = ModelAdmin.__new__
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
#TODO: is this check really necessary?
if isinstance(model.objects, manager.Manager):
+ # Don't change ModelAdmin.inlines
+ # If our model is being registered with this base class,
+ # then subclass it before changing its inlines attribute
+ if cls is ModelAdmin:
+ cls = type("%sAdmin" % model.__name__, (ModelAdmin,), {})
X = cls.get_translation_modeladmin(model)
if cls.inlines:
for inline in cls.inlines:
if X.__name__ == inline.__name__:
cls.inlines.remove(inline)
break
cls.inlines.append(X)
else:
cls.inlines = [X]
return _old_admin_new(cls, model, admin_site, obj)
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
tr_cls.fk_name = 'master'
tr_cls.extra = get_language_count()
tr_cls.max_num = get_language_count()
return tr_cls
ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
ModelAdmin.get_translation_modeladmin = classmethod(get_translation_modeladmin)
# install the library
install_translation_library()
diff --git a/testproject/issue_61/__init__.py b/testproject/issue_61/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/testproject/issue_61/admin.py b/testproject/issue_61/admin.py
new file mode 100644
index 0000000..b09bbff
--- /dev/null
+++ b/testproject/issue_61/admin.py
@@ -0,0 +1,5 @@
+from django.contrib import admin
+from issue_61.models import Category, OtherModel
+
+admin.site.register(Category)
+admin.site.register(OtherModel)
diff --git a/testproject/issue_61/models.py b/testproject/issue_61/models.py
new file mode 100644
index 0000000..877fef4
--- /dev/null
+++ b/testproject/issue_61/models.py
@@ -0,0 +1,11 @@
+from django.db import models
+import multilingual
+
+class Category(models.Model):
+ created = models.DateTimeField(auto_now_add=True)
+
+ class Translation(multilingual.Translation):
+ name = models.CharField(max_length=250)
+
+class OtherModel(models.Model):
+ name = models.CharField(max_length=250)
diff --git a/testproject/issue_61/tests.py b/testproject/issue_61/tests.py
new file mode 100644
index 0000000..9fe4077
--- /dev/null
+++ b/testproject/issue_61/tests.py
@@ -0,0 +1,20 @@
+from django.contrib.auth.models import User
+from django.test import TestCase
+
+class TestIssue61(TestCase):
+ def setUp(self):
+ self.user = User.objects.get_or_create(username='admin',
+ email='[email protected]')[0]
+ self.user.set_password('admin')
+ self.user.is_staff = True
+ self.user.is_superuser = True
+ self.user.save()
+
+ def test_the_issue(self):
+ self.client.login(username = 'admin', password = 'admin')
+ resp = self.client.get('/admin/issue_61/othermodel/')
+ self.assertEqual(resp.status_code, 200)
+
+ # the next line failed in #61
+ resp = self.client.get('/admin/issue_61/othermodel/add/')
+ self.assertEqual(resp.status_code, 200)
diff --git a/testproject/settings.py b/testproject/settings.py
index 0875468..2925720 100644
--- a/testproject/settings.py
+++ b/testproject/settings.py
@@ -1,109 +1,110 @@
# Django settings for testproject project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'database.db3' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en'
# django-multilanguange #####################
# It is important that the language identifiers are consecutive
# numbers starting with 1.
LANGUAGES = [['en', 'English'], # id=1
['pl', 'Polish'], # id=2
['zh-cn', 'Simplified Chinese'], # id=3
]
DEFAULT_LANGUAGE = 1
##############################################
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '1+t11&r9nw+d7uw558+8=#j8!8^$nt97ecgv()-@x!tcef7f6)'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'multilingual.flatpages.middleware.FlatpageFallbackMiddleware',
)
ROOT_URLCONF = 'testproject.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'../multilingual/templates/',
'templates/',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'multilingual',
'multilingual.flatpages',
'testproject.articles',
'testproject.issue_15',
'testproject.issue_16',
'testproject.issue_29',
'testproject.issue_37',
+ 'testproject.issue_61',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'multilingual.context_processors.multilingual',
)
|
stefanfoulis/django-multilingual
|
03fac695135b308ed3a33dcbfcfcd1d74154fea3
|
Fixed a mistake in initial_data.xml fixture: it was referencing a model by its db_table instead of by module name.
|
diff --git a/testproject/articles/fixtures/initial_data.xml b/testproject/articles/fixtures/initial_data.xml
index 9207906..830569a 100644
--- a/testproject/articles/fixtures/initial_data.xml
+++ b/testproject/articles/fixtures/initial_data.xml
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0">
- <object pk="1" model="articles.category_language">
+ <object pk="1" model="articles.categorytranslation">
<field type="CharField" name="name">Fixture category</field>
<field type="TextField" name="description">Fixture category description</field>
<field type="IntegerField" name="language_id">1</field>
<field to="articles.category" name="master" rel="ManyToOneRel">1</field>
</object>
- <object pk="2" model="articles.category_language">
+ <object pk="2" model="articles.categorytranslation">
<field type="CharField" name="name">Fixture kategoria</field>
<field type="TextField" name="description">Fixture kategoria opis</field>
<field type="IntegerField" name="language_id">2</field>
<field to="articles.category" name="master" rel="ManyToOneRel">1</field>
</object>
<object pk="1" model="articles.category">
<field to="auth.user" name="creator" rel="ManyToOneRel">1</field>
<field type="DateTimeField" name="created">2007-05-04 16:45:29</field>
<field to="articles.category" name="parent" rel="ManyToOneRel"><None></None></field>
</object>
</django-objects>
|
stefanfoulis/django-multilingual
|
dab30c0e23683e02a13b6857b0662e0727ba3dfb
|
Fixed flatpages middleware to use request.path_info instead of request.path.
|
diff --git a/multilingual/flatpages/middleware.py b/multilingual/flatpages/middleware.py
index fdd6a4a..25c6533 100644
--- a/multilingual/flatpages/middleware.py
+++ b/multilingual/flatpages/middleware.py
@@ -1,18 +1,18 @@
from multilingual.flatpages.views import multilingual_flatpage
from django.http import Http404
from django.conf import settings
class FlatpageFallbackMiddleware(object):
def process_response(self, request, response):
if response.status_code != 404:
return response # No need to check for a flatpage for non-404 responses.
try:
- return multilingual_flatpage(request, request.path)
+ return multilingual_flatpage(request, request.path_info)
# Return the original response if any errors happened. Because this
# is a middleware, we can't assume the errors will be caught elsewhere.
except Http404:
return response
except:
if settings.DEBUG:
raise
return response
|
stefanfoulis/django-multilingual
|
2c77083623ec5d3dba38bd1aab75801b391d2ab7
|
No functional changes. Set eol-style to native. Fixed-up whitespace. Patch from Florian Sening.
|
diff --git a/multilingual/__init__.py b/multilingual/__init__.py
index cb21d5a..ed6a5b6 100644
--- a/multilingual/__init__.py
+++ b/multilingual/__init__.py
@@ -1,10 +1,9 @@
"""
Django-multilingual: multilingual model support for Django.
"""
from multilingual import models
from multilingual.exceptions import TranslationDoesNotExist, LanguageDoesNotExist
from multilingual.languages import set_default_language, get_default_language, get_language_code_list
from multilingual.translation import Translation
from multilingual.manager import Manager
-
diff --git a/multilingual/flatpages/admin.py b/multilingual/flatpages/admin.py
index 5ac0ccd..81de9c5 100644
--- a/multilingual/flatpages/admin.py
+++ b/multilingual/flatpages/admin.py
@@ -1,14 +1,13 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from multilingual.flatpages.models import MultilingualFlatPage
class MultilingualFlatPageAdmin(admin.ModelAdmin):
fieldsets = (
(None, {'fields': ('url', 'sites')}),
(_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
)
list_filter = ('sites',)
search_fields = ('url', 'title')
admin.site.register(MultilingualFlatPage, MultilingualFlatPageAdmin)
-
diff --git a/multilingual/flatpages/models.py b/multilingual/flatpages/models.py
index 10201b5..12a9a1b 100644
--- a/multilingual/flatpages/models.py
+++ b/multilingual/flatpages/models.py
@@ -1,51 +1,48 @@
from django.db import models
from django.contrib.sites.models import Site
import multilingual
from django.utils.translation import ugettext as _
class MultilingualFlatPage(models.Model):
# non-translatable fields first
url = models.CharField(_('URL'), max_length=100, db_index=True,
help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes."))
enable_comments = models.BooleanField(_('enable comments'))
template_name = models.CharField(_('template name'), max_length=70, blank=True,
help_text=_("Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'."))
registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page."))
sites = models.ManyToManyField(Site)
-
-
# And now the translatable fields
class Translation(multilingual.Translation):
"""
The definition of translation model.
The multilingual machinery will automatically add these to the
Category class:
* get_title(language_id=None)
* set_title(value, language_id=None)
* get_content(language_id=None)
* set_content(value, language_id=None)
* title and content properties using the methods above
"""
title = models.CharField(_('title'), max_length=200)
content = models.TextField(_('content'))
-
+
class Meta:
db_table = 'multilingual_flatpage'
verbose_name = _('multilingual flat page')
verbose_name_plural = _('multilingual flat pages')
ordering = ('url',)
def __unicode__(self):
# note that you can use name and description fields as usual
try:
return u"%s -- %s" % (self.url, self.title)
except multilingual.TranslationDoesNotExist:
return u"-not-available-"
def get_absolute_url(self):
return self.url
-
diff --git a/multilingual/flatpages/urls.py b/multilingual/flatpages/urls.py
index c7efda8..8710c81 100644
--- a/multilingual/flatpages/urls.py
+++ b/multilingual/flatpages/urls.py
@@ -1,7 +1,6 @@
from django.conf.urls.defaults import *
from multilingual.flatpages.views import *
urlpatterns = patterns('',
url(r'^(?P<url>.*)$', MultilingualFlatPage , name="multilingual_flatpage"),
)
-
diff --git a/multilingual/flatpages/views.py b/multilingual/flatpages/views.py
index f7f7d11..25dc602 100644
--- a/multilingual/flatpages/views.py
+++ b/multilingual/flatpages/views.py
@@ -1,53 +1,52 @@
from multilingual.flatpages.models import MultilingualFlatPage
from django.template import loader, RequestContext
from django.shortcuts import get_object_or_404
from django.http import HttpResponse
from django.conf import settings
from django.core.xheaders import populate_xheaders
from django.utils.translation import get_language
import multilingual
from django.utils.safestring import mark_safe
DEFAULT_TEMPLATE = 'flatpages/default.html'
def multilingual_flatpage(request, url):
"""
Multilingual flat page view.
Models: `multilingual.flatpages.models`
Templates: Uses the template defined by the ``template_name`` field,
or `flatpages/default.html` if template_name is not defined.
Context:
flatpage
`flatpages.flatpages` object
"""
if not url.startswith('/'):
url = "/" + url
f = get_object_or_404(MultilingualFlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
# If registration is required for accessing this page, and the user isn't
# logged in, redirect to the login page.
if f.registration_required and not request.user.is_authenticated():
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(request.path)
#Serve the content in the language defined by the Django translation module
#if possible else serve the default language
f._default_language = multilingual.languages.get_language_id_from_id_or_code(get_language())
if f.template_name:
t = loader.select_template((f.template_name, DEFAULT_TEMPLATE))
else:
t = loader.get_template(DEFAULT_TEMPLATE)
# To avoid having to always use the "|safe" filter in flatpage templates,
# mark the title and content as already safe (since they are raw HTML
# content in the first place).
f.title = mark_safe(f.title)
f.content = mark_safe(f.content)
c = RequestContext(request, {
'flatpage': f,
})
response = HttpResponse(t.render(c))
populate_xheaders(request, response, MultilingualFlatPage, f.id)
return response
-
diff --git a/multilingual/languages.py b/multilingual/languages.py
index 99a9d7a..2fe79de 100644
--- a/multilingual/languages.py
+++ b/multilingual/languages.py
@@ -1,118 +1,117 @@
"""
Django-multilingual: language-related settings and functions.
"""
# Note: this file did become a mess and will have to be refactored
# after the configuration changes get in place.
#retrieve language settings from settings.py
from django.conf import settings
LANGUAGES = settings.LANGUAGES
from django.utils.translation import ugettext_lazy as _
from multilingual.exceptions import LanguageDoesNotExist
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
thread_locals = local()
def get_language_count():
return len(LANGUAGES)
def get_language_code(language_id):
return LANGUAGES[(int(language_id or get_default_language())) - 1][0]
def get_language_name(language_id):
return _(LANGUAGES[(int(language_id or get_default_language())) - 1][1])
def get_language_bidi(language_id):
return get_language_code(language_id) in settings.LANGUAGES_BIDI
def get_language_id_list():
return range(1, get_language_count() + 1)
def get_language_code_list():
return [lang[0] for lang in LANGUAGES]
def get_language_choices():
return [(language_id, get_language_code(language_id))
for language_id in get_language_id_list()]
def get_language_id_from_id_or_code(language_id_or_code, use_default=True):
if language_id_or_code is None:
if use_default:
return get_default_language()
else:
return None
if isinstance(language_id_or_code, int):
return language_id_or_code
i = 0
for (code, desc) in LANGUAGES:
i += 1
if code == language_id_or_code:
return i
if language_id_or_code.startswith("%s-" % code):
return i
raise LanguageDoesNotExist(language_id_or_code)
def get_language_idx(language_id_or_code):
# to do: optimize
language_id = get_language_id_from_id_or_code(language_id_or_code)
return get_language_id_list().index(language_id)
def set_default_language(language_id_or_code):
"""
Set the default language for the whole translation mechanism.
Accepts language codes or IDs.
"""
language_id = get_language_id_from_id_or_code(language_id_or_code)
thread_locals.DEFAULT_LANGUAGE = language_id
def get_default_language():
"""
Return the language ID set by set_default_language.
"""
return getattr(thread_locals, 'DEFAULT_LANGUAGE',
settings.DEFAULT_LANGUAGE)
def get_default_language_code():
"""
Return the language code of language ID set by set_default_language.
"""
language_id = get_language_id_from_id_or_code(get_default_language())
return get_language_code(language_id)
def _to_db_identifier(name):
"""
Convert name to something that is usable as a field name or table
alias in SQL.
For the time being assume that the only possible problem with name
is the presence of dashes.
"""
return name.replace('-', '_')
def get_translation_table_alias(translation_table_name, language_id):
"""
Return an alias for the translation table for a given language_id.
Used in SQL queries.
"""
return (translation_table_name
+ '_'
+ _to_db_identifier(get_language_code(language_id)))
def get_translated_field_alias(field_name, language_id=None):
"""
Return an alias for field_name field for a given language_id.
Used in SQL queries.
"""
return ('_trans_'
+ field_name
+ '_' + _to_db_identifier(get_language_code(language_id)))
-
diff --git a/multilingual/manager.py b/multilingual/manager.py
index a5c29ef..c073d5a 100644
--- a/multilingual/manager.py
+++ b/multilingual/manager.py
@@ -1,16 +1,15 @@
from django.db import models
from multilingual.query import MultilingualModelQuerySet
from multilingual.languages import *
class Manager(models.Manager):
"""
A manager for multilingual models.
TO DO: turn this into a proxy manager that would allow developers
to use any manager they need. It should be sufficient to extend
and additionaly filter or order querysets returned by that manager.
"""
def get_query_set(self):
return MultilingualModelQuerySet(self.model)
-
diff --git a/multilingual/query.py b/multilingual/query.py
index 7a41800..c699321 100644
--- a/multilingual/query.py
+++ b/multilingual/query.py
@@ -1,529 +1,528 @@
"""
Django-multilingual: a QuerySet subclass for models with translatable
fields.
This file contains the implementation for QSRF Django.
"""
import datetime
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models.fields import FieldDoesNotExist
from django.db.models.query import QuerySet, Q
from django.db.models.sql.query import Query
from django.db.models.sql.datastructures import Count, EmptyResultSet, Empty, MultiJoin
from django.db.models.sql.constants import *
from django.db.models.sql.where import WhereNode, EverythingNode, AND, OR
from multilingual.languages import (get_translation_table_alias, get_language_id_list,
get_default_language, get_translated_field_alias,
get_language_id_from_id_or_code)
__ALL__ = ['MultilingualModelQuerySet']
class MultilingualQuery(Query):
def __init__(self, model, connection, where=WhereNode):
self.extra_join = {}
extra_select = {}
super(MultilingualQuery, self).__init__(model, connection, where=where)
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
for language_id in get_language_id_list():
for fname in [f.attname for f in translation_opts.fields]:
table_alias = get_translation_table_alias(trans_table_name,
language_id)
field_alias = get_translated_field_alias(fname,
language_id)
extra_select[field_alias] = qn2(table_alias) + '.' + qn2(fname)
self.add_extra(extra_select, None,None,None,None,None)
def clone(self, klass=None, **kwargs):
obj = super(MultilingualQuery, self).clone(klass=klass, **kwargs)
obj.extra_join = self.extra_join
return obj
def pre_sql_setup(self):
"""Adds the JOINS and SELECTS for fetching multilingual data.
"""
super(MultilingualQuery, self).pre_sql_setup()
opts = self.model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
if hasattr(opts, 'translation_model'):
master_table_name = opts.db_table
translation_opts = opts.translation_model._meta
trans_table_name = translation_opts.db_table
for language_id in get_language_id_list():
table_alias = get_translation_table_alias(trans_table_name,
language_id)
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(translation_opts.db_table),
qn2(table_alias),
qn2(table_alias),
qn(master_table_name),
qn2(self.model._meta.pk.column),
qn2(table_alias),
language_id))
self.extra_join[table_alias] = trans_join
def get_from_clause(self):
"""Add the JOINS for related multilingual fields filtering.
"""
result = super(MultilingualQuery, self).get_from_clause()
from_ = result[0]
for join in self.extra_join.values():
from_.append(join)
return (from_, result[1])
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None, process_extras=True):
"""Copied from add_filter to generate WHERES for translation fields.
"""
arg, value = filter_expr
parts = arg.split(LOOKUP_SEP)
if not parts:
raise FieldError("Cannot parse keyword query %r" % arg)
# Work out the lookup type and remove it from 'parts', if necessary.
if len(parts) == 1 or parts[-1] not in self.query_terms:
lookup_type = 'exact'
else:
lookup_type = parts.pop()
# Interpret '__exact=None' as the sql 'is NULL'; otherwise, reject all
# uses of None as a query value.
if value is None:
if lookup_type != 'exact':
raise ValueError("Cannot use None as a query value")
lookup_type = 'isnull'
value = True
elif (value == '' and lookup_type == 'exact' and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value = True
elif callable(value):
value = value()
opts = self.get_meta()
alias = self.get_initial_alias()
allow_many = trim or not negate
-
+
try:
field, target, opts, join_list, last, extra_filters = self.setup_joins(
parts, opts, alias, True, allow_many, can_reuse=can_reuse,
negate=negate, process_extras=process_extras)
except MultiJoin, e:
self.split_exclude(filter_expr, LOOKUP_SEP.join(parts[:e.level]),
can_reuse)
return
#NOTE: here comes Django Multilingual
if hasattr(opts, 'translation_model'):
field_name = parts[-1]
if field_name == 'pk':
field_name = opts.pk.name
translation_opts = opts.translation_model._meta
if field_name in translation_opts.translated_fields.keys():
field, model, direct, m2m = opts.get_field_by_name(field_name)
if model == opts.translation_model:
language_id = translation_opts.translated_fields[field_name][1]
if language_id is None:
language_id = get_default_language()
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
self.where.add((new_table, field.column, field, lookup_type, value), connector)
return
final = len(join_list)
penultimate = last.pop()
if penultimate == final:
penultimate = last.pop()
if trim and len(join_list) > 1:
extra = join_list[penultimate:]
join_list = join_list[:penultimate]
final = penultimate
penultimate = last.pop()
col = self.alias_map[extra[0]][LHS_JOIN_COL]
for alias in extra:
self.unref_alias(alias)
else:
col = target.column
alias = join_list[-1]
while final > 1:
# An optimization: if the final join is against the same column as
# we are comparing against, we can go back one step in the join
# chain and compare against the lhs of the join instead (and then
# repeat the optimization). The result, potentially, involves less
# table joins.
join = self.alias_map[alias]
if col != join[RHS_JOIN_COL]:
break
self.unref_alias(alias)
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
join_list = join_list[:-1]
final -= 1
if final == penultimate:
penultimate = last.pop()
if (lookup_type == 'isnull' and value is True and not negate and
final > 1):
# If the comparison is against NULL, we need to use a left outer
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed as it's less
# efficient at the database level.
self.promote_alias(join_list[penultimate])
if connector == OR:
# Some joins may need to be promoted when adding a new filter to a
# disjunction. We walk the list of new joins and where it diverges
# from any previous joins (ref count is 1 in the table list), we
# make the new additions (and any existing ones not used in the new
# join list) an outer join.
join_it = iter(join_list)
table_it = iter(self.tables)
join_it.next(), table_it.next()
table_promote = False
join_promote = False
for join in join_it:
table = table_it.next()
if join == table and self.alias_refcount[join] > 1:
continue
join_promote = self.promote_alias(join)
if table != join:
table_promote = self.promote_alias(table)
break
self.promote_alias_chain(join_it, join_promote)
self.promote_alias_chain(table_it, table_promote)
self.where.add((alias, col, field, lookup_type, value), connector)
if negate:
self.promote_alias_chain(join_list)
if lookup_type != 'isnull':
if final > 1:
for alias in join_list:
if self.alias_map[alias][JOIN_TYPE] == self.LOUTER:
j_col = self.alias_map[alias][RHS_JOIN_COL]
entry = self.where_class()
entry.add((alias, j_col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
break
elif not (lookup_type == 'in' and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# it's short-circuited in the Where class.
entry = self.where_class()
entry.add((alias, col, None, 'isnull', True), AND)
entry.negate()
self.where.add(entry, AND)
if can_reuse is not None:
can_reuse.update(join_list)
if process_extras:
for filter in extra_filters:
self.add_filter(filter, negate=negate, can_reuse=can_reuse,
process_extras=False)
def _setup_joins_with_translation(self, names, opts, alias,
dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None,
negate=False, process_extras=True):
"""
This is based on a full copy of Query.setup_joins because
currently I see no way to handle it differently.
TO DO: there might actually be a way, by splitting a single
multi-name setup_joins call into separate calls. Check it.
-- [email protected]
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are joining to), 'alias' is the alias for the
table we are joining to. If dupe_multis is True, any many-to-many or
many-to-one joins will always create a new alias (necessary for
disjunctive filters).
Returns the final field involved in the join, the target database
column (used for any 'where' constraint), the final 'opts' value and the
list of tables joined.
"""
joins = [alias]
last = [0]
dupe_set = set()
exclusions = set()
extra_filters = []
for pos, name in enumerate(names):
try:
exclusions.add(int_alias)
except NameError:
pass
exclusions.add(alias)
last.append(len(joins))
if name == 'pk':
name = opts.pk.name
try:
field, model, direct, m2m = opts.get_field_by_name(name)
except FieldDoesNotExist:
for f in opts.fields:
if allow_explicit_fk and name == f.attname:
# XXX: A hack to allow foo_id to work in values() for
# backwards compatibility purposes. If we dropped that
# feature, this could be removed.
field, model, direct, m2m = opts.get_field_by_name(f.name)
break
else:
names = opts.get_all_field_names()
raise FieldError("Cannot resolve keyword %r into field. "
"Choices are: %s" % (name, ", ".join(names)))
if not allow_many and (m2m or not direct):
for alias in joins:
self.unref_alias(alias)
raise MultiJoin(pos + 1)
#NOTE: Start Django Multilingual specific code
if hasattr(opts, 'translation_model'):
translation_opts = opts.translation_model._meta
if model == opts.translation_model:
language_id = translation_opts.translated_fields[name][1]
if language_id is None:
language_id = get_default_language()
#TODO: check alias
master_table_name = opts.db_table
trans_table_alias = get_translation_table_alias(
model._meta.db_table, language_id)
new_table = (master_table_name + "__" + trans_table_alias)
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
trans_join = ('LEFT JOIN %s AS %s ON ((%s.master_id = %s.%s) AND (%s.language_id = %s))'
% (qn2(model._meta.db_table),
qn2(new_table),
qn2(new_table),
qn(master_table_name),
qn2(model._meta.pk.column),
qn2(new_table),
language_id))
self.extra_join[new_table] = trans_join
target = field
continue
#NOTE: End Django Multilingual specific code
elif model:
# The field lives on a base class of the current model.
for int_model in opts.get_base_chain(model):
lhs_col = opts.parents[int_model].column
dedupe = lhs_col in opts.duplicate_targets
if dedupe:
exclusions.update(self.dupe_avoidance.get(
(id(opts), lhs_col), ()))
dupe_set.add((opts, lhs_col))
opts = int_model._meta
alias = self.join((alias, opts.db_table, lhs_col,
opts.pk.column), exclusions=exclusions)
joins.append(alias)
exclusions.add(alias)
for (dupe_opts, dupe_col) in dupe_set:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
cached_data = opts._join_cache.get(name)
orig_opts = opts
dupe_col = direct and field.column or field.field.column
dedupe = dupe_col in opts.duplicate_targets
if dupe_set or dedupe:
if dedupe:
dupe_set.add((opts, dupe_col))
exclusions.update(self.dupe_avoidance.get((id(opts), dupe_col),
()))
if process_extras and hasattr(field, 'extra_filters'):
extra_filters.extend(field.extra_filters(names, pos, negate))
if direct:
if m2m:
# Many-to-many field defined on the current model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_column_name()
opts = field.rel.to._meta
table2 = opts.db_table
from_col2 = field.m2m_reverse_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
if int_alias == table2 and from_col2 == to_col2:
joins.append(int_alias)
alias = int_alias
else:
alias = self.join(
(int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
elif field.rel:
# One-to-one or many-to-one field
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
opts = field.rel.to._meta
target = field.rel.get_related_field()
table = opts.db_table
from_col = field.column
to_col = target.column
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
exclusions=exclusions, nullable=field.null)
joins.append(alias)
else:
# Non-relation fields.
target = field
break
else:
orig_field = field
field = field.field
if m2m:
# Many-to-many field defined on the target model.
if cached_data:
(table1, from_col1, to_col1, table2, from_col2,
to_col2, opts, target) = cached_data
else:
table1 = field.m2m_db_table()
from_col1 = opts.pk.column
to_col1 = field.m2m_reverse_name()
opts = orig_field.opts
table2 = opts.db_table
from_col2 = field.m2m_column_name()
to_col2 = opts.pk.column
target = opts.pk
orig_opts._join_cache[name] = (table1, from_col1,
to_col1, table2, from_col2, to_col2, opts,
target)
int_alias = self.join((alias, table1, from_col1, to_col1),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
alias = self.join((int_alias, table2, from_col2, to_col2),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.extend([int_alias, alias])
else:
# One-to-many field (ForeignKey defined on the target model)
if cached_data:
(table, from_col, to_col, opts, target) = cached_data
else:
local_field = opts.get_field_by_name(
field.rel.field_name)[0]
opts = orig_field.opts
table = opts.db_table
from_col = local_field.column
to_col = field.column
target = opts.pk
orig_opts._join_cache[name] = (table, from_col, to_col,
opts, target)
alias = self.join((alias, table, from_col, to_col),
dupe_multis, exclusions, nullable=True,
reuse=can_reuse)
joins.append(alias)
for (dupe_opts, dupe_col) in dupe_set:
try:
self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias)
except NameError:
self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
if pos != len(names) - 1:
raise FieldError("Join on field %r not permitted." % name)
return field, target, opts, joins, last, extra_filters
def setup_joins(self, names, opts, alias, dupe_multis, allow_many=True,
allow_explicit_fk=False, can_reuse=None, negate=False,
process_extras=True):
return self._setup_joins_with_translation(names, opts, alias, dupe_multis,
allow_many, allow_explicit_fk,
can_reuse, negate, process_extras)
class MultilingualModelQuerySet(QuerySet):
"""
A specialized QuerySet that knows how to handle translatable
fields in ordering and filtering methods.
"""
def __init__(self, model=None, query=None):
query = query or MultilingualQuery(model, connection)
super(MultilingualModelQuerySet, self).__init__(model, query)
def for_language(self, language_id_or_code):
"""
Set the default language for all objects returned with this
query.
"""
clone = self._clone()
clone._default_language = get_language_id_from_id_or_code(language_id_or_code)
return clone
def iterator(self):
"""
Add the default language information to all returned objects.
"""
default_language = getattr(self, '_default_language', None)
for obj in super(MultilingualModelQuerySet, self).iterator():
obj._default_language = default_language
yield obj
def _clone(self, klass=None, **kwargs):
"""
Override _clone to preserve additional information needed by
MultilingualModelQuerySet.
"""
clone = super(MultilingualModelQuerySet, self)._clone(klass, **kwargs)
clone._default_language = getattr(self, '_default_language', None)
return clone
def order_by(self, *field_names):
if hasattr(self.model._meta, 'translation_model'):
trans_opts = self.model._meta.translation_model._meta
new_field_names = []
for field_name in field_names:
prefix = ''
if field_name[0] == '-':
prefix = '-'
field_name = field_name[1:]
field_and_lang = trans_opts.translated_fields.get(field_name)
if field_and_lang:
field, language_id = field_and_lang
if language_id is None:
language_id = getattr(self, '_default_language', None)
real_name = get_translated_field_alias(field.attname,
language_id)
new_field_names.append(prefix + real_name)
else:
new_field_names.append(prefix + field_name)
return super(MultilingualModelQuerySet, self).extra(order_by=new_field_names)
else:
return super(MultilingualModelQuerySet, self).order_by(*field_names)
-
diff --git a/multilingual/templates/admin/fieldset.html b/multilingual/templates/admin/fieldset.html
index 9948743..ab2e9c5 100644
--- a/multilingual/templates/admin/fieldset.html
+++ b/multilingual/templates/admin/fieldset.html
@@ -1,30 +1,30 @@
{% load multilingual_tags %}
<fieldset class="module aligned {{ fieldset.classes }}">
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
{% if fieldset.description %}<div class="description">{{ fieldset.description }}</div>{% endif %}
{% for line in fieldset %}
<div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ field.field.name }} {% endfor %} ">
{{ field.name }}
{{ line.errors }}
{% for field in line %}
{{ field.field. }}
{% if field.is_checkbox %}
{{ field.field }}{{ field.label_tag }}
{% else %}
{% ifequal field.field.name "language_id" %}
<input type="hidden" name="{{ field.field.html_name }}"
value="{{ forloop.parentloop.parentloop.parentloop.counter }}" />
{% else %}
{{ field.label_tag }}
{% if forloop.parentloop.parentloop.parentloop.counter|language_bidi %}
<span style="direction: rtl; text-align: right;">{{ field.field }}</span>
{% else %}
<span style="direction: ltr; text-align: left;">{{ field.field }}</span>
{% endif %}
{% endifequal %}
{% endif %}
{% if field.field.field.help_text %}<p class="help">{{ field.field.field.help_text|safe }}</p>{% endif %}
{% endfor %}
</div>
{% endfor %}
-</fieldset>
\ No newline at end of file
+</fieldset>
diff --git a/multilingual/templatetags/multilingual_tags.py b/multilingual/templatetags/multilingual_tags.py
index 2b11f45..dd9f758 100644
--- a/multilingual/templatetags/multilingual_tags.py
+++ b/multilingual/templatetags/multilingual_tags.py
@@ -1,73 +1,71 @@
from django import template
from django import forms
from django.template import Node, NodeList, Template, Context, resolve_variable
from django.template.loader import get_template, render_to_string
from django.conf import settings
from django.utils.html import escape
from multilingual.languages import get_language_idx, get_default_language
import math
import StringIO
import tokenize
register = template.Library()
from multilingual.languages import get_language_code, get_language_name, get_language_bidi
def language_code(language_id):
"""
Return the code of the language with id=language_id
"""
return get_language_code(language_id)
register.filter(language_code)
def language_name(language_id):
"""
Return the name of the language with id=language_id
"""
return get_language_name(language_id)
register.filter(language_name)
def language_bidi(language_id):
"""
Return whether the language with id=language_id is written right-to-left.
"""
return get_language_bidi(language_id)
register.filter(language_bidi)
class EditTranslationNode(template.Node):
def __init__(self, form_name, field_name, language=None):
self.form_name = form_name
self.field_name = field_name
self.language = language
def render(self, context):
form = resolve_variable(self.form_name, context)
model = form._meta.model
trans_model = model._meta.translation_model
if self.language:
language_id = self.language.resolve(context)
else:
language_id = get_default_language()
real_name = "%s.%s.%s.%s" % (self.form_name,
trans_model._meta.object_name.lower(),
get_language_idx(language_id),
self.field_name)
return str(resolve_variable(real_name, context))
def do_edit_translation(parser, token):
bits = token.split_contents()
if len(bits) not in [3, 4]:
raise template.TemplateSyntaxError, \
"%r tag requires 3 or 4 arguments" % bits[0]
if len(bits) == 4:
language = parser.compile_filter(bits[3])
else:
language = None
return EditTranslationNode(bits[1], bits[2], language)
-
-register.tag('edit_translation', do_edit_translation)
-
+register.tag('edit_translation', do_edit_translation)
diff --git a/testproject/articles/fixtures/initial_data.xml b/testproject/articles/fixtures/initial_data.xml
index 830569a..9207906 100644
--- a/testproject/articles/fixtures/initial_data.xml
+++ b/testproject/articles/fixtures/initial_data.xml
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0">
- <object pk="1" model="articles.categorytranslation">
+ <object pk="1" model="articles.category_language">
<field type="CharField" name="name">Fixture category</field>
<field type="TextField" name="description">Fixture category description</field>
<field type="IntegerField" name="language_id">1</field>
<field to="articles.category" name="master" rel="ManyToOneRel">1</field>
</object>
- <object pk="2" model="articles.categorytranslation">
+ <object pk="2" model="articles.category_language">
<field type="CharField" name="name">Fixture kategoria</field>
<field type="TextField" name="description">Fixture kategoria opis</field>
<field type="IntegerField" name="language_id">2</field>
<field to="articles.category" name="master" rel="ManyToOneRel">1</field>
</object>
<object pk="1" model="articles.category">
<field to="auth.user" name="creator" rel="ManyToOneRel">1</field>
<field type="DateTimeField" name="created">2007-05-04 16:45:29</field>
<field to="articles.category" name="parent" rel="ManyToOneRel"><None></None></field>
</object>
</django-objects>
diff --git a/testproject/articles/models.py b/testproject/articles/models.py
index 90b3e33..48edda3 100644
--- a/testproject/articles/models.py
+++ b/testproject/articles/models.py
@@ -1,302 +1,301 @@
"""
Test models for the multilingual library.
# Note: the to_str() calls in all the tests are here only to make it
# easier to test both pre-unicode and current Django.
>>> from testproject.utils import to_str
# make sure the settings are right
>>> from multilingual.languages import LANGUAGES
>>> LANGUAGES
[['en', 'English'], ['pl', 'Polish'], ['zh-cn', 'Simplified Chinese']]
>>> from multilingual import set_default_language
>>> from django.db.models import Q
>>> set_default_language(1)
### Check the table names
>>> Category._meta.translation_model._meta.db_table
'category_language'
>>> Article._meta.translation_model._meta.db_table
'articles_article_translation'
### Create the test data
# Check both assigning via the proxy properties and set_* functions
>>> c = Category()
>>> c.name_en = 'category 1'
>>> c.name_pl = 'kategoria 1'
>>> c.save()
>>> c = Category()
>>> c.set_name('category 2', 'en')
>>> c.set_name('kategoria 2', 'pl')
>>> c.save()
### See if the test data was saved correctly
### Note: first object comes from the initial fixture.
>>> c = Category.objects.all().order_by('id')[1]
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('category 1', 'category 1', 'kategoria 1')
>>> c = Category.objects.all().order_by('id')[2]
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('category 2', 'category 2', 'kategoria 2')
### Check translation changes.
### Make sure the name and description properties obey
### set_default_language.
>>> c = Category.objects.all().order_by('id')[1]
# set language: pl
>>> set_default_language(2)
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('kategoria 1', 'category 1', 'kategoria 1')
>>> c.name = 'kat 1'
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('kat 1', 'category 1', 'kat 1')
# set language: en
>>> set_default_language('en')
>>> c.name = 'cat 1'
>>> to_str((c.name, c.get_name(1), c.get_name(2)))
('cat 1', 'cat 1', 'kat 1')
>>> c.save()
# Read the entire Category objects from the DB again to see if
# everything was saved correctly.
>>> c = Category.objects.all().order_by('id')[1]
>>> to_str((c.name, c.get_name('en'), c.get_name('pl')))
('cat 1', 'cat 1', 'kat 1')
>>> c = Category.objects.all().order_by('id')[2]
>>> to_str((c.name, c.get_name('en'), c.get_name('pl')))
('category 2', 'category 2', 'kategoria 2')
### Check ordering
>>> set_default_language(1)
>>> to_str([c.name for c in Category.objects.all().order_by('name_en')])
['Fixture category', 'cat 1', 'category 2']
### Check ordering
# start with renaming one of the categories so that the order actually
# depends on the default language
>>> set_default_language(1)
>>> c = Category.objects.get(name='cat 1')
>>> c.name = 'zzz cat 1'
>>> c.save()
>>> to_str([c.name for c in Category.objects.all().order_by('name_en')])
['Fixture category', 'category 2', 'zzz cat 1']
>>> to_str([c.name for c in Category.objects.all().order_by('name')])
['Fixture category', 'category 2', 'zzz cat 1']
>>> to_str([c.name for c in Category.objects.all().order_by('-name')])
['zzz cat 1', 'category 2', 'Fixture category']
>>> set_default_language(2)
>>> to_str([c.name for c in Category.objects.all().order_by('name')])
['Fixture kategoria', 'kat 1', 'kategoria 2']
>>> to_str([c.name for c in Category.objects.all().order_by('-name')])
['kategoria 2', 'kat 1', 'Fixture kategoria']
### Check filtering
# Check for filtering defined by Q objects as well. This is a recent
# improvement: the translation fields are being handled by an
# extension of lookup_inner instead of overridden
# QuerySet._filter_or_exclude
>>> set_default_language('en')
>>> to_str([c.name for c in Category.objects.all().filter(name__contains='2')])
['category 2']
>>> set_default_language('en')
>>> to_str([c.name for c in Category.objects.all().filter(Q(name__contains='2'))])
['category 2']
>>> set_default_language(1)
>>> to_str([c.name for c in
... Category.objects.all().filter(Q(name__contains='2')|Q(name_pl__contains='kat'))])
['Fixture category', 'zzz cat 1', 'category 2']
>>> set_default_language(1)
>>> to_str([c.name for c in Category.objects.all().filter(name_en__contains='2')])
['category 2']
>>> set_default_language(1)
>>> to_str([c.name for c in Category.objects.all().filter(Q(name_pl__contains='kat'))])
['Fixture category', 'zzz cat 1', 'category 2']
>>> set_default_language('pl')
>>> to_str([c.name for c in Category.objects.all().filter(name__contains='k')])
['Fixture kategoria', 'kat 1', 'kategoria 2']
>>> set_default_language('pl')
>>> to_str([c.name for c in Category.objects.all().filter(Q(name__contains='kategoria'))])
['Fixture kategoria', 'kategoria 2']
### Check specifying query set language
>>> c_en = Category.objects.all().for_language('en')
>>> c_pl = Category.objects.all().for_language(2) # both ID and code work here
>>> to_str(c_en.get(name__contains='1').name)
'zzz cat 1'
>>> to_str(c_pl.get(name__contains='1').name)
'kat 1'
>>> to_str([c.name for c in c_en.order_by('name')])
['Fixture category', 'category 2', 'zzz cat 1']
>>> to_str([c.name for c in c_pl.order_by('-name')])
['kategoria 2', 'kat 1', 'Fixture kategoria']
>>> c = c_en.get(id=2)
>>> c.name = 'test'
>>> to_str((c.name, c.name_en, c.name_pl))
('test', 'test', 'kat 1')
>>> c = c_pl.get(id=2)
>>> c.name = 'test'
>>> to_str((c.name, c.name_en, c.name_pl))
('test', 'zzz cat 1', 'test')
### Check filtering spanning more than one model
>>> set_default_language(1)
>>> cat_1 = Category.objects.get(name='zzz cat 1')
>>> cat_2 = Category.objects.get(name='category 2')
>>> a = Article(category=cat_1)
>>> a.set_title('article 1', 1)
>>> a.set_title('artykul 1', 2)
>>> a.set_contents('contents 1', 1)
>>> a.set_contents('zawartosc 1', 1)
>>> a.save()
>>> a = Article(category=cat_2)
>>> a.set_title('article 2', 1)
>>> a.set_title('artykul 2', 2)
>>> a.set_contents('contents 2', 1)
>>> a.set_contents('zawartosc 2', 1)
>>> a.save()
>>> to_str([a.title for a in Article.objects.filter(category=cat_1)])
['article 1']
>>> to_str([a.title for a in Article.objects.filter(category__name=cat_1.name)])
['article 1']
>>> to_str([a.title for a in Article.objects.filter(Q(category__name=cat_1.name)|Q(category__name_pl__contains='2')).order_by('-title')])
['article 2', 'article 1']
### Test the creation of new objects using keywords passed to the
### constructor
>>> set_default_language(2)
>>> c_n = Category.objects.create(name_en='new category', name_pl='nowa kategoria')
>>> to_str((c_n.name, c_n.name_en, c_n.name_pl))
('nowa kategoria', 'new category', 'nowa kategoria')
>>> c_n.save()
>>> c_n2 = Category.objects.get(name_en='new category')
>>> to_str((c_n2.name, c_n2.name_en, c_n2.name_pl))
('nowa kategoria', 'new category', 'nowa kategoria')
>>> set_default_language(2)
>>> c_n3 = Category.objects.create(name='nowa kategoria 2')
>>> to_str((c_n3.name, c_n3.name_en, c_n3.name_pl))
('nowa kategoria 2', None, 'nowa kategoria 2')
-
"""
from django.db import models
from django.contrib.auth.models import User
import multilingual
try:
from django.utils.translation import ugettext as _
except:
# if this fails then _ is a builtin
pass
class Category(models.Model):
"""
Test model for multilingual content: a simplified Category.
"""
# First, some fields that do not need translations
creator = models.ForeignKey(User, verbose_name=_("Created by"),
blank=True, null=True)
created = models.DateTimeField(verbose_name=_("Created at"),
auto_now_add=True)
parent = models.ForeignKey('self', verbose_name=_("Parent category"),
blank=True, null=True)
# And now the translatable fields
class Translation(multilingual.Translation):
"""
The definition of translation model.
The multilingual machinery will automatically add these to the
Category class:
* get_name(language_id=None)
* set_name(value, language_id=None)
* get_description(language_id=None)
* set_description(value, language_id=None)
* name and description properties using the methods above
"""
name = models.CharField(verbose_name=_("The name"),
max_length=250)
description = models.TextField(verbose_name=_("The description"),
blank=True, null=False)
- class Meta:
+ class Meta:
db_table = 'category_language'
def get_absolute_url(self):
return "/" + str(self.id) + "/"
def __unicode__(self):
# note that you can use name and description fields as usual
try:
return str(self.name)
except multilingual.TranslationDoesNotExist:
return "-not-available-"
def __str__(self):
# compatibility
return str(self.__unicode__())
class Meta:
verbose_name_plural = 'categories'
ordering = ('id',)
class CustomArticleManager(multilingual.Manager):
pass
class Article(models.Model):
"""
Test model for multilingual content: a simplified article
belonging to a single category.
"""
# non-translatable fields first
creator = models.ForeignKey(User, verbose_name=_("Created by"),
blank=True, null=True)
created = models.DateTimeField(verbose_name=_("Created at"),
auto_now_add=True)
category = models.ForeignKey(Category, verbose_name=_("Parent category"),
blank=True, null=True)
objects = CustomArticleManager()
# And now the translatable fields
class Translation(multilingual.Translation):
title = models.CharField(verbose_name=_("The title"),
blank=True, null=False, max_length=250)
contents = models.TextField(verbose_name=_("The contents"),
blank=True, null=False)
diff --git a/testproject/issue_15/models.py b/testproject/issue_15/models.py
index 33e96bf..136bbe3 100644
--- a/testproject/issue_15/models.py
+++ b/testproject/issue_15/models.py
@@ -1,42 +1,41 @@
"""
Models and unit tests for issues reported in the tracker.
# test for issue #15, it will fail on unpatched Django
# http://code.google.com/p/django-multilingual/issues/detail?id=15
>>> from multilingual import set_default_language
# Note: the to_str() calls in all the tests are here only to make it
# easier to test both pre-unicode and current Django.
>>> from testproject.utils import to_str
>>> set_default_language('pl')
>>> g = Gallery.objects.create(id=2, ref_id=2, title_pl='Test polski', title_en='English Test')
>>> to_str(g.title)
'Test polski'
>>> to_str(g.title_en)
'English Test'
>>> g = Gallery.objects.select_related(depth=1).get(id=2)
>>> to_str(g.title)
'Test polski'
>>> to_str(g.title_en)
'English Test'
-
"""
from django.db import models
import multilingual
try:
from django.utils.translation import ugettext as _
except:
# if this fails then _ is a builtin
pass
class Gallery(models.Model):
ref = models.ForeignKey('self', verbose_name=_('Parent gallery'))
modified = models.DateField(_('Modified'), auto_now=True)
class Translation(multilingual.Translation):
title = models.CharField(_('Title'), max_length=50)
description = models.TextField(_('Description'), blank=True)
diff --git a/testproject/issue_16/models/__init__.py b/testproject/issue_16/models/__init__.py
index 90bcddd..ad7deab 100644
--- a/testproject/issue_16/models/__init__.py
+++ b/testproject/issue_16/models/__init__.py
@@ -1,20 +1,18 @@
"""
Test for issue #16
http://code.google.com/p/django-multilingual/issues/detail?id=16
# Note: the to_str() calls in all the tests are here only to make it
# easier to test both pre-unicode and current Django.
>>> from testproject.utils import to_str
# The next line triggered an OperationalError before fix for #16
>>> c = Category.objects.create(name=u'The Name')
>>> c = Category.objects.get(id=c.id)
>>> to_str(c.name)
'The Name'
-
-
"""
from issue_16.models.category import Category
from issue_16.models.page import Page
diff --git a/testproject/issue_29/models.py b/testproject/issue_29/models.py
index aae1395..462621d 100644
--- a/testproject/issue_29/models.py
+++ b/testproject/issue_29/models.py
@@ -1,43 +1,42 @@
"""
Models and unit tests for issues reported in the tracker.
>>> from multilingual import set_default_language
# test for issue #15
# http://code.google.com/p/django-multilingual/issues/detail?id=15
>>> set_default_language('pl')
>>> g = Gallery.objects.create(id=2, title_pl='Test polski', title_en='English Test')
>>> g.title
'Test polski'
>>> g.title_en
'English Test'
>>> g.save()
>>> g.title_en = 'Test polski'
>>> g.save()
>>> try:
... g = Gallery.objects.create(id=3, title_pl='Test polski')
... except: print "ERROR"
...
ERROR
>>>
"""
-
from django.db import models
import multilingual
try:
from django.utils.translation import ugettext as _
except ImportError:
pass
class Gallery(models.Model):
class Admin:
pass
ref = models.ForeignKey('self', verbose_name=_('Parent gallery'),
blank=True, null=True)
modified = models.DateField(_('Modified'), auto_now=True)
class Translation(multilingual.Translation):
title = models.CharField(_('Title'), max_length=50, unique = True)
description = models.TextField(_('Description'), blank=True)
diff --git a/testproject/issue_37/models.py b/testproject/issue_37/models.py
index 3f4688a..2ff88e6 100644
--- a/testproject/issue_37/models.py
+++ b/testproject/issue_37/models.py
@@ -1,38 +1,34 @@
"""
Models and unit tests for issues reported in the tracker.
>>> from multilingual import set_default_language
>>> from testproject.utils import to_str
# test for issue #37
# http://code.google.com/p/django-multilingual/issues/detail?id=37
>>> set_default_language('en')
>>> x = ModelWithCustomPK.objects.create(custompk='key1', title=u'The English Title')
>>> set_default_language('pl')
>>> x.title = u'The Polish Title'
>>> x.save()
>>> x = ModelWithCustomPK.objects.get(pk='key1')
>>> to_str(x.title)
'The Polish Title'
>>> set_default_language('en')
>>> to_str(x.title)
'The English Title'
-
"""
-
from django.db import models
import multilingual
try:
from django.utils.translation import ugettext as _
except ImportError:
pass
class ModelWithCustomPK(models.Model):
-
custompk = models.CharField(max_length=5, primary_key=True)
-
+
class Translation(multilingual.Translation):
title = models.CharField(_('Title'), max_length=50, unique = True)
-
diff --git a/testproject/multimanage.py b/testproject/multimanage.py
index 070d312..502db31 100755
--- a/testproject/multimanage.py
+++ b/testproject/multimanage.py
@@ -1,85 +1,85 @@
#!/bin/env python
"""
A script that makes it easy to execute unit tests or start the dev
server with multiple Django versions.
Requires a short configuration file called test_config.py that lists
available Django paths. Will create that file if it is not present.
"""
import os
import os.path
import sys
def get_django_paths():
"""
Return the dictionary mapping Django versions to paths.
"""
CONFIG_FILE_NAME = 'multimanage_config.py'
DEFAULT_CONFIG_CONTENT = """DJANGO_PATHS = {
'0.96.1': '/dev/django-0.96.1/',
'trunk': '/dev/django-trunk/',
'newforms': '/dev/django-newforms/',
}
"""
-
+
if not os.path.exists(CONFIG_FILE_NAME):
print "The %s file does not exist" % CONFIG_FILE_NAME
open(CONFIG_FILE_NAME, 'w').write(DEFAULT_CONFIG_CONTENT)
print ("I created the file, but you need to edit it to enter "
"the correct paths.")
-
+
sys.exit(1)
from multimanage_config import DJANGO_PATHS
return DJANGO_PATHS
def execute_with_django_path(django_path, command):
"""
Execute the given command (via os.system), putting django_path
in PYTHONPATH environment variable.
Returns True if the command succeeded.
"""
original_pythonpath = os.environ.get('PYTHONPATH', '')
try:
os.environ['PYTHONPATH'] = os.path.pathsep.join([django_path, '..'])
return os.system(command) == 0
finally:
os.environ['PYTHONPATH'] = original_pythonpath
def run_manage(django_version, django_path, manage_params):
"""
Run 'manage.py [manage_params]' for the given Django version.
"""
print "** Starting manage.py for Django %s (%s)" % (django_version, django_path)
execute_with_django_path(django_path,
'python manage.py ' + ' '.join(manage_params))
django_paths = get_django_paths()
if len(sys.argv) == 1:
# without any arguments: display config info
print "Configured Django paths:"
for version, path in django_paths.items():
print " ", version, path
print "Usage examples:"
print " python multimanage.py [normal manage.py commands]"
print " python multimanage.py test [application names...]"
print " python multimanage.py runserver 0.0.0.0:4000"
print " python multimanage.py --django=trunk runserver 0.0.0.0:4000"
else:
# with at least one argument: handle args
version = None
args = sys.argv[1:]
for arg in args:
if arg.startswith('--django='):
version = arg.split('=')[1]
args.remove(arg)
if version:
run_manage(version, django_paths[version], args)
else:
for version, path in django_paths.items():
run_manage(version, path, args)
diff --git a/testproject/settings.py b/testproject/settings.py
index 39999c3..0875468 100644
--- a/testproject/settings.py
+++ b/testproject/settings.py
@@ -1,110 +1,109 @@
# Django settings for testproject project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'database.db3' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en'
# django-multilanguange #####################
# It is important that the language identifiers are consecutive
# numbers starting with 1.
-
LANGUAGES = [['en', 'English'], # id=1
['pl', 'Polish'], # id=2
['zh-cn', 'Simplified Chinese'], # id=3
]
DEFAULT_LANGUAGE = 1
##############################################
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '1+t11&r9nw+d7uw558+8=#j8!8^$nt97ecgv()-@x!tcef7f6)'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'multilingual.flatpages.middleware.FlatpageFallbackMiddleware',
)
ROOT_URLCONF = 'testproject.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'../multilingual/templates/',
'templates/',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'multilingual',
'multilingual.flatpages',
'testproject.articles',
'testproject.issue_15',
'testproject.issue_16',
'testproject.issue_29',
'testproject.issue_37',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'multilingual.context_processors.multilingual',
)
diff --git a/testproject/templates/articles/category_detail.html b/testproject/templates/articles/category_detail.html
index c0c2a2a..dffe841 100644
--- a/testproject/templates/articles/category_detail.html
+++ b/testproject/templates/articles/category_detail.html
@@ -1,8 +1,5 @@
{% extends "base.html" %}
{% load multilingual_tags %}
{% block body %}
<h1>Category {{ object.name_en|escape }}/{{ object.name_pl|escape }}</h1>
-
-
-
{% endblock %}
|
stefanfoulis/django-multilingual
|
47bbc1df3c6a6cd56602253244827d1acc5ce63f
|
The first parameter of languages.get_language_id_from_id_or_code() can now be a sublanguage, i.e. 'en-us' may return the id for 'en'.
|
diff --git a/multilingual/languages.py b/multilingual/languages.py
index 40bc866..99a9d7a 100644
--- a/multilingual/languages.py
+++ b/multilingual/languages.py
@@ -1,116 +1,118 @@
"""
Django-multilingual: language-related settings and functions.
"""
# Note: this file did become a mess and will have to be refactored
# after the configuration changes get in place.
#retrieve language settings from settings.py
from django.conf import settings
LANGUAGES = settings.LANGUAGES
from django.utils.translation import ugettext_lazy as _
from multilingual.exceptions import LanguageDoesNotExist
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
thread_locals = local()
def get_language_count():
return len(LANGUAGES)
def get_language_code(language_id):
return LANGUAGES[(int(language_id or get_default_language())) - 1][0]
def get_language_name(language_id):
return _(LANGUAGES[(int(language_id or get_default_language())) - 1][1])
def get_language_bidi(language_id):
return get_language_code(language_id) in settings.LANGUAGES_BIDI
def get_language_id_list():
return range(1, get_language_count() + 1)
def get_language_code_list():
return [lang[0] for lang in LANGUAGES]
def get_language_choices():
return [(language_id, get_language_code(language_id))
for language_id in get_language_id_list()]
def get_language_id_from_id_or_code(language_id_or_code, use_default=True):
if language_id_or_code is None:
if use_default:
return get_default_language()
else:
return None
-
+
if isinstance(language_id_or_code, int):
return language_id_or_code
i = 0
for (code, desc) in LANGUAGES:
i += 1
if code == language_id_or_code:
return i
+ if language_id_or_code.startswith("%s-" % code):
+ return i
raise LanguageDoesNotExist(language_id_or_code)
def get_language_idx(language_id_or_code):
# to do: optimize
language_id = get_language_id_from_id_or_code(language_id_or_code)
return get_language_id_list().index(language_id)
def set_default_language(language_id_or_code):
"""
Set the default language for the whole translation mechanism.
Accepts language codes or IDs.
"""
language_id = get_language_id_from_id_or_code(language_id_or_code)
thread_locals.DEFAULT_LANGUAGE = language_id
def get_default_language():
"""
Return the language ID set by set_default_language.
"""
return getattr(thread_locals, 'DEFAULT_LANGUAGE',
settings.DEFAULT_LANGUAGE)
def get_default_language_code():
"""
Return the language code of language ID set by set_default_language.
"""
language_id = get_language_id_from_id_or_code(get_default_language())
return get_language_code(language_id)
def _to_db_identifier(name):
"""
Convert name to something that is usable as a field name or table
alias in SQL.
For the time being assume that the only possible problem with name
- is the presence of dashes.
+ is the presence of dashes.
"""
return name.replace('-', '_')
def get_translation_table_alias(translation_table_name, language_id):
"""
Return an alias for the translation table for a given language_id.
Used in SQL queries.
"""
return (translation_table_name
+ '_'
+ _to_db_identifier(get_language_code(language_id)))
def get_translated_field_alias(field_name, language_id=None):
"""
Return an alias for field_name field for a given language_id.
Used in SQL queries.
"""
return ('_trans_'
+ field_name
+ '_' + _to_db_identifier(get_language_code(language_id)))
|
stefanfoulis/django-multilingual
|
290ae661db5b162120cad1c29273fc14e1f30c54
|
Fix for issue 57
|
diff --git a/multilingual/translation.py b/multilingual/translation.py
index f91f584..fdce7fc 100644
--- a/multilingual/translation.py
+++ b/multilingual/translation.py
@@ -1,397 +1,398 @@
"""
Support for models' internal Translation class.
"""
-## TO DO: this is messy and needs to be cleaned up
+##TODO: this is messy and needs to be cleaned up
from django.contrib.admin import StackedInline, ModelAdmin
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import signals
from django.db.models.base import ModelBase
from multilingual.languages import *
from multilingual.exceptions import TranslationDoesNotExist
from multilingual.fields import TranslationForeignKey
from multilingual import manager
from new import instancemethod
class TranslationModelAdmin(StackedInline):
template = "admin/edit_inline_translations_newforms.html"
def translation_save_translated_fields(instance, **kwargs):
"""
Save all the translations of instance in post_save signal handler.
"""
if not hasattr(instance, '_translation_cache'):
return
for l_id, translation in instance._translation_cache.iteritems():
# set the translation ID just in case the translation was
# created while instance was not stored in the DB yet
# note: we're using _get_pk_val here even though it is
# private, since that's the most reliable way to get the value
# on older Django (pk property did not exist yet)
translation.master_id = instance._get_pk_val()
translation.save()
def translation_overwrite_previous(instance, **kwargs):
"""
Delete previously existing translation with the same master and
language_id values. To be called by translation model's pre_save
signal.
This most probably means I am abusing something here trying to use
Django inline editor. Oh well, it will have to go anyway when we
move to newforms.
"""
qs = instance.__class__.objects
try:
qs = qs.filter(master=instance.master).filter(language_id=instance.language_id)
qs.delete()
except ObjectDoesNotExist:
# We are probably loading a fixture that defines translation entities
# before their master entity.
pass
def fill_translation_cache(instance):
"""
Fill the translation cache using information received in the
instance objects as extra fields.
You can not do this in post_init because the extra fields are
assigned by QuerySet.iterator after model initialization.
"""
if hasattr(instance, '_translation_cache'):
# do not refill the cache
return
instance._translation_cache = {}
for language_id in get_language_id_list():
# see if translation for language_id was in the query
field_alias = get_translated_field_alias('id', language_id)
if getattr(instance, field_alias, None) is not None:
field_names = [f.attname for f in instance._meta.translation_model._meta.fields]
# if so, create a translation object and put it in the cache
field_data = {}
for fname in field_names:
field_data[fname] = getattr(instance,
get_translated_field_alias(fname, language_id))
translation = instance._meta.translation_model(**field_data)
instance._translation_cache[language_id] = translation
# In some situations an (existing in the DB) object is loaded
# without using the normal QuerySet. In such case fallback to
# loading the translations using a separate query.
# Unfortunately, this is indistinguishable from the situation when
# an object does not have any translations. Oh well, we'll have
# to live with this for the time being.
if len(instance._translation_cache.keys()) == 0:
for translation in instance.translations.all():
instance._translation_cache[translation.language_id] = translation
class TranslatedFieldProxy(property):
def __init__(self, field_name, alias, field, language_id=None):
self.field_name = field_name
self.field = field
self.admin_order_field = alias
self.language_id = language_id
def __get__(self, obj, objtype=None):
if obj is None:
return self
return getattr(obj, 'get_' + self.field_name)(self.language_id)
def __set__(self, obj, value):
language_id = self.language_id
return getattr(obj, 'set_' + self.field_name)(value, self.language_id)
short_description = property(lambda self: self.field.short_description)
def getter_generator(field_name, short_description):
"""
Generate get_'field name' method for field field_name.
"""
def get_translation_field(self, language_id_or_code=None):
try:
return getattr(self.get_translation(language_id_or_code), field_name)
except TranslationDoesNotExist:
return None
get_translation_field.short_description = short_description
return get_translation_field
def setter_generator(field_name):
"""
Generate set_'field name' method for field field_name.
"""
def set_translation_field(self, value, language_id_or_code=None):
setattr(self.get_translation(language_id_or_code, True),
field_name, value)
set_translation_field.short_description = "set " + field_name
return set_translation_field
def get_translation(self, language_id_or_code,
create_if_necessary=False):
"""
Get a translation instance for the given language_id_or_code.
If it does not exist, either create one or raise the
TranslationDoesNotExist exception, depending on the
create_if_necessary argument.
"""
# fill the cache if necessary
self.fill_translation_cache()
language_id = get_language_id_from_id_or_code(language_id_or_code, False)
if language_id is None:
language_id = getattr(self, '_default_language', None)
if language_id is None:
language_id = get_default_language()
if language_id not in self._translation_cache:
if not create_if_necessary:
raise TranslationDoesNotExist(language_id)
new_translation = self._meta.translation_model(master=self,
language_id=language_id)
self._translation_cache[language_id] = new_translation
return self._translation_cache.get(language_id, None)
class Translation:
"""
A superclass for translatablemodel.Translation inner classes.
"""
def contribute_to_class(cls, main_cls, name):
"""
Handle the inner 'Translation' class.
"""
# delay the creation of the *Translation until the master model is
# fully created
signals.class_prepared.connect(cls.finish_multilingual_class,
sender=main_cls, weak=False)
# connect the post_save signal on master class to a handler
# that saves translations
signals.post_save.connect(translation_save_translated_fields,
sender=main_cls)
contribute_to_class = classmethod(contribute_to_class)
def create_translation_attrs(cls, main_cls):
"""
Creates get_'field name'(language_id) and set_'field
name'(language_id) methods for all the translation fields.
Adds the 'field name' properties too.
Returns the translated_fields hash used in field lookups, see
multilingual.query. It maps field names to (field,
language_id) tuples.
"""
translated_fields = {}
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
translated_fields[fname] = (field, None)
# add get_'fname' and set_'fname' methods to main_cls
getter = getter_generator(fname, getattr(field, 'verbose_name', fname))
setattr(main_cls, 'get_' + fname, getter)
setter = setter_generator(fname)
setattr(main_cls, 'set_' + fname, setter)
# add the 'fname' proxy property that allows reads
# from and writing to the appropriate translation
setattr(main_cls, fname,
TranslatedFieldProxy(fname, fname, field))
# create the 'fname'_'language_code' proxy properties
for language_id in get_language_id_list():
language_code = get_language_code(language_id)
fname_lng = fname + '_' + language_code.replace('-', '_')
translated_fields[fname_lng] = (field, language_id)
setattr(main_cls, fname_lng,
TranslatedFieldProxy(fname, fname_lng, field,
language_id))
return translated_fields
create_translation_attrs = classmethod(create_translation_attrs)
def get_unique_fields(cls):
"""
Return a list of fields with "unique" attribute, which needs to
be augmented by the language.
"""
unique_fields = []
for fname, field in cls.__dict__.items():
if isinstance(field, models.fields.Field):
if getattr(field,'unique',False):
try:
field.unique = False
except AttributeError:
# newer Django defines unique as a property
# that uses _unique to store data. We're
# jumping over the fence by setting _unique,
# so this sucks, but this happens early enough
# to be safe.
field._unique = False
unique_fields.append(fname)
return unique_fields
get_unique_fields = classmethod(get_unique_fields)
def finish_multilingual_class(cls, *args, **kwargs):
"""
Create a model with translations of a multilingual class.
"""
main_cls = kwargs['sender']
translation_model_name = main_cls.__name__ + "Translation"
# create the model with all the translatable fields
unique = [('language_id', 'master')]
for f in cls.get_unique_fields():
unique.append(('language_id',f))
class TransMeta:
pass
try:
meta = cls.Meta
except AttributeError:
meta = TransMeta
meta.ordering = ('language_id',)
meta.unique_together = tuple(unique)
meta.app_label = main_cls._meta.app_label
if not hasattr(meta, 'db_table'):
meta.db_table = main_cls._meta.db_table + '_translation'
trans_attrs = cls.__dict__.copy()
trans_attrs['Meta'] = meta
trans_attrs['language_id'] = models.IntegerField(blank=False, null=False,
choices=get_language_choices(),
db_index=True)
edit_inline = True
trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
related_name='translations',)
trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
% (translation_model_name,
get_language_code(self.language_id)))
trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
_old_init_name_map = main_cls._meta.__class__.init_name_map
def init_name_map(self):
cache = _old_init_name_map(self)
for name, field_and_lang_id in trans_model._meta.translated_fields.items():
#import sys; sys.stderr.write('TM %r\n' % trans_model)
cache[name] = (field_and_lang_id[0], trans_model, True, False)
return cache
main_cls._meta.init_name_map = instancemethod(init_name_map,
main_cls._meta,
main_cls._meta.__class__)
main_cls._meta.translation_model = trans_model
main_cls.get_translation = get_translation
main_cls.fill_translation_cache = fill_translation_cache
# Note: don't fill the translation cache in post_init, as all
# the extra values selected by QAddTranslationData will be
# assigned AFTER init()
# signals.post_init.connect(fill_translation_cache,
# sender=main_cls)
# connect the pre_save signal on translation class to a
# function removing previous translation entries.
signals.pre_save.connect(translation_overwrite_previous,
sender=trans_model, weak=False)
finish_multilingual_class = classmethod(finish_multilingual_class)
def install_translation_library():
# modify ModelBase.__new__ so that it understands how to handle the
# 'Translation' inner class
if getattr(ModelBase, '_multilingual_installed', False):
# don't install it twice
return
_old_new = ModelBase.__new__
def multilingual_modelbase_new(cls, name, bases, attrs):
if 'Translation' in attrs:
if not issubclass(attrs['Translation'], Translation):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.Translation.") % (name,)
# Make sure that if the class specifies objects then it is
# a subclass of our Manager.
#
# Don't check other managers since someone might want to
# have a non-multilingual manager, but assigning a
# non-multilingual manager to objects would be a common
# mistake.
if ('objects' in attrs) and (not isinstance(attrs['objects'], manager.Manager)):
raise ValueError, ("Model %s specifies translations, " +
"so its 'objects' manager must be " +
"a subclass of multilingual.Manager.") % (name,)
# Change the default manager to multilingual.Manager.
if not 'objects' in attrs:
attrs['objects'] = manager.Manager()
# Install a hack to let add_multilingual_manipulators know
# this is a translatable model (TODO: manipulators gone)
attrs['is_translation_model'] = lambda self: True
return _old_new(cls, name, bases, attrs)
ModelBase.__new__ = staticmethod(multilingual_modelbase_new)
ModelBase._multilingual_installed = True
# Override ModelAdmin.__new__ to create automatic inline
# editor for multilingual models.
_old_admin_new = ModelAdmin.__new__
def multilingual_modeladmin_new(cls, model, admin_site, obj=None):
+ #TODO: is this check really necessary?
if isinstance(model.objects, manager.Manager):
X = cls.get_translation_modeladmin(model)
if cls.inlines:
for inline in cls.inlines:
- if X.__class__ == inline.__class__:
+ if X.__name__ == inline.__name__:
cls.inlines.remove(inline)
break
cls.inlines.append(X)
else:
cls.inlines = [X]
return _old_admin_new(cls, model, admin_site, obj)
def get_translation_modeladmin(cls, model):
if hasattr(cls, 'Translation'):
tr_cls = cls.Translation
if not issubclass(tr_cls, TranslationModelAdmin):
raise ValueError, ("%s.Translation must be a subclass "
+ " of multilingual.TranslationModelAdmin.") % cls.name
else:
tr_cls = type("%s.Translation" % cls.__name__, (TranslationModelAdmin,), {})
tr_cls.model = model._meta.translation_model
tr_cls.fk_name = 'master'
tr_cls.extra = get_language_count()
tr_cls.max_num = get_language_count()
return tr_cls
ModelAdmin.__new__ = staticmethod(multilingual_modeladmin_new)
ModelAdmin.get_translation_modeladmin = classmethod(get_translation_modeladmin)
# install the library
install_translation_library()
|
stefanfoulis/django-multilingual
|
34c953d46d04e084cf0a98f351758cf8c2ceb23e
|
Removing useless ModelForm patch
|
diff --git a/multilingual/__init__.py b/multilingual/__init__.py
index 0703190..cb21d5a 100644
--- a/multilingual/__init__.py
+++ b/multilingual/__init__.py
@@ -1,10 +1,10 @@
"""
Django-multilingual: multilingual model support for Django.
"""
from multilingual import models
from multilingual.exceptions import TranslationDoesNotExist, LanguageDoesNotExist
from multilingual.languages import set_default_language, get_default_language, get_language_code_list
from multilingual.translation import Translation
from multilingual.manager import Manager
-from multilingual import forms
+
diff --git a/multilingual/forms.py b/multilingual/forms.py
deleted file mode 100644
index fff6109..0000000
--- a/multilingual/forms.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""TODO: this will probably be removed because DM seems to work correctly without
-manipulators.
-"""
-from django.forms.models import ModelForm
-from django.forms.models import ErrorList
-
-from multilingual.languages import get_language_id_list
-
-def multilingual_init(self, data=None, files=None, auto_id='id_%s', prefix=None,
- initial=None, error_class=ErrorList, label_suffix=':',
- empty_permitted=False, instance=None):
- if data and hasattr(self._meta.model, 'translation_model'):
- trans_model = self._meta.model._meta.translation_model
- lower_model_name = trans_model._meta.object_name.lower()
- language_id_list = get_language_id_list()
- for language_idx in range(0, len(language_id_list)):
- name = "%s.%s.language_id" % (lower_model_name,
- language_idx)
- data[name] = language_id_list[language_idx]
- super(ModelForm, self).__init__(data, files, auto_id, prefix, initial,
- error_class, label_suffix, empty_permitted, instance)
-
-#NOTE: leave commented
-#ModelForm.__init__ = multilingual_init
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.