#Contents
- Site Conventions
- Special tags
- Database Management
- Sass and Compass
- Installation
- DB config
- DB import
- Local Virtual Host
- Cache folder permissions
- Protecting In-Development Pages
- Working With the Code and Deploying Changes
- Making file changes
- Making data/schema changes
- Deploying the code
##1. Site Conventions
This site depends on a few conventions which should be followed when naming things:
- Snippets should be prefixed
sn_ - Global variables should be prefixed
gv_
##2. Special Tags
This site uses some custom tags ({exp:[CLIENTNAME]:tagname}) defined the pi.[CLIENTNAME].php file.
This file documents all the methods used. You can also view documentation from Addons -> Plugins.
Any method prefixed with an underscore is private, and only used internally in the Lenovo class.
##3. Database Management
A current copy of the database dump is kept inside /data. Once you have installed the site, you can import the DB from the dump file by running the command...
php tasks/import_db.php
...from the [ROOT. To export, run...
php tasks/export_db.php
If you prefer to use rake instead, there are similar tasks for importing (rake import_db) and exporting (rake export_db).
##4. Sass and Compass
Using Sass and Compass, you can edit the .scss files inside /assets/compile/sass, and they'll compile to a final CSS file. Sass is a compile-to-CSS tool that adds features like automatic sprites, variables, file-inclusion, and much more to CSS.
In order to compile your changes to css files, you'll need ruby and the following Ruby gems installed on your machine:
- sass
- compass
When making edits, you'll run the "watcher" from the command line, and Compass will automatically compile the css to all.css.
From the /assets, run:
compass watch
All compiled scss files are contained in /assets/compile/sass and sprites are derived from their source images in /images/structure.
If you'd prefer not to use Sass, you can delete the .scss files and the config.rb file and edit the CSS directly.
Information and documentation for Sass can be found at http://sass-lang.com/ and for compass at http://compass-style.org/.
##5. Installation
[ROOT] is the server path to the site's directory. (ex: /var/www/html/clientname/)
[SITE_URL] is the URL you'd like the site to be available at from the browser.
###5.1 DB config
Go to [ROOT]/ee-system/expressionengine/config/database.php and update the following to match your database information:
$db['expressionengine']['hostname'] = "[DB_HOST]"; // host name - probably localhost
$db['expressionengine']['username'] = "[DB_USER]"; // username - probably root
$db['expressionengine']['password'] = "[DB_PASSWORD]"; // password - probably root
$db['expressionengine']['database'] = "[DB_NAME]"; // database name of your choosing
$db['expressionengine']['path_to_mysql_command'] = "/Applications/MAMP/Library/bin/"; // the location of your mysql command, usually blank
###5.2 DB Import and Export
Import the DB by entering the [ROOT] and running php tasks/import_db.php from the command line. This will create and import your database.
###5.3 Local Virtual Host
When running on a local machine you'll need to set up a virtual host to point to [SITE_URL]
(The following instructions are specific to MAMP and OS X)
-
Go to MAMP's preferences and set your Apache port to 80.
-
Back up your MAMP httpd.conf file $: cp /Applications/MAMP/conf/apache/httpd.conf /Applications/MAMP/conf/apache/httpd.conf.bak
-
Open the httpd.conf ( $: mate /Applications/MAMP/conf/apache/httpd.conf ) and add the virtual host to httpd.conf by adding these lines at the bottom
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /Applications/MAMP/htdocs/lenovosocial/ ServerName lenovosocial.local </VirtualHost> -
Update your
/etc/hostsfile to point[SITE_URL]to127.0.0.1by adding the line127.0.0.1 [SITE_URL] -
Restart your web server (MAMP)
###5.4 Make cache folder writable
Go to [ROOT]/ee-system/expressionengine/cache/ and make sure the folder's permissions are set to 777.
##6. Protecting In-Development Pages
To limit a page to only be seen by a certain group of users, use the format:
{if group_id=="1"}
// code goes here
{if:else}
{redirect="404"}
{/if}
group_id 1 is super-admins, group_id 6 is admins. Other group ids can be found in the control panel under Members -> Member Groups
##7. Working With the Code and Deploying Changes
###7.1 Making file changes
All source code is checked into the repository found at https://github.com/cdre/cdrerepo10_viget.
All edits to JavaScript, stylesheets, and structural (non-content) images should be made using the git repository and not directly on any staging or production server.
It is preferred that any template changes be through the repository as well. It is, however, possible to make template changes through the template manager in the ExpressionEngine control panel. If changes are made in this way, they will need to be committed back into the repository by remotely logging into the server using SSH, navigating to the project directory (current /var/www/html/viget/) and committing and pushing those changes.
Templates should ALWAYS be set to be saved as files. This will greatly reduce any syncing errors that might occur between the template files and what EE has loaded into the database.
###7.2 Making data/schema changes
If the case arises that data or schema changes need to be made, or if production data needs to be synced into the repository for local use, these changes must occur on the production database to mitigate syncing issues or any potential overwriting of data.
Once changes have been planned and made, you will need to sync those changes into the repository using the following process:
-
Remotely log in to the server via SSH and navigate to the project folder (currently
/var/www/html/viget) -
Export the production database using the command
php tasks/export_db.php -
Using git, stage and commit the changes using with an accompanying descriptive commit message detailing what changed.
git add data/db_dump.sql git commit -m "MESSAGE GOES HERE" -
Using git, push the changes up to the remote repository
git push origin master
Once this process is complete you'll be able to pull down those changes to your development environment and import the updated database.
Data changes should ALWAYS flow downward, from production to development environments. It should NEVER flow upward from development to production. This is to mitigate the possibility of sync errors and accidental overwriting and/or deletion of production data.
###7.3 Deploying the code
Once changes are ready to be deployed to a staging or production environment, follow this process to pull them down from the remote git repository:
-
Remotely log in to the server via SSH and navigate to the project folder (currently
/var/www/html/viget) -
Using git, retrieve changes from the remote git repository
git pull origin master