history.txt See ./README.txt for an overview. == Nov 5 2012 == # Created original project at csmarlboro.org, # /home/mahone/site/flaks/pe/ # i.e. http://csmarlboro.org/mahoney/flask/pe/ csmarlboro$ cd ~/site/flask csmarlboro$ mkdir pe; chdir pe # "Planet Express" project # created ./README.txt and ./history.txt # initialize local python environment for the project csmarlboro$ virtualenv -p python2.7 env # initialize folder as git repository csmarlboro$ git init csmarlboro$ git add * csmarlboro$ git commit -m "initial commit" # Also did (as prompted; first time with git on this machine) csmarlboro$ git config --global user.name "Jim Mahoney" csmarlboro$ git config --global user.email "mahoney@marlboro.edu" # Now on my laptop, thirty-two # This folder is csmarlboro.org:/home/mahoney/site/flask/pe/ # in addition to its web address, http://csmarlboro.org/mahoney/flask/pe/ # I've cloned it to my laptop, using ssh access with public/private keys thirty-two$ cd ~/academics/web_development; mkdir flask; cd flask; thirty-two$ git clone csmarlboro.org:site/flask/pe/ # The workflow on my laptop is now : # 1. edit files # 2. $ git add ; git commit "message"; git push Hit a complication. As I originally thought of this, I wanted the files visible at csmarlboro.org, but also wanted the working copy on my laptop able to ush changes there. Turns out git doesn't like this model. Any git repo with visible files is considered to be a "working" copy, with its own .git tree of changes. Pushing to a working copy is strongly discouraged, since effectly you'd be chaning the .git tree without changing the working files, which would then need to be manually reset. See e.g. http://www.bitflop.com/document/111 So, after a bit of playing around, I've set up a "bare" git repository (i.e. one designed to act as just a push/pull location, without any working files, essentially just the .git part), from which both csmarlboro and thirty-two can push and pull changes. This means that to propogate changes from thirty-two to csmarlboro's working directory I'll need to (1) push from thirty-two to the bare repo, and then later (2) pull from csmarlboro from the bare repo. I've set the bare repo as flask/.pe_bare_repo, and effectively created it this way: # starting from the working pe/ on csmarlboro, # create a bare copy : csmarlboro flask$ git clone --bare -l pe .pe_bare_repo # get rid of that working copy, and clone the # the bare repo so that push/pull go to the bare one csmarlboro flask$ rm -rf pe csmarlboro flask$ git clone .pe_bare_repo pe # Then on thirty-two, edit pe/.git/config # to point at flask/.pe_bare_repo/ on csmarlboro == Nov 12 == Futzed around with the directory structure. Ended up putting virtualenv stuff in env/ folder with the intention of *not* putting that in the git repo, since the stuff in it depends on the OS system specifics. * Added a number of static files (Bootstrap, jQuery, underscore.js, and some of my "default" html5 files). * Added pip's requirements.txt ; with virtualenv should be simple to create virtualenv's env/ and put in dependencies. See that file for the recipe. * Added .gitignore ; put env/ in it. Started work on putting SQLAlchemy into the project. Am trying Flask-SQLAlchemy ... not sure if it's going to be much better than just doing that stuff without it. Also not sure whether it's bringing the database connection up and down at the right times in the request. There's a long list of possibly interesting Flask extensions; see docs/thoughts.txt : flask-assets css, js, compiling flask-debugtoolbar django-debug-toolbar clone flask-lesscss flask-login ... eh flask-restless flask-admin library for an admin interface flask-superadmin flask-dashed flask-mustachejs fancier templates, I think flask-geokit flask-security flask-coffee2js == Nov 16 == Looking for images & fonts Planet Express: Our crew is replaceable. Your package isn't. http://www.fanpop.com/clubs/futurama/images/603850/title/futurama-wallpaper the frytrix - matrix hack futurama poster http://www.fanpop.com/clubs/futurama/images/3305283/title/planet-express-ship-wallpaper planet express ship http://en.wikinoticia.com/Technology/general-technology/78033-the-ten-most-iconic-spaceships-of-science-fiction http://www.wikinoticia.com/images/alt1040/cdn.alt1040.com.files.2011.03.Planet-Express-Ship-futurama-3305283-1024-768-w640.jpg planet express ship (black background) http://newsentimentality.wordpress.com/2012/04/09/space-truckin/ http://newsentimentality.files.wordpress.com/2012/04/planet-express.jpg planet express ship (blue background) (cc) skeletal planet express ship http://www.flickr.com/photos/gabrielsond/4665229709/ (cc) planet express logo yellow/red/black http://www.flickr.com/photos/patdavid/7562368060/ cleaned up in gimp * added transparency to backround * put insides of letters to yellow * saved as google.com/webfonts droid serif (normal, bold, italic, bold-italic) & sans (normal, bold) html: css: font-family: 'Droid Sans', sans-serif; font-family: 'Droid Serif', serif; The bold Droid Sans looks close enough to the logo to use. gradient backgroud , from http://webdesignerwall.com/tutorials/cross-browser-css-gradient /* for non-css3 browsers */ background: #999; /* for IE */ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for webkit browsers */ background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000)); /* for firefox 3.6+ */ background: -moz-linear-gradient(top, #ccc, #000); == Nov 19 == Got src/model.py into a reasonable state, using SqlAlchemy relations and classes, and roughly equivalent to the SqlSoup work I did earlier this semester. The console is also in a working state, and does allow modifications to the database. For a template, adopt from fedex.com/us ; see attached. == Nov 23 == To add variables or functions to the template context, flask/jinja2 provides the following syntax (see http://flask.pocoo.org/docs/templating/) @app.context_processor def template_context_additions: # return dict of variables & functions to put in template namespace return {func = func, name = value, ...} You can also define template filters, which modify the result of variables in templates in a unix-ish pipe notation {% keyword ... %} statement in jinja2 language, e.g. if, for, block, ... {{ name }} insert variable into document at that spot {{ func('arg') | upcase }} produce text, pipe through filter These functions can be jinja can also define its own functions, which it calls "macros", and can import those from other files. ... Got a simple bootstrap example running as a flask template, with the static urls translated via a filter == Nov 26 == Themes for bootstrap : http://bootswatch.com/ == June 2013 Looking back at this much later. Here's the basic idea of how it runs : # Get to the base directory $ cd /Users/mahoney/academics/web_development/flask/planet_express # Initiate the virtualenv python etc. $ . env/bin/activate # Run the development server. $ python planet_express.py # ... and point a browser at localhost:8090/ (port set in planet_express.py) # Or $ ./console # Interact with the database via python-sql stuff. It wasn't finished; I'm not sure how many of the routes worked. (I thought more than I'm seeing ... maybe the 'localhost' is failing for the path stuff?)