[Jifty-commit] r2674 - in jifty/branches/template-declare: .
lib/Jifty/Action lib/Jifty/Manual lib/Jifty/Plugin/REST
lib/Jifty/Script lib/Jifty/View/Static
share/web/static/images/iepngfix share/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jan 27 20:28:40 EST 2007
Author: trs
Date: Sat Jan 27 20:28:39 2007
New Revision: 2674
Added:
jifty/branches/template-declare/share/web/static/images/iepngfix/
jifty/branches/template-declare/share/web/static/images/iepngfix/blank.gif (contents, props changed)
jifty/branches/template-declare/share/web/static/js/iepngfix.htc
Modified:
jifty/branches/template-declare/ (props changed)
jifty/branches/template-declare/lib/Jifty/Action/Record.pm
jifty/branches/template-declare/lib/Jifty/Handle.pm
jifty/branches/template-declare/lib/Jifty/JSON.pm
jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod
jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm
jifty/branches/template-declare/lib/Jifty/Script/Schema.pm
jifty/branches/template-declare/lib/Jifty/Upgrade.pm
jifty/branches/template-declare/lib/Jifty/Util.pm
jifty/branches/template-declare/lib/Jifty/View/Static/Handler.pm
Log:
Mergedown from trunk
r19209 at zot (orig r2661): hlb | 2007-01-27 06:12:00 -0500
* include iepngfix 1.0
* add MIME type text/x-component for .htc file
* howto document for iepngfix
r19210 at zot (orig r2662): ruz | 2007-01-27 06:30:28 -0500
* grep and map are faster without block
r19211 at zot (orig r2663): ruz | 2007-01-27 06:48:54 -0500
* enable UTF-8 flag awarness in JSON libraries to fix problem in validation
of values during creating a record via the admin interface when column has
valid values with unicode chars.
r19212 at zot (orig r2664): audreyt | 2007-01-27 07:31:22 -0500
* Revert r2662 as it's optimizing a block that's called only once per record. :-)
r19213 at zot (orig r2665): audreyt | 2007-01-27 07:34:27 -0500
* Er, uhm, obra++ for pointing out that I mixed up the logic in the revert.
r19216 at zot (orig r2668): hlb | 2007-01-27 10:26:18 -0500
local_path regex fix
r19217 at zot (orig r2669): audreyt | 2007-01-27 10:42:01 -0500
* Change all tests for the literal Driver string "SQLite"
to a regex match to /SQLite/, in anticipation of fancy
drivers such as SVK::SQLite.
r19218 at zot (orig r2670): agentz | 2007-01-27 13:11:26 -0500
Jifty::Util - fixed the broken Win32 logic:
- use ExtUtils::MM before calling MM->maybe_command
- ignore the case of letters when comparing file names
r19219 at zot (orig r2671): agentz | 2007-01-27 13:24:59 -0500
Jifty::Util - only requires ExtUtils::MM at request.
r19229 at zot (orig r2673): trs | 2007-01-27 20:27:32 -0500
r19228 at zot: tom | 2007-01-27 20:27:17 -0500
Do a better job of making action results simple data structures
Modified: jifty/branches/template-declare/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Action/Record.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Action/Record.pm Sat Jan 27 20:28:39 2007
@@ -346,7 +346,7 @@
sub possible_fields {
my $self = shift;
- return map {$_->name} grep {$_->type ne "serial"} $self->record->columns;
+ return map { $_->name } grep { $_->type ne "serial" } $self->record->columns;
}
=head2 take_action
Modified: jifty/branches/template-declare/lib/Jifty/Handle.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Handle.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Handle.pm Sat Jan 27 20:28:39 2007
@@ -65,7 +65,7 @@
# legacy databases
my $db = $db_config->{'Database'};
- if ($db_config->{'Driver'} eq 'SQLite') {
+ if ($db_config->{'Driver'} =~ /SQLite/) {
$db = Jifty::Util->absolute_path($db);
}
Modified: jifty/branches/template-declare/lib/Jifty/JSON.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/JSON.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/JSON.pm Sat Jan 27 20:28:39 2007
@@ -19,7 +19,7 @@
single-quoted string output.
If the faster L<JSON::Syck> is available, it is preferred over the pure-perl
-L<JSON>, as it provides native support for single-quoted strings..
+L<JSON>, as it provides native support for single-quoted strings.
=head1 METHODS
@@ -32,11 +32,13 @@
if (eval { require JSON::Syck; JSON::Syck->VERSION(0.05) }) {
*jsonToObj = *_jsonToObj_syck;
*objToJson = *_objToJson_syck;
+ $JSON::Syck::ImplicitUnicode = 1;
}
else {
require JSON;
*jsonToObj = *_jsonToObj_pp;
*objToJson = *_objToJson_pp;
+ $JSON::UTF8 = 1;
}
}
Modified: jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod (original)
+++ jifty/branches/template-declare/lib/Jifty/Manual/Cookbook.pod Sat Jan 27 20:28:39 2007
@@ -303,3 +303,21 @@
Take care the indentation is significant. Use spaces, not tabs.
Once you have done that you can restart your Jifty application and the
edit links should then function correctly.
+
+=head2 Use iepngfix.htc to add PNG support in IE5.5+
+
+Jifty has included iepngfix.htc by Angus Turnbull. The HTC file will
+automatically add PNG support to IMG elements and also supports any
+element with a "background-image" CSS property.
+
+If you want to use this fix, please include this one line in your CSS
+file, whit tag names to which you want the script applied:
+
+ img, div { behavior: url(/static/js/iepngfix.htc) }
+
+Alternatively, you can specify that this will apply to all tags like so:
+
+ * { behavior: url(/static/js/iepngfix.htc) }
+
+Check details from Angus himself. ( http://www.twinhelix.com/ )
+
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm Sat Jan 27 20:28:39 2007
@@ -96,6 +96,53 @@
return wantarray ? @r : pop @r;
}
+=head2 object_to_data OBJ
+
+Takes an object and converts the known types into simple data structures.
+
+Current known types:
+
+ Jifty::DBI::Collection
+ Jifty::DBI::Record
+
+=cut
+
+sub object_to_data {
+ my $obj = shift;
+
+ my %types = (
+ 'Jifty::DBI::Collection' => \&_collection_to_data,
+ 'Jifty::DBI::Record' => \&_record_to_data,
+ );
+
+ for my $type ( keys %types ) {
+ if ( UNIVERSAL::isa( $obj, $type ) ) {
+ return $types{$type}->( $obj );
+ }
+ }
+
+ warn "Unable to handle object of type ", ref $obj, ", attempting to stringify.\n";
+ return stringify( $obj );
+}
+
+sub _collection_to_data {
+ my $records = shift->items_array_ref;
+ return [ map { _record_to_data( $_ ) } @$records ];
+}
+
+sub _record_to_data {
+ my $record = shift;
+ # We could use ->as_hash but this method avoids transforming refers_to
+ # columns into JDBI objects
+ my %data = map {
+ $_ => (UNIVERSAL::isa( $record->column( $_ )->refers_to,
+ 'Jifty::DBI::Collection' )
+ ? undef
+ : stringify( $record->_value( $_ ) ) )
+ } $record->readable_attributes;
+ return \%data;
+}
+
=head2 list PREFIX items
Takes a URL prefix and a set of items to render. passes them on.
@@ -406,7 +453,7 @@
=head2 show_item $model, $column, $key
-Loads up a model of type C<$model> which has a column C<$column> with a value C<$key>. Returns all columns for the object
+Loads up a model of type C<$model> which has a column C<$column> with a value C<$key>. Returns all columns for the object
Returns 404 if it doesn't exist.
@@ -631,6 +678,10 @@
delete $out->{field_warnings}->{$_} unless $out->{field_warnings}->{$_};
}
$out->{content} = $result->content;
+
+ for my $key ( keys %{ $out->{content} } ) {
+ $out->{content}{$key} = object_to_data( $out->{content}{$key} );
+ }
outs(undef, $out);
Modified: jifty/branches/template-declare/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Script/Schema.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Script/Schema.pm Sat Jan 27 20:28:39 2007
@@ -491,7 +491,7 @@
if ( $self->{'drop_database'} ) {
if ( $self->{'print'} ) {
print "DROP DATABASE $database;\n";
- } elsif ( $driver eq 'SQLite' ) {
+ } elsif ( $driver =~ /SQLite/ ) {
# Win32 complains when you try to unlink open DB
$handle->disconnect if $^O eq 'MSWin32';
unlink($database);
@@ -503,7 +503,7 @@
if ( $self->{'create_database'} ) {
if ( $self->{'print'} ) {
print "CREATE DATABASE $database;\n";
- } elsif ( $driver ne 'SQLite' ) {
+ } elsif ( $driver !~ /SQLite/ ) {
$handle->simple_query("CREATE DATABASE $database");
}
}
Modified: jifty/branches/template-declare/lib/Jifty/Upgrade.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Upgrade.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Upgrade.pm Sat Jan 27 20:28:39 2007
@@ -84,7 +84,7 @@
if ( $args{column} ) {
my $driver = Jifty->config->framework('Database')->{'Driver'};
- if ( $driver eq "SQLite" ) {
+ if ( $driver =~ /SQLite/ ) {
# Convert columns
my ($schema) = Jifty->handle->fetch_result("SELECT sql FROM sqlite_master WHERE tbl_name = '$table_name' AND type = 'table'");
Modified: jifty/branches/template-declare/lib/Jifty/Util.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Util.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Util.pm Sat Jan 27 20:28:39 2007
@@ -144,6 +144,7 @@
push @roots, $FindBin::Bin;
}
+ Jifty::Util->require('ExtUtils::MM') if $^O =~ /(?:MSWin32|cygwin|os2)/;
Jifty::Util->require('Config');
for (@roots) {
my @root = File::Spec->splitdir($_);
@@ -156,10 +157,15 @@
# Also, /usr/bin or /usr/local/bin should be taken from
# %Config{bin} or %Config{scriptdir} or something like that
# for portablility.
+ # Note that to compare files in Win32 we have to ignore the case
(-e $try or (($^O =~ /(?:MSWin32|cygwin|os2)/) and MM->maybe_command($try)))
- and $try ne File::Spec->catdir($Config::Config{bin}, "jifty")
- and $try ne File::Spec->catdir($Config::Config{scriptdir}, "jifty") )
+ and lc($try) ne lc(File::Spec->catdir($Config::Config{bin}, "jifty"))
+ and lc($try) ne lc(File::Spec->catdir($Config::Config{scriptdir}, "jifty")) )
{
+ #warn "root: ", File::Spec->catdir(@root);
+ #warn "bin/jifty: ", File::Spec->catdir($Config::Config{bin}, "jifty");
+ #warn "scriptdir/jifty: ", File::Spec->catdir($Config::Config{scriptdir}, "jifty");
+ #warn "try: $try";
return $APP_ROOT = File::Spec->catdir(@root);
}
pop @root;
Modified: jifty/branches/template-declare/lib/Jifty/View/Static/Handler.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/View/Static/Handler.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/View/Static/Handler.pm Sat Jan 27 20:28:39 2007
@@ -154,10 +154,11 @@
# chokes on ajax-fetched JS that has a type other than the one below
# JSAN.js fetches JS via Ajax when it loads JSAN modules
'js' => 'application/x-javascript',
+ 'htc' => 'text/x-component',
);
return ($type_override{$1})
- if $local_path =~ /\.(.+)$/ and defined $type_override{$1};
+ if $local_path =~ /^.*\.(.+?)$/ and defined $type_override{$1};
# Defer initialization to first use. (It's not actually cheap)
$MIME ||= MIME::Types->new();
Added: jifty/branches/template-declare/share/web/static/images/iepngfix/blank.gif
==============================================================================
Binary file. No diff available.
Added: jifty/branches/template-declare/share/web/static/js/iepngfix.htc
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/share/web/static/js/iepngfix.htc Sat Jan 27 20:28:39 2007
@@ -0,0 +1,55 @@
+<public:component>
+<public:attach event="onpropertychange" onevent="doFix()" />
+
+<script>
+
+// IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com
+// Free usage permitted as long as this notice remains intact.
+
+// This must be a path to a blank image. That's all the configuration you need here.
+
+/*
+ USAGE:
+ All you have to do is include this one line in your CSS file, with the
+ tag names to which you want the script applied:
+
+ img, div { behavior: url(iepngfix.htc) }
+
+ Alternatively, you can specify that this will apply to all tags like so:
+
+ * { behavior: url(iepngfix.htc) }
+*/
+
+var blankImg = '/static/images/iepngfix/blank.gif';
+
+var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
+
+function filt(s, m) {
+ if (filters[f]) {
+ filters[f].enabled = s ? true : false;
+ if (s) with (filters[f]) { src = s; sizingMethod = m }
+ } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")';
+}
+
+function doFix() {
+ if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) ||
+ (event && !/(background|src)/.test(event.propertyName))) return;
+
+ if (tagName == 'IMG') {
+ if ((/\.png$/i).test(src)) {
+ filt(src, 'image'); // was 'scale'
+ src = blankImg;
+ } else if (src.indexOf(blankImg) < 0) filt();
+ } else if (style.backgroundImage) {
+ if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) {
+ var s = RegExp.$1;
+ style.backgroundImage = '';
+ filt(s, 'crop');
+ } else filt();
+ }
+}
+
+doFix();
+
+</script>
+</public:component>
More information about the Jifty-commit
mailing list