App-AutoCRUD
view release on metacpan or search on metacpan
lib/App/AutoCRUD.pm view on Meta::CPAN
# raise exception if found but there is a compilation error
my $class = try {Plack::Util::load_class($name, $namespace)}
catch {die $_ if $_ !~ /^Can't locate(?! object method)/};
return $class;
}
sub is_class_loaded {
my ($self, $class) = @_;
# deactivate strict refs because we'll be looking into symbol tables
no strict 'refs';
# looking at %{$class."::"} is not enough (it may contain other namespaces);
# so we consider a class loaded if it has at least an ISA or a VERSION
return @{$class."::ISA"} || ${$class."::VERSION"};
}
sub show_error {
my ($self, $msg) = @_;
return <<__EOHTML__;
<!doctype html>
<html>
<head><title>500 Server Error</title></head>
<body><h1>500 Server Error</h1>
<pre>
$msg
</pre>
<!--
512 bytes of padding to suppress Internet Explorer's "Friendly error messages"
From: HOW TO: Turn Off the Internet Explorer 5.x and 6.x
"Show Friendly HTTP Error Messages" Feature on the Server Side"
http://support.microsoft.com/kb/294807
Several frequently-seen status codes have "friendly" error messages
that Internet Explorer 5.x displays and that effectively mask the
actual text message that the server sends.
However, these "friendly" error messages are only displayed if the
response that is sent to the client is less than or equal to a
specified threshold.
For example, to see the exact text of an HTTP 500 response,
the content length must be greater than 512 bytes.
-->
</body>
</html>
__EOHTML__
}
1; # End of App::AutoCRUD
__END__
=head1 NAME
App::AutoCRUD - A Plack application for browsing and editing databases
=head1 SYNOPSIS
=head2 Quick demo
To see the demo distributed with this application :
cd examples/Chinook
plackup app.psgi
Then point your browser to L<http://localhost:5000>.
=head2 General startup
Create a configuration file, for example in L<YAML> format, like this :
app:
name: Test AutoCRUD
datasources :
Source1 :
dbh:
connect:
# arguments that will be passed to DBI->connect(...)
# for example :
- dbi:SQLite:dbname=some_file
- "" # user
- "" # password
- RaiseError : 1
sqlite_unicode: 1
Create a file F<crud.psgi> like this :
use App::AutoCRUD;
use YAML qw/LoadFile/;
my $config = LoadFile "/path/to/config.yaml";
my $crud = App::AutoCRUD->new(config => $config);
my $app = $crud->to_app;
Then run the app
plackup crud.psgi
or mount the app in Apache
<Location /crud>
SetHandler perl-script
PerlResponseHandler Plack::Handler::Apache2
PerlSetVar psgi_app /path/to/crud.psgi
</Location>
and use your favorite web browser to navigate through your database.
=head1 DESCRIPTION
This module embodies a web application for Creating, Retrieving,
Updating and Deleting records in relational databases (hence the
'CRUD' acronym). The 'C<Auto>' part of the name is because the
application automatically generates and immediately uses the
components needed to work with your data -- you don't have to edit
scaffolding code. The 'C<Plack>' part of the name comes from the
L<Plack middleware framework|Plack> used to implement this application.
To connect to one or several databases, just supply a configuration
file with the connnection information, and optionally some
presentation information, and then you can directly work with the
data. Optionally, the configuration file can also specify many
additional details, like table groups, column groups, data
descriptions, etc. If more customization is needed, then you can
modify the presentation templates, or even subclass some parts of the
framework.
This application was designed to be easy to integrate with other web
resources in your organization : every table, every record, every
search form has its own URL which can be linked from other sources,
can be bookmarked, etc. This makes it a great tool for example
for adding an admin interface to an existing application : just
install AutoCRUD at a specific location within your Web server
(with appropriate access control :-).
Some distinctive features of this module, in comparison with other
CRUD applications, are :
=over
=item *
Hyperlinks between records, corresponding to foreign key
relationships in the database.
=item *
Support for update or delete of several records at once.
=item *
Support for reordering, masking, documenting tables and columns
through configuration files -- a cheap way to provide reasonable
user experience without investing into a full-fledged custom application.
=item *
Data export in Excel, YAML, JSON, XML formats
=item *
Extensibility through inheritance
=back
This application is also meant as an example for showing the
power of "Modern Perl", assembling several advanced frameworks
such as L<Moose>, L<Plack> and L<DBIx::DataModel>.
=head1 CONFIGURATION
The bare minimum for this application to run is to
get some configuration information about how to connect
lib/App/AutoCRUD.pm view on Meta::CPAN
=head1 ACKNOWLEDGEMENTS
Some design aspects were borrowed from
=over
=item L<Catalyst>
=item L<Catalyst::Helper::View::TTSite>
=back
=head1 AUTHOR
Laurent Dami, C<< <dami at cpan.org> >>
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc App::AutoCRUD
You can also look for information at:
=over 4
=item * github's request tracker (report bugs here)
L<https://github.com/damil/App-AutoCRUD/issues>
=item * MetaCPAN
L<https://metacpan.org/pod/App::AutoCRUD>
=back
The source code is at
L<https://github.com/damil/App-AutoCRUD>.
=head1 SEE ALSO
L<Catalyst::Plugin::AutoCRUD>,
L<WebAPI::DBIC>,
L<Plack>,
L<http://www.codeplex.com/ChinookDatabase>.
=head1 TODO
- column properties
- noinsert, noupdate, nosearch, etc.
- edit: select or autocompleter for foreign keys
- internationalisation
-
- View:
- default view should be defined in config
- overridable content-type & headers
- search form, show associations => link to join search
- list foreign keys even if not in DBIDM schema
- change log
- quoting problem (FromQuery: "J&B")
- readonly fields: tabindex -1 (can be done by CSS?)
in fact, current values should NOT be input fields, but plain SPANs
- NULL in updates
- Update form, focus problem (focus in field should deactivate TreeNav)
- add insert link in table descr
- deal with Favicon.ico
- declare in http://www.sqlite.org/cvstrac/wiki?p=ManagementTools
- multicolumns : if there is an association over a multicolumns key,
it is not displayed as a hyperlink in /list. To do so, we would need
to add a line in the display, corresponding to the multicolumn.
=head1 LICENSE AND COPYRIGHT
Copyright 2014-2021 Laurent Dami.
This program is free software; you can redistribute it and/or modify it
under the terms of the the Artistic License (2.0). You may obtain a
copy of the full license at:
L<http://www.perlfoundation.org/artistic_license_2_0>
=cut
( run in 1.004 second using v1.01-cache-2.11-cpan-13bb782fe5a )