Do not edit this code directly, after installing it use the clone tool (clonebeegowebapp) as described in "Quick Start" below to get you up and running.
An open source project to create a skeleton of a Beego website.
The aim is to have all the basics of a website, like User registration, login, password reset, etc. It will also include clientside libraries like AngularJS and Bootstrap.
This package was initially forked from wetalk and stripped down to give a basic web application.
The stripped down version includes the following features:
- Authentication (register, activate email, reset password, login, XSRF, etc)
- Admin side to manage the registered users
- Migration (makes use Beego/orm syncdb) to do migration and create log files
- Localization using i18n
- Two config files, one with general settings (like app name) and the other with machine specific settings (like runmode, http_port, etc)
- Compression of static files (like css, js, etc)
- MVC pattern is used which is part of Beego splits our code up into Routers (controllers), Models and Views
- We make use of a Master view (in views/master.html) to define the default layout of the site,
{{.LayoutContent}}
defines where the other templates are rendered - Making use of Beego also gives us the ORM capability
We have also included the following libraries into the design (they are laid out in the conf/compress.json file):
- AngularJS, created by Google and is the missing link between HTML and Javascript
- Bootstrap, created by Twitter and is a front-end framework
- jQuery, do we really need to say what jQuery is?
- SASS, a CSS-precompiler
-
go get github.com/astaxie/beego go get github.com/astaxie/bee go get github.com/Unknwon/goconfig go get github.com/beego/i18n go get github.com/howeyc/fsnotify go get github.com/beego/compress go get github.com/go-sql-driver/mysql go get github.com/francoishill/runsass go get github.com/francoishill/beegowebapp
-
cd $GOPATH/src/github.com/francoishill/beegowebapp ./install_cloner.sh
-
- memcache: https://github.com/youtube/vitess
- redis: github.com/garyburd/redigo/redis
- x2jXML: github.com/clbanning/x2j
- goyaml2: github.com/wendal/goyaml2
- postgres: github.com/lib/pq
- sqlite3: github.com/mattn/go-sqlite3
- websockets: github.com/garyburd/go-websocket/websocket
-
Generate your first web app (based on the Beego framework)
cd /temp clonebeegowebapp blank --foldername="myfirstapp"
-
[app] app_name = My Web Application author_firstname = Francois author_surname = Hill session_path = sess_db_username:sess_db_password@/sess_db_name?charset=utf8 session_name = myapp_session mail_user = Myapp Mailer mail_from = admin@myapp.com secret_key = 1234abc890def567 [orm] data_source = main_db_username:main_db_password@/main_db_name?charset=utf8
-
AF = EN-US = app_name = app_intro = app_desc = app_keywords = app_welcome_message = app_brand = app_copyright = slogan = app_meta_author_firstname = app_meta_author_surname =
Note: the values of
AF
andEN-US
are what will be displayed to the user when choosing languages. To create another language just add a new.ini
file in theconf
folder with its localization key and add its display value to each localization.ini
file.For instance to add chinese create a file named
locale_zh-CN.ini
. Then addzh-CN = Chinese
to each localization.ini
file, includinglocale_zh-CN.ini
itsself. -
If you configured mysql to be the session provider, create its required table with the following SQL:
CREATE TABLE `session` ( `session_key` char(64) NOT NULL, `session_data` blob, `session_expiry` int(11) unsigned NOT NULL, PRIMARY KEY (`session_key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
Run the script
db/migrate_windows.bat
(ordb/migrate_linux.sh
if on linux) to create all the tables for models registerd withorm.RegisterModel
. By default this will be like the User model.This migration status will be logged into a timestamped file inside db/migrations/windows or db/migrations/linux.
Double check this log to ensure everything ran smoothly.
To run as a stand-alone web server on another machine you will only need 1. a database and 2. to copy the following files/folders:
- conf
- static
- static_source
- views
- ??.exe (your applications' executable, on windows it will have the extension .exe)
- A portable MySql server: https://github.com/francoishill/windows_portable_mysql
- A portable Admin tool for MySql: https://github.com/francoishill/windows_heidisql_portable
Please feel free to contribute or to contact me.