├── .gitignore ├── Changes ├── LICENSE ├── Makefile.PL ├── README.md ├── cpanfile ├── database_backup.sql ├── lib ├── PerlCatalystMysqlTemplate.pm └── PerlCatalystMysqlTemplate │ ├── Controller │ └── Root.pm │ ├── Model │ └── DB.pm │ ├── Schema.pm │ ├── Schema │ └── Result │ │ └── Fruit.pm │ └── View │ └── HTML.pm ├── perlcatalystmysqltemplate.conf ├── perlcatalystmysqltemplate.psgi ├── root ├── favicon.ico ├── root │ └── index.tt └── static │ ├── css │ └── style.css │ └── images │ ├── btn_120x50_built.png │ ├── btn_120x50_built_shadow.png │ ├── btn_120x50_powered.png │ ├── btn_120x50_powered_shadow.png │ ├── btn_88x31_built.png │ ├── btn_88x31_built_shadow.png │ ├── btn_88x31_powered.png │ ├── btn_88x31_powered_shadow.png │ └── catalyst_logo.png ├── script ├── perlcatalystmysqltemplate_cgi.pl ├── perlcatalystmysqltemplate_create.pl ├── perlcatalystmysqltemplate_fastcgi.pl ├── perlcatalystmysqltemplate_server.pl └── perlcatalystmysqltemplate_test.pl └── t ├── 01app.t ├── 02pod.t ├── 03podcoverage.t ├── model_DB.t └── view_HTML.t /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | This file documents the revision history for Perl extension PerlCatalystMysqlTemplate. 2 | 3 | 0.01 2016-11-03 12:31:40 4 | - initial revision, generated by Catalyst 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile.PL: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # IMPORTANT: if you delete this file your app will not work as 3 | # expected. You have been warned. 4 | use inc::Module::Install 1.02; 5 | use Module::Install::Catalyst; # Complain loudly if you don't have 6 | # Catalyst::Devel installed or haven't said 7 | # 'make dist' to create a standalone tarball. 8 | 9 | name 'PerlCatalystMysqlTemplate'; 10 | all_from 'lib/PerlCatalystMysqlTemplate.pm'; 11 | 12 | requires 'Catalyst::Runtime' => '5.90112'; 13 | requires 'Catalyst::Plugin::ConfigLoader'; 14 | requires 'Catalyst::Plugin::Static::Simple'; 15 | requires 'Catalyst::Action::RenderView'; 16 | 17 | requires 'Catalyst::Helper::View::TT'; 18 | requires 'DBD::mysql'; 19 | requires 'DBIx::Class::Schema::Loader'; 20 | requires 'Catalyst::Helper::Model::DBIC::Schema'; 21 | requires 'Catalyst::Plugin::StackTrace'; 22 | 23 | requires 'Moose'; 24 | requires 'namespace::autoclean'; 25 | requires 'Config::General'; # This should reflect the config file format you've chosen 26 | # See Catalyst::Plugin::ConfigLoader for supported formats 27 | test_requires 'Test::More' => '0.88'; 28 | catalyst; 29 | 30 | install_script glob('script/*.pl'); 31 | auto_install; 32 | WriteAll; 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [AnyChart - Robust JavaScript/HTML5 Chart library for any project](https://www.anychart.com) 2 | # Perl Catalyst basic template 3 | This example shows how to use Anychart library with the Perl programming language, Catalyst web framework and MySQL database. 4 | 5 | ## Running 6 | 7 | To use this sample you must have Perl, Cpan and Catalyst installed, if not, please, visit [Catalyst installation guide](http://wiki.catalystframework.org/wiki/installingcatalyst); 8 | MySQL installed and running, if not please check out [MySQL download page](https://dev.mysql.com/downloads/installer/) and follow [instructions](http://dev.mysql.com/doc/refman/5.7/en/installing.html). 9 | 10 | To check your installations, run the following command in the command line: 11 | ``` 12 | $ perl -v 13 | This is perl 5, version 20, subversion 1 (v5.20.1) built for x86_64-linux... # sample output 14 | 15 | $ perl -MCatalyst::Runtime -e 'print Catalyst::Runtime->VERSION' 16 | 5.90112 # sample output 17 | 18 | $ mysql --version 19 | mysql Ver 14.14 Distrib 5.5.52, for debian-linux-gnu (x86_64) using readline 6. # sample output 20 | ``` 21 | 22 | To start this example run commands listed below. 23 | 24 | Clone the repository from github.com: 25 | ``` 26 | $ git clone git@github.com:anychart-integrations/perl-catalyst-mysql-template.git 27 | ``` 28 | 29 | Navigate to the repository folder: 30 | ``` 31 | $ cd perl-catalyst-mysql-template 32 | ``` 33 | Set up MySQL database, use -u -p flags to provide username and password: 34 | ``` 35 | $ mysql < database_backup.sql 36 | ``` 37 | 38 | Install app dependencies, you can use cpanfile or Makefile.PL. 39 | 40 | To use cpanfile, assuming you have [cpanminus](http://search.cpan.org/~miyagawa/App-cpanminus-1.7042/lib/App/cpanminus.pm) installed on your system, run: 41 | ``` 42 | cpanm --installdeps . 43 | ``` 44 | 45 | To use Makefile.PL run: 46 | 47 | ``` 48 | perl Makefile.PL 49 | ``` 50 | The command will show you your dependencies versions. This template is tested with dependencies listed below: 51 | ``` 52 | *** Checking for Perl dependencies... 53 | [Core Features] 54 | - Test::More ...loaded. (1.302062 >= 0.88) 55 | - Catalyst::Runtime ...loaded. (5.90112 >= 5.90112) 56 | - Catalyst::Plugin::ConfigLoader ...loaded. (0.34) 57 | - Catalyst::Plugin::Static::Simple ...loaded. (0.33) 58 | - Catalyst::Action::RenderView ...loaded. (0.16) 59 | - Catalyst::Helper::View::TT ...loaded. (0.44) 60 | - DBD::mysql ...loaded. (4.038) 61 | - DBIx::Class::Schema::Loader ...loaded. (0.07046) 62 | - Catalyst::Helper::Model::DBIC::Schema ...loaded. (0.65) 63 | - Catalyst::Plugin::StackTrace ...loaded. (0.12) 64 | - Moose ...loaded. (2.1806) 65 | - namespace::autoclean ...loaded. (0.28) 66 | - Config::General ...loaded. (2.63) 67 | ``` 68 | 69 | Run example: 70 | ``` 71 | $ script/perlcatalystmysqltemplate_server.pl -r 72 | ``` 73 | 74 | Open browser at http://localhost:3000/ 75 | 76 | ## Workspace 77 | Your workspace should look like: 78 | ``` 79 | perl-catalyst-mysql-template/ 80 | lib/ 81 | PerlCatalystMysqlTemplate/ 82 | Controller/ 83 | Root.pm # main controller 84 | Model/ 85 | DB.pm # MySQL settings 86 | Schema/ 87 | Result/ 88 | Fruit.pm # database model 89 | View/ 90 | HTML.pm # template engine settings 91 | Schema.pm # database schema settings 92 | PerlCatalystMysqlTemplate.pm # main project settings 93 | root/ 94 | root/ 95 | index.tt # HTML template 96 | static/ 97 | css/ 98 | style.css # CSS style 99 | images/ 100 | favicon.ico 101 | script/ # Perl useful scripts 102 | perlcatalystmysqltemplate_cgi.pl 103 | perlcatalystmysqltemplate_create.pl 104 | perlcatalystmysqltemplate_fastcgi.pl 105 | perlcatalystmysqltemplate_server.pl 106 | perlcatalystmysqltemplate_test.pl 107 | t/ # folder for tests 108 | Changes 109 | database_backup.sql # MySQL database dump 110 | LICENSE 111 | Makefile.PL # project makefile 112 | cpanfile # settings for cpanm 113 | perlcatalystmysqltemplate.conf 114 | perlcatalystmysqltemplate.psgi 115 | README.md 116 | 117 | ``` 118 | More about Catalyst folder structure you can read [here](http://search.cpan.org/~hkclark/Catalyst-Manual-5.7021/lib/Catalyst/Manual/Tutorial/CatalystBasics.pod#CREATE_A_CATALYST_PROJECT). 119 | 120 | ## Technologies 121 | Language - [Perl](https://www.perl.org/)
122 | Web framework - [Catalyst](http://www.catalystframework.org/)
123 | Template Engine - [Template Toolkit](http://template-toolkit.org/)
124 | Database - [MySQL](https://www.mysql.com/)
125 | 126 | 127 | ## Further Learning 128 | * [Documentation](https://docs.anychart.com) 129 | * [JavaScript API Reference](https://api.anychart.com) 130 | * [Code Playground](https://playground.anychart.com) 131 | * [Technical Support](https://www.anychart.com/support) 132 | 133 | ## License 134 | AnyChart Perl/Catalyst/MySQL integration sample includes two parts: 135 | - Code of the integration sample that allows to use Javascript library (in this case, AnyChart) with Perl programming language, Catalyst web framework and MySQL database. You can use, edit, modify it, use it with other Javascript libraries without any restrictions. It is released under [Apache 2.0 License](https://github.com/anychart-integrations/perl-catalyst-mysql-template/blob/master/LICENSE). 136 | - AnyChart JavaScript library. It is released under Commercial license. You can test this plugin with the trial version of AnyChart. Our trial version is not limited by time and doesn't contain any feature limitations. Check details [here](https://www.anychart.com/buy/). 137 | 138 | If you have any questions regarding licensing - please contact us. 139 | 140 | [![Analytics](https://ga-beacon.appspot.com/UA-228820-4/Integrations/perl-catalyst-mysql-template?pixel&useReferer)](https://github.com/igrigorik/ga-beacon) 141 | -------------------------------------------------------------------------------- /cpanfile: -------------------------------------------------------------------------------- 1 | requires 'Catalyst::Runtime', '>= 5.90112'; 2 | requires 'Catalyst::Plugin::ConfigLoader'; 3 | requires 'Catalyst::Plugin::Static::Simple'; 4 | requires 'Catalyst::Action::RenderView'; 5 | 6 | requires 'Catalyst::Helper::View::TT'; 7 | requires 'DBD::mysql'; 8 | requires 'DBIx::Class::Schema::Loader'; 9 | requires 'Catalyst::Helper::Model::DBIC::Schema'; 10 | requires 'Catalyst::Plugin::StackTrace'; 11 | 12 | requires 'Moose'; 13 | requires 'namespace::autoclean'; 14 | requires 'Config::General'; 15 | requires 'Test::More', '>= 0.88'; 16 | -------------------------------------------------------------------------------- /database_backup.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS anychart_db; 2 | USE anychart_db; 3 | DROP PROCEDURE IF EXISTS init; 4 | DELIMITER // 5 | CREATE PROCEDURE init () 6 | LANGUAGE SQL 7 | BEGIN 8 | DECLARE user_exist, data_present INT; 9 | SET user_exist = (SELECT EXISTS (SELECT DISTINCT user FROM mysql.user WHERE user = "anychart_user")); 10 | IF user_exist = 0 THEN 11 | CREATE USER 'anychart_user'@'localhost' IDENTIFIED BY 'anychart_pass'; 12 | GRANT ALL PRIVILEGES ON anychart_db.* TO 'anychart_user'@'localhost'; 13 | FLUSH PRIVILEGES; 14 | END IF; 15 | CREATE TABLE IF NOT EXISTS fruits ( 16 | id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 17 | name VARCHAR(64), 18 | value INT 19 | ); 20 | SET data_present = (SELECT COUNT(*) FROM fruits); 21 | IF data_present = 0 THEN 22 | INSERT INTO fruits (name, value) VALUES 23 | ('apples', 10), 24 | ('oranges', 20), 25 | ('bananas', 15), 26 | ('lemons', 5), 27 | ('pears', 3), 28 | ('apricots', 7), 29 | ('kiwis', 9), 30 | ('mangos', 12), 31 | ('figs', 4), 32 | ('limes', 8); 33 | END IF; 34 | END;// 35 | DELIMITER ; 36 | CALL init(); -------------------------------------------------------------------------------- /lib/PerlCatalystMysqlTemplate.pm: -------------------------------------------------------------------------------- 1 | package PerlCatalystMysqlTemplate; 2 | use Moose; 3 | use namespace::autoclean; 4 | 5 | use Catalyst::Runtime 5.80; 6 | 7 | # Set flags and add plugins for the application. 8 | # 9 | # Note that ORDERING IS IMPORTANT here as plugins are initialized in order, 10 | # therefore you almost certainly want to keep ConfigLoader at the head of the 11 | # list if you're using it. 12 | # 13 | # -Debug: activates the debug mode for very useful log messages 14 | # ConfigLoader: will load the configuration from a Config::General file in the 15 | # application's home directory 16 | # Static::Simple: will serve static files from the application's root 17 | # directory 18 | 19 | use Catalyst qw/ 20 | -Debug 21 | ConfigLoader 22 | Static::Simple 23 | 24 | StackTrace 25 | /; 26 | 27 | extends 'Catalyst'; 28 | 29 | our $VERSION = '0.01'; 30 | 31 | # Configure the application. 32 | # 33 | # Note that settings in perlcatalystmysqltemplate.conf (or other external 34 | # configuration file that you set up manually) take precedence 35 | # over this when using ConfigLoader. Thus configuration 36 | # details given here can function as a default configuration, 37 | # with an external configuration file acting as an override for 38 | # local deployment. 39 | 40 | __PACKAGE__->config( 41 | name => 'PerlCatalystMysqlTemplate', 42 | # Disable deprecated behavior needed by old applications 43 | disable_component_resolution_regex_fallback => 1, 44 | enable_catalyst_header => 1, # Send X-Catalyst header 45 | ); 46 | 47 | # Start the application 48 | __PACKAGE__->setup(); 49 | 50 | =encoding utf8 51 | 52 | =head1 NAME 53 | 54 | PerlCatalystMysqlTemplate - Catalyst based application 55 | 56 | =head1 SYNOPSIS 57 | 58 | script/perlcatalystmysqltemplate_server.pl 59 | 60 | =head1 DESCRIPTION 61 | 62 | [enter your description here] 63 | 64 | =head1 SEE ALSO 65 | 66 | L, L 67 | 68 | =head1 AUTHOR 69 | 70 | Igor,,, 71 | 72 | =head1 LICENSE 73 | 74 | This library is free software. You can redistribute it and/or modify 75 | it under the same terms as Perl itself. 76 | 77 | =cut 78 | 79 | 1; 80 | -------------------------------------------------------------------------------- /lib/PerlCatalystMysqlTemplate/Controller/Root.pm: -------------------------------------------------------------------------------- 1 | package PerlCatalystMysqlTemplate::Controller::Root; 2 | use Moose; 3 | use namespace::autoclean; 4 | use JSON; 5 | 6 | BEGIN { extends 'Catalyst::Controller' } 7 | 8 | # 9 | # Sets the actions in this controller to be registered with no prefix 10 | # so they function identically to actions created in MyApp.pm 11 | # 12 | __PACKAGE__->config(namespace => ''); 13 | 14 | =encoding utf-8 15 | 16 | =head1 NAME 17 | 18 | PerlCatalystMysqlTemplate::Controller::Root - Root Controller for PerlCatalystMysqlTemplate 19 | 20 | =head1 DESCRIPTION 21 | 22 | [enter your description here] 23 | 24 | =head1 METHODS 25 | 26 | =head2 index 27 | 28 | The root page (/) 29 | 30 | =cut 31 | 32 | sub index :Path :Args(0) { 33 | my ( $self, $c ) = @_; 34 | 35 | # get fruits data from database 36 | my @fruits = $c->model('DB::Fruit')->search(undef, {order_by => {-desc => 'value'}, rows => 5})->all; 37 | foreach my $f (@fruits) 38 | { 39 | $f = {name => $f->name, value => $f->value}; 40 | } 41 | my $data = JSON->new->utf8->allow_blessed->convert_blessed->encode([@fruits]); 42 | 43 | # pass data to HTML template 44 | $c->stash(chartData => $data, 45 | title => "Perl Catalyst template", 46 | chartTitle => "Top 5 fruits" 47 | ); 48 | $c->stash(template => 'root/index.tt'); 49 | } 50 | 51 | =head2 default 52 | 53 | Standard 404 error page 54 | 55 | =cut 56 | 57 | sub default :Path { 58 | my ( $self, $c ) = @_; 59 | $c->response->body( 'Page not found' ); 60 | $c->response->status(404); 61 | } 62 | 63 | =head2 end 64 | 65 | Attempt to render a view, if needed. 66 | 67 | =cut 68 | 69 | sub end : ActionClass('RenderView') {} 70 | 71 | =head1 AUTHOR 72 | 73 | Igor,,, 74 | 75 | =head1 LICENSE 76 | 77 | This library is free software. You can redistribute it and/or modify 78 | it under the same terms as Perl itself. 79 | 80 | =cut 81 | 82 | __PACKAGE__->meta->make_immutable; 83 | 84 | 1; 85 | -------------------------------------------------------------------------------- /lib/PerlCatalystMysqlTemplate/Model/DB.pm: -------------------------------------------------------------------------------- 1 | package PerlCatalystMysqlTemplate::Model::DB; 2 | 3 | use strict; 4 | use base 'Catalyst::Model::DBIC::Schema'; 5 | 6 | __PACKAGE__->config( 7 | schema_class => 'PerlCatalystMysqlTemplate::Schema', 8 | 9 | connect_info => { 10 | dsn => 'dbi:mysql:anychart_db', 11 | user => 'anychart_user', 12 | password => 'anychart_pass', 13 | AutoCommit => q{1}, 14 | } 15 | ); 16 | 17 | =head1 NAME 18 | 19 | PerlCatalystMysqlTemplate::Model::DB - Catalyst DBIC Schema Model 20 | 21 | =head1 SYNOPSIS 22 | 23 | See L 24 | 25 | =head1 DESCRIPTION 26 | 27 | L Model using schema L 28 | 29 | =head1 GENERATED BY 30 | 31 | Catalyst::Helper::Model::DBIC::Schema - 0.65 32 | 33 | =head1 AUTHOR 34 | 35 | Igor 36 | 37 | =head1 LICENSE 38 | 39 | This library is free software, you can redistribute it and/or modify 40 | it under the same terms as Perl itself. 41 | 42 | =cut 43 | 44 | 1; 45 | -------------------------------------------------------------------------------- /lib/PerlCatalystMysqlTemplate/Schema.pm: -------------------------------------------------------------------------------- 1 | use utf8; 2 | package PerlCatalystMysqlTemplate::Schema; 3 | 4 | # Created by DBIx::Class::Schema::Loader 5 | # DO NOT MODIFY THE FIRST PART OF THIS FILE 6 | 7 | use Moose; 8 | use MooseX::MarkAsMethods autoclean => 1; 9 | extends 'DBIx::Class::Schema'; 10 | 11 | __PACKAGE__->load_namespaces; 12 | 13 | 14 | # Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-03 12:32:03 15 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T1amix1dGE4nT2RFfYdixA 16 | 17 | 18 | # You can replace this text with custom code or comments, and it will be preserved on regeneration 19 | __PACKAGE__->meta->make_immutable(inline_constructor => 0); 20 | 1; 21 | -------------------------------------------------------------------------------- /lib/PerlCatalystMysqlTemplate/Schema/Result/Fruit.pm: -------------------------------------------------------------------------------- 1 | use utf8; 2 | package PerlCatalystMysqlTemplate::Schema::Result::Fruit; 3 | 4 | # Created by DBIx::Class::Schema::Loader 5 | # DO NOT MODIFY THE FIRST PART OF THIS FILE 6 | 7 | =head1 NAME 8 | 9 | PerlCatalystMysqlTemplate::Schema::Result::Fruit 10 | 11 | =cut 12 | 13 | use strict; 14 | use warnings; 15 | 16 | use Moose; 17 | use MooseX::NonMoose; 18 | use MooseX::MarkAsMethods autoclean => 1; 19 | extends 'DBIx::Class::Core'; 20 | 21 | =head1 COMPONENTS LOADED 22 | 23 | =over 4 24 | 25 | =item * L 26 | 27 | =back 28 | 29 | =cut 30 | 31 | __PACKAGE__->load_components("InflateColumn::DateTime"); 32 | 33 | =head1 TABLE: C 34 | 35 | =cut 36 | 37 | __PACKAGE__->table("fruits"); 38 | 39 | =head1 ACCESSORS 40 | 41 | =head2 id 42 | 43 | data_type: 'integer' 44 | is_auto_increment: 1 45 | is_nullable: 0 46 | 47 | =head2 name 48 | 49 | data_type: 'varchar' 50 | is_nullable: 1 51 | size: 64 52 | 53 | =head2 value 54 | 55 | data_type: 'integer' 56 | is_nullable: 1 57 | 58 | =cut 59 | 60 | __PACKAGE__->add_columns( 61 | "id", 62 | { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, 63 | "name", 64 | { data_type => "varchar", is_nullable => 1, size => 64 }, 65 | "value", 66 | { data_type => "integer", is_nullable => 1 }, 67 | ); 68 | 69 | =head1 PRIMARY KEY 70 | 71 | =over 4 72 | 73 | =item * L 74 | 75 | =back 76 | 77 | =cut 78 | 79 | __PACKAGE__->set_primary_key("id"); 80 | 81 | 82 | # Created by DBIx::Class::Schema::Loader v0.07046 @ 2016-11-03 12:32:03 83 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LlN9sWX+qhWTuwb6P7atLA 84 | 85 | 86 | # You can replace this text with custom code or comments, and it will be preserved on regeneration 87 | __PACKAGE__->meta->make_immutable; 88 | 1; 89 | -------------------------------------------------------------------------------- /lib/PerlCatalystMysqlTemplate/View/HTML.pm: -------------------------------------------------------------------------------- 1 | package PerlCatalystMysqlTemplate::View::HTML; 2 | use Moose; 3 | use namespace::autoclean; 4 | 5 | extends 'Catalyst::View::TT'; 6 | 7 | __PACKAGE__->config( 8 | TEMPLATE_EXTENSION => '.tt', 9 | render_die => 1, 10 | ); 11 | 12 | =head1 NAME 13 | 14 | PerlCatalystMysqlTemplate::View::HTML - TT View for PerlCatalystMysqlTemplate 15 | 16 | =head1 DESCRIPTION 17 | 18 | TT View for PerlCatalystMysqlTemplate. 19 | 20 | =head1 SEE ALSO 21 | 22 | L 23 | 24 | =head1 AUTHOR 25 | 26 | Igor,,, 27 | 28 | =head1 LICENSE 29 | 30 | This library is free software. You can redistribute it and/or modify 31 | it under the same terms as Perl itself. 32 | 33 | =cut 34 | 35 | 1; 36 | -------------------------------------------------------------------------------- /perlcatalystmysqltemplate.conf: -------------------------------------------------------------------------------- 1 | # rename this file to perlcatalystmysqltemplate.yml and put a ':' after 'name' if 2 | # you want to use YAML like in old versions of Catalyst 3 | name PerlCatalystMysqlTemplate 4 | -------------------------------------------------------------------------------- /perlcatalystmysqltemplate.psgi: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use PerlCatalystMysqlTemplate; 5 | 6 | my $app = PerlCatalystMysqlTemplate->apply_default_middlewares(PerlCatalystMysqlTemplate->psgi_app); 7 | $app; 8 | 9 | -------------------------------------------------------------------------------- /root/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/favicon.ico -------------------------------------------------------------------------------- /root/root/index.tt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | [% title %] 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 23 | 24 | -------------------------------------------------------------------------------- /root/static/css/style.css: -------------------------------------------------------------------------------- 1 | html, body, #container { 2 | width: 400px; 3 | height: 400px; 4 | margin: 0; 5 | padding: 0; 6 | } -------------------------------------------------------------------------------- /root/static/images/btn_120x50_built.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_120x50_built.png -------------------------------------------------------------------------------- /root/static/images/btn_120x50_built_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_120x50_built_shadow.png -------------------------------------------------------------------------------- /root/static/images/btn_120x50_powered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_120x50_powered.png -------------------------------------------------------------------------------- /root/static/images/btn_120x50_powered_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_120x50_powered_shadow.png -------------------------------------------------------------------------------- /root/static/images/btn_88x31_built.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_88x31_built.png -------------------------------------------------------------------------------- /root/static/images/btn_88x31_built_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_88x31_built_shadow.png -------------------------------------------------------------------------------- /root/static/images/btn_88x31_powered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_88x31_powered.png -------------------------------------------------------------------------------- /root/static/images/btn_88x31_powered_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/btn_88x31_powered_shadow.png -------------------------------------------------------------------------------- /root/static/images/catalyst_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anychart-integrations/perl-catalyst-mysql-template/9436b8a1e1c6dfd64b3a4e979d0a755c2440c5a9/root/static/images/catalyst_logo.png -------------------------------------------------------------------------------- /script/perlcatalystmysqltemplate_cgi.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use Catalyst::ScriptRunner; 4 | Catalyst::ScriptRunner->run('PerlCatalystMysqlTemplate', 'CGI'); 5 | 6 | 1; 7 | 8 | =head1 NAME 9 | 10 | perlcatalystmysqltemplate_cgi.pl - Catalyst CGI 11 | 12 | =head1 SYNOPSIS 13 | 14 | See L 15 | 16 | =head1 DESCRIPTION 17 | 18 | Run a Catalyst application as a CGI script. 19 | 20 | =head1 AUTHORS 21 | 22 | Catalyst Contributors, see Catalyst.pm 23 | 24 | =head1 COPYRIGHT 25 | 26 | This library is free software. You can redistribute it and/or modify 27 | it under the same terms as Perl itself. 28 | 29 | =cut 30 | 31 | -------------------------------------------------------------------------------- /script/perlcatalystmysqltemplate_create.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Catalyst::ScriptRunner; 7 | Catalyst::ScriptRunner->run('PerlCatalystMysqlTemplate', 'Create'); 8 | 9 | 1; 10 | 11 | =head1 NAME 12 | 13 | perlcatalystmysqltemplate_create.pl - Create a new Catalyst Component 14 | 15 | =head1 SYNOPSIS 16 | 17 | perlcatalystmysqltemplate_create.pl [options] model|view|controller name [helper] [options] 18 | 19 | Options: 20 | --force don't create a .new file where a file to be created exists 21 | --mechanize use Test::WWW::Mechanize::Catalyst for tests if available 22 | --help display this help and exits 23 | 24 | Examples: 25 | perlcatalystmysqltemplate_create.pl controller My::Controller 26 | perlcatalystmysqltemplate_create.pl --mechanize controller My::Controller 27 | perlcatalystmysqltemplate_create.pl view My::View 28 | perlcatalystmysqltemplate_create.pl view HTML TT 29 | perlcatalystmysqltemplate_create.pl model My::Model 30 | perlcatalystmysqltemplate_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\ 31 | dbi:SQLite:/tmp/my.db 32 | perlcatalystmysqltemplate_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\ 33 | [Loader opts like db_schema, naming] dbi:Pg:dbname=foo root 4321 34 | [connect_info opts like quote_char, name_sep] 35 | 36 | See also: 37 | perldoc Catalyst::Manual 38 | perldoc Catalyst::Manual::Intro 39 | perldoc Catalyst::Helper::Model::DBIC::Schema 40 | perldoc Catalyst::Model::DBIC::Schema 41 | perldoc Catalyst::View::TT 42 | 43 | =head1 DESCRIPTION 44 | 45 | Create a new Catalyst Component. 46 | 47 | Existing component files are not overwritten. If any of the component files 48 | to be created already exist the file will be written with a '.new' suffix. 49 | This behavior can be suppressed with the C<-force> option. 50 | 51 | =head1 AUTHORS 52 | 53 | Catalyst Contributors, see Catalyst.pm 54 | 55 | =head1 COPYRIGHT 56 | 57 | This library is free software. You can redistribute it and/or modify 58 | it under the same terms as Perl itself. 59 | 60 | =cut 61 | -------------------------------------------------------------------------------- /script/perlcatalystmysqltemplate_fastcgi.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use Catalyst::ScriptRunner; 4 | Catalyst::ScriptRunner->run('PerlCatalystMysqlTemplate', 'FastCGI'); 5 | 6 | 1; 7 | 8 | =head1 NAME 9 | 10 | perlcatalystmysqltemplate_fastcgi.pl - Catalyst FastCGI 11 | 12 | =head1 SYNOPSIS 13 | 14 | perlcatalystmysqltemplate_fastcgi.pl [options] 15 | 16 | Options: 17 | -? --help display this help and exit 18 | -l --listen socket path to listen on 19 | (defaults to standard input) 20 | can be HOST:PORT, :PORT or a 21 | filesystem path 22 | -n --nproc specify number of processes to keep 23 | to serve requests (defaults to 1, 24 | requires --listen) 25 | -p --pidfile specify filename for pid file 26 | (requires --listen) 27 | -d --daemon daemonize (requires --listen) 28 | -M --manager specify alternate process manager 29 | (FCGI::ProcManager sub-class) 30 | or empty string to disable 31 | -e --keeperr send error messages to STDOUT, not 32 | to the webserver 33 | --proc_title Set the process title (if possible) 34 | 35 | =head1 DESCRIPTION 36 | 37 | Run a Catalyst application as FastCGI. 38 | 39 | =head1 AUTHORS 40 | 41 | Catalyst Contributors, see Catalyst.pm 42 | 43 | =head1 COPYRIGHT 44 | 45 | This library is free software. You can redistribute it and/or modify 46 | it under the same terms as Perl itself. 47 | 48 | =cut 49 | -------------------------------------------------------------------------------- /script/perlcatalystmysqltemplate_server.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | BEGIN { 4 | $ENV{CATALYST_SCRIPT_GEN} = 40; 5 | } 6 | 7 | use Catalyst::ScriptRunner; 8 | Catalyst::ScriptRunner->run('PerlCatalystMysqlTemplate', 'Server'); 9 | 10 | 1; 11 | 12 | =head1 NAME 13 | 14 | perlcatalystmysqltemplate_server.pl - Catalyst Test Server 15 | 16 | =head1 SYNOPSIS 17 | 18 | perlcatalystmysqltemplate_server.pl [options] 19 | 20 | -d --debug force debug mode 21 | -f --fork handle each request in a new process 22 | (defaults to false) 23 | -? --help display this help and exits 24 | -h --host host (defaults to all) 25 | -p --port port (defaults to 3000) 26 | -k --keepalive enable keep-alive connections 27 | -r --restart restart when files get modified 28 | (defaults to false) 29 | -rd --restart_delay delay between file checks 30 | (ignored if you have Linux::Inotify2 installed) 31 | -rr --restart_regex regex match files that trigger 32 | a restart when modified 33 | (defaults to '\.yml$|\.yaml$|\.conf|\.pm$') 34 | --restart_directory the directory to search for 35 | modified files, can be set multiple times 36 | (defaults to '[SCRIPT_DIR]/..') 37 | --follow_symlinks follow symlinks in search directories 38 | (defaults to false. this is a no-op on Win32) 39 | --background run the process in the background 40 | --pidfile specify filename for pid file 41 | 42 | See also: 43 | perldoc Catalyst::Manual 44 | perldoc Catalyst::Manual::Intro 45 | 46 | =head1 DESCRIPTION 47 | 48 | Run a Catalyst Testserver for this application. 49 | 50 | =head1 AUTHORS 51 | 52 | Catalyst Contributors, see Catalyst.pm 53 | 54 | =head1 COPYRIGHT 55 | 56 | This library is free software. You can redistribute it and/or modify 57 | it under the same terms as Perl itself. 58 | 59 | =cut 60 | 61 | -------------------------------------------------------------------------------- /script/perlcatalystmysqltemplate_test.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use Catalyst::ScriptRunner; 4 | Catalyst::ScriptRunner->run('PerlCatalystMysqlTemplate', 'Test'); 5 | 6 | 1; 7 | 8 | =head1 NAME 9 | 10 | perlcatalystmysqltemplate_test.pl - Catalyst Test 11 | 12 | =head1 SYNOPSIS 13 | 14 | perlcatalystmysqltemplate_test.pl [options] uri 15 | 16 | Options: 17 | --help display this help and exits 18 | 19 | Examples: 20 | perlcatalystmysqltemplate_test.pl http://localhost/some_action 21 | perlcatalystmysqltemplate_test.pl /some_action 22 | 23 | See also: 24 | perldoc Catalyst::Manual 25 | perldoc Catalyst::Manual::Intro 26 | 27 | =head1 DESCRIPTION 28 | 29 | Run a Catalyst action from the command line. 30 | 31 | =head1 AUTHORS 32 | 33 | Catalyst Contributors, see Catalyst.pm 34 | 35 | =head1 COPYRIGHT 36 | 37 | This library is free software. You can redistribute it and/or modify 38 | it under the same terms as Perl itself. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /t/01app.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use Catalyst::Test 'PerlCatalystMysqlTemplate'; 7 | 8 | ok( request('/')->is_success, 'Request should succeed' ); 9 | 10 | done_testing(); 11 | -------------------------------------------------------------------------------- /t/02pod.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; 7 | eval "use Test::Pod 1.14"; 8 | plan skip_all => 'Test::Pod 1.14 required' if $@; 9 | 10 | all_pod_files_ok(); 11 | -------------------------------------------------------------------------------- /t/03podcoverage.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; 7 | 8 | eval "use Test::Pod::Coverage 1.04"; 9 | plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; 10 | 11 | eval "use Pod::Coverage 0.20"; 12 | plan skip_all => 'Pod::Coverage 0.20 required' if $@; 13 | 14 | all_pod_coverage_ok(); 15 | -------------------------------------------------------------------------------- /t/model_DB.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | 6 | BEGIN { use_ok 'PerlCatalystMysqlTemplate::Model::DB' } 7 | 8 | done_testing(); 9 | -------------------------------------------------------------------------------- /t/view_HTML.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | 6 | BEGIN { use_ok 'PerlCatalystMysqlTemplate::View::HTML' } 7 | 8 | done_testing(); 9 | --------------------------------------------------------------------------------