在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):sailorproject/sailor开源软件地址(OpenSource Url):https://github.com/sailorproject/sailor开源编程语言(OpenSource Language):Lua 90.6%开源软件介绍(OpenSource Introduction):SailorWE ARE LOOKING FOR NEW MAINTAINERS!Features
Roadmap
More about the motivation to build this project can be found here: http://etiene.net/10/sailor Directory tree info
Supported EnvironmentsSailor has been tested under Linux, Mac OS X and Windows and is currently compatible with Apache with mod_lua or mod_pLua, Nginx with ngx_lua, Lwan, Lighttpd with mod_magnet, or any CGI-enabled web server, like Civetweb, Mongoose and Xavante, if CGILua is present. InstallationFor Linux, see INSTALL_LINUX.md (Ubuntu) or INSTALL_LINUX_ARCH.md (Arch Linux) For Windows, see INSTALL_WIN.md For Mac, see INSTALL_MAC.md Using SailorA default Sailor app will have the following directory tree structure:
Creating PagesGo to /controllers and create your first controller! It should be a lua module. Name it whatever you want, our example is "site.lua". We will serve two pages, one accessible via /?r=site which will run site.index() by default and another one acessible via /?r=site/notindex. local site = {}
local model = require "sailor.model"
function site.index(page)
local foo = 'Hello world'
local User = model("user")
local u = User:new()
u.username = "etiene"
u.password = "a_password"
local valid, err = u:validate() -- validate() will check if your attributes follow the rules!
if not valid then
foo = "Boohoo :("
end
-- Warning: this is a tech preview and some methods of model class do not avoid SQL injections yet.
page:render('index',{foo=foo,name=u.username}) -- This will render /views/site/index.lp and pass the variables 'foo' and 'name'
end
function site.notindex(page)
page:write('<b>Hey you!</b>')
end
return site Go to /views, create a dir named 'site' to match your controller name and create your first page, our example is index.lp <?=foo?>
<p>
Hi, <?=name?>
</p> For more information on what you can do with html and Lua Pages, visit http://keplerproject.github.io/cgilua/manual.html#templates For more examples, you can check the test controller (/controllers/test.lua), the test views (/views/test/*) and the User model (/models/user.lua) Documentation & Reference Manualhttp://sailorproject.org/?r=docs ContributingContributions are welcome! Just make a pull request :) Please try to follow the code style of the rest of the repository. If you made an extension for Sailor and would like to share, please get in contact so I can add it to the website. ThanksThis repository contains the following third-party MIT licensed code:
Suggestions, questions & hugsHugs! Not bugs. For bugs, fill an issue! :) Mail List & SupportJoin our google group for mail list and support If you are having trouble to get Sailor working or if you got it working using different specs, please make contact so we can exchange info and I can improve the manual. Thanks! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论