- CodeIgniter Web Application Blueprints
- Rob Foster
- 520字
- 2021-08-06 19:34:29
Design and wireframes
Before we start building, we should always take a look at what we plan to build.
Firstly, a brief description of our intent: we plan to build an app that will display a simple form to the user. The user will be encouraged to enter a URL into the form and submit that form.
A unique code will be generated and associated with the URL entered by the user. This URL and unique code will be saved to a database.
A new URL will be shown to the user containing the unique code we just generated. That unique code will be appended to the URL of the app we're building. Should the user (or anyone else) click on that link, the app will look up the unique code in the database. If the unique code exists, it will redirect the user to the original URL associated with that unique code.
So, let's take a look at some wireframes to help us understand what this might look like on screen:

This is the first page that the user will see. The user is invited to enter a URL into the textbox and hit the Go button.
The page will be submitted and code will be generated. Both this code and the original URL will be saved to the database. The user will then see the new URL we've just created for them. They can copy that URL to their clipboard (for pasting into an e-mail and so on) or click on it there and then if they wish. This is shown in the following screenshot:

File overview
We're going to create six files for this application, as follows:
/path/to/codeigniter/application/models/urls_model.php
: This file provides access to the database and allows us to create theurl_code
, save the record to the database, and also retrieve the original URL from the database./path/to/codeigniter/application/views/create/create.php
: This file provides us with our interface, the user facing form, and any messages needed to inform the user of their actions or the system's actions./path/to/codeigniter/application/views/nav/top_nav.php
: This file provides a navigation bar at the top of the page./path/to/codeigniter/application/controllers/create.php
: This file performs validation checks on the URL inputted by the user, calls any helpers, and so on./path/to/codeigniter/application/controllers/go.php
: This file provides support for shortened URLs. It gets the unique code parameter from the URI (first segment), sends it to theUrls_model,
and redirects the user to the associatedurl_address
if it exists./path/to/codeigniter/application/language/english/en_admin_lang.php
: This file provides language support for the application.
The file structure of the preceding six files is as follows:
application/ ├── controllers/ │ ├── create.php │ ├── go.php ├── models/ │ ├── urls_model.php ├── views/create/ │ ├── create.php ├── views/nav/ │ ├── top_nav.php ├── language/english/ ├── en_admin_lang.php
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
- iOS面試一戰(zhàn)到底
- C語言程序設(shè)計(jì)(第3版)
- 劍指JVM:虛擬機(jī)實(shí)踐與性能調(diào)優(yōu)
- Java面向?qū)ο蟪绦蜷_發(fā)及實(shí)戰(zhàn)
- Backbone.js Blueprints
- Go并發(fā)編程實(shí)戰(zhàn)
- Hands-On Automation Testing with Java for Beginners
- 劍指Java:核心原理與應(yīng)用實(shí)踐
- jQuery炫酷應(yīng)用實(shí)例集錦
- Internet of Things with ESP8266
- Rust游戲開發(fā)實(shí)戰(zhàn)
- Beginning C++ Game Programming
- C++程序設(shè)計(jì)
- Visual C++程序設(shè)計(jì)與項(xiàng)目實(shí)踐
- Xamarin Cross-Platform Development Cookbook