• t2_345327
  • 157KB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-06-01 00:11
预约时间表 一个由jQuery和PERL支持的基本Create-Read应用程序。 安装 经测试仅适用于Ubuntu 16.04 下载网站 将其克隆到您的开发目录中。 我总是使用/ opt /,所以我要在那做: cd /opt/ git clone appointment cd appointment 组织 db/保存数据库 web/包含所有与Web相关的文件 /web/assets/vendor具有第三方框架(jQuery,timepicker等) web/assets/js主要有一个用于此站点的.js文件 web/assets/css自定义css cgi-bin具有所有Perl脚本(模块) 依存关系 安装JSON和CGI模块。 sudo cpan JSON sudo cpan CGI C
# Appointment Scheduler A basic Create-Read application backed by jQuery and PERL. ### Installation It is only tested to work for Ubuntu 16.04 ### Download the site Clone this into your development directory. I always use /opt/, so I am going to do it there: ``` cd /opt/ git clone appointment cd appointment ``` ### Organization * `db/` holds the database * `web/` contains all web related files * `/web/assets/vendor` has third party frameworks (jQuery, timepicker, etc) * `web/assets/js` has mainly one .js file used for this site * `web/assets/css` custom css * `cgi-bin` has all Perl scripts (Modules) ### Dependencies Install JSON and CGI modules. ``` sudo cpan JSON sudo cpan CGI ``` * CGI is great for handling Common Gateway Interface requests and responses (`POST` and `GET`). You can read about its details [here]( * JSON for general JSON processing. You can also read about the module [here]( Then, since this is a database based application, we need to have a database interface. For this, PERL has a common interface, DBI whose details can be found [here]( For this case, we will also need a SQLite specific driver (DBD::SQLite) which allows PERL to talk to SQLite. If you don't have sqlite installed in Ubuntu you can run install it by running this command: ``` sudo apt-get install sqlite3 ``` Then, to install DBI and DBD::SQLite run these commands ``` sudo cpan DBI sudo cpan DBD::SQLite ``` ## Enable CGI module To be able to run a CGI-backed application, we need to have CGI enabled in apache2. This CGI module is different from the one that we have just installed above. This is the module which enables apache2 to run CGI scripts and direct their output to _a web browser_. Since Ubuntu 14.04 to 16.04 configurations for apache2 changed. I hope they have not for 18.04 as I have not yet tested. But, we will need to make sure the following: * That the cgi-bin configuration have been enabled. If you do not have this file `/etc/apache2/conf-enabled/serve-cgi-bin.conf` (which is set by default) then you need to run the command below, otherwise (if you do) you don't have to run the command: ``` sudo ln -s /etc/apache2/conf-available/serve-cgi-bin.conf /etc/apache2/conf-enabled/serve-cgi-bin.conf ``` * That the CGI module has also been enabled. For some reason, the CGI module is not enabled by default like the CGI conf. So, you will need to run this command in order to enable CGI for the web server. ``` sudo ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load ``` After running these two commands, then you need to reload the web server for the new configurations to take place. ## Serving our CGI scripts By default, apache2 looks for cgi-scripts in the path `/usr/lib/cgi-bin/`, which means we have two options: * Keep all our scripts there, and take advantage of the readily available system configuration for security! OR * Create our own directory to host our CGI scripts. this comes with a caveat. We will need to either use .htaccess file (which experts say .htaccess files have an impact on performance). If we decide to go by the first option, we do not need to keep our files there, we will instead make use a SymLink and allow apache to follow Symbolic links. For this application to run, we will need to run these commands: ``` sudo ln -s /opt/appointment/cgi-bin /usr/lib/cgi-bin/appointment sudo chmod 755 /usr/lib/cgi-bin/appointment ``` ### Allow apache2 to follow symbolic links This is important so that apache2 can serve our scripts which have been symlinked to the default cgi-bin. Then open this file `/etc/apache2/conf-available/serve-cgi-bin.conf` and change the this part in the file to look like below: ``` <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +FollowSymLinks Require all granted </Directory> ``` ## Create database Create database in db/appointment.db. Make sure the ownership of db is set to www-data. Otherwise, the app is going to fail to write. Change the ownership by running the command ``` sudo chown db www-data:www-data db ``` If the database is not created, the system creates it automatically. ## Starting the site At this point hoping everything went OK (there maybe surprises at times though), we need to launch our app. We make our site available to apache2 ``` sudo ln -s /opt/appointment/web /var/www/html/appointment ``` We will restart apache2 webserver by running the command ``` sudo service apache2 restart ``` and then visit the site through [this url](http://localhost/appointment) (http://localhost/appointment) ## My take-away points for learning PERL in about 18 hrs * I used approximately 18 hrs, main challenge being most materials to learn PERL are old and looks like there's not many Monks in the PERL monasteries these days. I could hardly see support questions posted after 2016, maybe all those who use PERL are experts or there's nobody using PERL. * The syntax is a bit different from other common languages that I have worked with. Yes, there's semicolons, and curly braces and parentheses and the arrow operator, but the hashes syntax the functions and Modules (equivalents of classes) is not very intuitive. * It is a nice language, I would want to do another non-trivial project in one of the next weekends. For the coming days I will keep learning this to become more familiar. * Everytime I learn a new language, (not only a programming language), I realize I become better at languages that I already know. A new language gives us a new perspective to look at what we already know. ## Areas of improvement: * Set own configuration for cgi-bin for this site only. This would still require changing AllowOverride in the global apache config. * Organize jQuery code into modules. However the literal was OK for this case considering the time I had. * Create a more elegant database abstraction for DBI and DBD::SQLite using modules. * Create a docker image (DockerFile) to make the setup process easier and more portable. * These resources have been very useful in the process * [Zetcode Perl SQLite Tutorial]( * [Introductory Perl Tutorial Course for Windows]( * [Gabor Szabo's Perl Tutorial]( * Gabor Szabo Perlmaven is a very great site I would recommend. * [Programming the Perl DBI]( * [Perl Monks site]( * [University of Washington Perl Reference](
    • introduction-to-git:https
      谨慎使用 Git 丸山新平 介绍 本文档旨在以通俗易懂的方式解释 Git 的基本概念和用法。通过阅读本书 易于使用的 Git 你可以使用一个分支 多人可以一起工作 如果你有任何问题,你可以用谷歌找出“我应该查什么词” ...
    • git 教材 progit
    • git-kurs:na podstawie https
      git-kurs:na podstawie https
    • TVDbLib:httpsGit 克隆
      电视数据库 Git 克隆
    • git-mdp:mdp (https
      git-mdp 用于介绍 git 的甲板
    • Git环境搭建
      NULL 博文链接:
    • Git学习笔记
      NULL 博文链接:
    • git GUI使用
      NULL 博文链接:
    • git学习
      NULL 博文链接:
    • Git 中文教程
      NULL 博文链接: