A summary of the initial attempt of web framework under OpenWrt

Source: Internet
Author: User

Web summary under OpenWRT

Directory

Catalog 1

Chapter One Web Framework and implementation 2

Section Luci frame 2

Section II Preparation of the next controller file (*.lua) 2

Section III model under document (*.lua) compilation 3

Fourth section view under document (*.htm) 4

Chapter II the Web Access Process 5

Chapter III LUA learning materials 6

Reference 7


The first chapter of the WEB framework and implementation

The first section Luci Frame

OpenWRTof theWebadopted is theLuciFramework, the framework uses aMVCdesign pattern. In theLuciThere are three important directories under the directory:Controller,Model,View. The front-endhtmfiles are placed inViewThe logical control files are placed in theControllerNext, some map generationhtmThe template is placed in theModelthe next.

Controller Directory: organizes all the "logical processing" that is used, by registering "tree nodes". In other words, all the logical processing, like the branches of the tree, organized together.

Model: Business processing and the production of htm templates.

View:htm file.

Online reference:

Http://www.verydemo.com/demo_c101_i48675.html

Http://www.verydemo.com/demo_c101_i42459.html

Section II Preparation of the next controller file (*.lua)

As described in the first section, thecontroller 's role in the Luci Framework is logically organized. The code is divided into two main pieces:

1 "Branch registration"--- module registration

2 "leaf registration"--- node registration

1 Module Registration

such as:module ("Luci.controller.admin.system", Package.seeall)

Explanation: Indicates that a system module is registered under luci/controller/admin/

2 Node Registration

Line 1:Function index ()

Line 2:entry({"admin", "System", "system"}, CBI ("Admin_system/system"), _ ("System"), 1)

Line 3:End

Line 1 and line 3 will represent a function block

Line 2: indicates that a node of system is registered under the admin/system module, the node sequence is 1, CBI(discussed later)

Note: The fourth parameter sequence in line 2 is important, and it affects the order of display on the web

Entry () function Analysis:

parameter one: Insert the name of the node , such as:{ "Admin", "system", "HEYG1"}, which means insert in system under admin node heyg1

Parameter two: What to do when the HEYG1 node is inserted (what is the action), usually in the following ways:

Mode one: thetemplate mode, that is, the node will directly invoke the corresponding htm file under view

Mode two:cbi/form mode, will call the model under the corresponding file to do the corresponding processing

Method Three: call mode, will invoke the file or import the function of the file

Other ways:

Alias: Indicates a link to a different node

here the template ("heyg/heyg1") will call view/heyg/heyg1.htm file

Parameter three: The name of the insertion node in the corresponding location, the display name in the corresponding menu in the Web interface

here _ ("heyg1"), displayed as heyg1 in the Web menu

Parameter four: Different classifications of the same level of the insertion node, or the number code of the other nodes that distinguish the same level

Here 3, cannot repeat with other options under the same level

In the menu level is small to large display such as:system(1),Administration (2),heyg1 (3) ....

Some properties of the Entry () function parse: For inserting a node, the node has a corresponding name and processing action, It also has some corresponding properties that we can manually set its property value to resemble entry (). Dependent=false

The following attributes are given in official text denier:

Dependent: When the parent node of the node is lost, the node is protected from accidental invocation .

Leaf: If there are other child nodes under the node, it will not continue to parse its child nodes as it resolves to it.

Sysauth: Requires a System account verification when using this node

i18n: Defines which files are loaded automatically when requesting a page

Other attributes (purely self-guessing, if there is not right, a lot of advice, do not spray):

Index: The node as the first page in the sibling directory, or the default

Official website:http://luci.subsignal.org/trac/wiki/Documentation

Blog:http://blog.csdn.net/ubuntucc/article/details/41083687

Section III model under document (*.lua) written

Http://www.tuicool.com/articles/zaUNfy

Http://blog.chinaunix.net/uid-23780428-id-4367351.html

Fourth section view under File (*.htm) Writing

Embed Lua script,htm,JS multiple Statements


Chapter II The Web Access process

Http://blog.chinaunix.net/uid-23780428-id-4367414.html

data interaction in the Web in http://www.cnblogs.com/gnuhpc/archive/2013/08/31/3293643.html


Chapter III LUA learning materials

English manual:

Http://www.lua.org/manual/5.1/index.html

Chinese manual:

Http://www.codingnow.com/2000/download/lua_manual.html

Lua Learning Tutorials:

Http://lua-users.org/wiki/TutorialDirectory

The function interfaces that appear in most LUA statement parsing:

http://blog.csdn.net/chinazhd/article/details/7776994

NB Blogs and Learning articles

http://blog.csdn.net/xoyojank/article/details/12762909

http://xuzhihong1987.blog.163.com/blog/static/26731587201171152614685/


Resources

Configure Makefile on Luci:

Http://luci.subsignal.org/trac/wiki/Documentation/Modules


Cbi:

Http://luci.subsignal.org/trac/wiki/Documentation/CBI


Luci:

Http://luci.subsignal.org/trac/wiki/Documentation/ModulesHowTo


function definitions and usage instructions for the Luci Class library:

Http://luci.subsignal.org/api/luci/index.html


UCI interface:

Http://wiki.openwrt.org/doc/devel/config-scripting

A summary of the initial attempt of web framework under OpenWrt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.