#Setting up to use Glass ##Some links to help get set up:
- Compass: http://compass-style.org/help/documentation/configuration-reference/
- Sass http://blog.teamtreehouse.com/the-absolute-beginners-guide-to-sass
- Susy http://susydocs.oddbird.net/en/latest/install/
- Bundler http://bundler.io/
- Install bower etc http://tecadmin.net/install-bower-on-ubuntu/#
- Bower https://bower.io/
Glass - api git clone: Along with other git links, I couldn't/didn't know how to use the link provided, I usually get the http link, which is what I did for all other github references. I went to the page and just copied and git cloned. This was documented better than other things, but I had some problems with what I had to have installed previously(see above links!) Finding sites for you
- Graham and Graham Which which site would you like to configure in this directory?: 1
On a personal note: While using glass during setup and in the code editor, I wasn't expecting the password to show up, maybe there's a way in my settings to change that?
**Install **
- Ruby, susy, compass, breakpoint
- Install bundle
- Better to have Gemfile (bundle install)
The gemfile should go in the project root, like a requirements.txt file (or a package.json file, for npm/bower/etc)
GNU nano 2.5.3 File: Gemfile
frozen_string_literal: true
source "https://rubygems.org"
gem "breakpoint", "~>2.4.0"
gem "sass-rails", "~> 5.0.0"
gem "susy"
Config.rb https://gist.github.com/kkellydesign/24cf6aa9eb3cdad992d038a8b73f5466
sass --watch scss:css
http://tecadmin.net/install-bower-on-ubuntu/#- Install node.js NVM
- Install bower
Update stuff :
-
sudo npm update -g npm
-
Sudo npm install -g bower
-
Edit bower.json contents
-
bower install susy --save
-
git remote add origin git@github.com:kellycreativetech/grahamlpa.git
-
Nano .gitignore
(add stuff ) -
git push -u origin master
Meta Data: I was really confused on which page to put it. I was trying to create child/parent relationship with the blog but, if I’m not mistaken, it was placed in the site page? Leading to my next point: Where does glass end and django admin begin? Sometimes I given instructions to do X, but I was really confused which tools - django admin, glass UI, or edit the files locally.
Naming rules: no spaces - This caused some problems for me.
It's more important on loops than in-page fields. Unhelpful names like content_1, content_2, etc. are fine for most in-page >fields. Just put a helpful placeholder like "Insert content" or "Add a short headline", as the labels will only be used >when the field is empty AND if there's no placeholder value. But in loops, placeholders are never used, and labels are always used in the overlay form
So, there's three fixes that are important here:
- Parsing bugs need to show up and they don't. 2) Single quotes really ought to be supported
- We need to write down somewhere what the rules are (probably: https://github.com/kellycreativetech/glass/blob/master/docs/templates.txt ) ** The rules for what you can call a
{% page
or{% list_item
are really the intersection of:** JavaScript attribute rules (starts with an alpha, can be alphanumeric, etc) Python Dictionary Key Rules (pretty similar... Django Template Variable rules (no dashes or spaces)
So the general consensus on that would be under_title or camelCase, start with an alpha character, wrap it in double quotes Fixing #2 I think means upgrading, fixing, or forking django-classy-tags
What I needed to do could have been clearer. A lot of documentation is for Mac, or it's outdated. ( I think!) https://github.com/kellycreativetech/glass/blob/master/config/install-deps.sh
Have to do some but not all: https://github.com/kellycreativetech/glass/blob/master/config/provision.sh Same with postgres,
npm install .
from the home directory, just likepip install -r requirements.txt
- Python 3.5
- Clone the repo
- make a virtualenv
- install pip -r requirements.txt I wasn't sure about these, I didn't install elasticsearch/redis-server, but it's in docs to install.
- elasticsearch
- redis-server
- postgresql
Postgres: Setting up superuser in postgres:
sudo -su postgres
psql
ALTER USER <name> with SUPERUSER;
Orsudo -su postgres
Createuser -s <name>
Edit your pg_hba.conf file:sudo nano /etc/postgresql/9.6/main/pg_hba.conf
- Change all the local configuration to trust
- Rstart postgres
sudo systemctl restart postgresql
Assuming password auth works, It would also be nice to:
- set it up so local auth works without passwords for all your other projects (including some others of ours.
- fix glass's settings.py so that it's easy to configure a password when you need
- set up your virtualenvironment so that when you activate it, it sets the env variables that glass needs, like it sets the env variables your python needs (edit env/bin/activate)
After sudo su postgres, to exit: ctrl + d
In Settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('POSTGRES_DB', 'glass'),
'HOST': os.environ.get('POSTGRES_HOST', 'localhost'),
'USER': os.environ.get('POSTGRES_USER', getpass.getuser()),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', ''),
}
}
Edit your virtualenv Check value of:
echo $VIRTUAL_ENV
/home/rachell/code/work/workenvs/glassbackenv
Edit the activate script: For atom: atom /home/rachell/code/work/workenvs/glassbackenv/bin/activate Or sublime text: subl /home/rachell/code/work/workenvs/glassbackenv/bin/activate
(I put it at the end so I can use
tail env/bin/activate
to see what my settings are) In settings.py at the end paste:
export DJANGO_DEBUG=True
export POSTGRES_USER='glass'
export POSTGRES_PASSWORD='abc'
Setting up locally with zip files
- Download files
- Move to whatever folder they should be in
- xtract/unarchive : unarchive each of these
tar -xzvf rp_code.tar.gz
tar -xzvf rollingplains.tgz
Debugging https://pythonconquerstheuniverse.wordpress.com/2009/09/10/debugging-in-python/
12/13/2016 API
Open shell:
python manage.py shell
To run a file in the shell:
(check transer_biblion_sample.py or sample_rp.py for example )
$ ./manage.py shell ... >>> execfile('myscript.py')
Date formatting:
"Url": "/messages/" + "%Y/%m/%d/".format(p.published) + p.slug + "/",
String formatting recommended
12/14/2016 More Postgres
Check installed packages: http://askubuntu.com/questions/17823/how-to-list-all-installed-packages
sudo apt-get purge postgresql-client-9.3
sudo apt-get purge postgresql-client-9.5
Setting up glass:
Python manage.py migrate
Python manage.py createsuperuser
npm run build:webpack
npm install gulp -g
terminal1:npm run build:webpack-watch
terminal2:gulp watch
Terminal3:python manage.py runserver localhost:8000
Terminal4:python manage.py runserver localhost:8001
The next step would be to make a superuser, and then to login to patrol @ http://localhost:8001 and make a new site
if you make a new site with domain 'foo' you can get to it from http://foo.lvh.me:8000
*npm run build:webpack-watch is really slow and was hard for me to work with. But my system isn't the best (gonna work on fixing that!)
*Glass UI notes: Navigation was a little confusing, It might help having either documentation or 'helper text' on the page.