Browse Source

setting up pyramid app: static routes

funding-tag
Holger Frey 5 years ago
parent
commit
6e48c02958
  1. 3
      development.ini
  2. 23
      ordr3/__init__.py
  3. 13
      ordr3/pshell.py
  4. 2
      ordr3/routes.py
  5. BIN
      ordr3/static/pyramid-16x16.png
  6. BIN
      ordr3/static/pyramid.png
  7. 154
      ordr3/static/theme.css
  8. 3
      production.ini

3
development.ini

@ -18,6 +18,9 @@ sqlalchemy.url = sqlite:///%(here)s/ordr3.sqlite @@ -18,6 +18,9 @@ sqlalchemy.url = sqlite:///%(here)s/ordr3.sqlite
retry.attempts = 3
session.secret = "change me for production"
session.auto_csrf = true
# By default, the toolbar only appears for clients from IP addresses
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1

23
ordr3/__init__.py

@ -7,13 +7,32 @@ __version__ = "0.0.1" @@ -7,13 +7,32 @@ __version__ = "0.0.1"
from pyramid.config import Configurator
from pyramid.session import JSONSerializer, SignedCookieSessionFactory
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
with Configurator(settings=settings) as config:
config.include("pyramid_jinja2")
session_factory = SignedCookieSessionFactory(
settings["session.secret"], serializer=JSONSerializer()
)
config.set_session_factory(session_factory)
config.set_default_csrf_options(
require_csrf=settings["session.auto_csrf"]
)
# config.set_root_factory(root_factory)
config.include(".adapters")
# config.include('.resources')
config.include(".routes")
# config.include('.security')
# config.include('.views')
config.include("pyramid_jinja2")
config.scan()
return config.make_wsgi_app()
return config.make_wsgi_app()

13
ordr3/pshell.py

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
from . import models
def setup(env):
request = env["request"]
# start a transaction
request.tm.begin()
# inject some vars into the shell builtins
env["tm"] = request.tm
env["dbsession"] = request.dbsession
env["models"] = models

2
ordr3/routes.py

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
def includeme(config):
config.add_static_view("static", "static", cache_max_age=3600)

BIN
ordr3/static/pyramid-16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
ordr3/static/pyramid.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

154
ordr3/static/theme.css

@ -0,0 +1,154 @@ @@ -0,0 +1,154 @@
@import url(//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);
body {
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 300;
color: #ffffff;
background: #bc2131;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 300;
}
p {
font-weight: 300;
}
.font-normal {
font-weight: 400;
}
.font-semi-bold {
font-weight: 600;
}
.font-bold {
font-weight: 700;
}
.starter-template {
margin-top: 250px;
}
.starter-template .content {
margin-left: 10px;
}
.starter-template .content h1 {
margin-top: 10px;
font-size: 60px;
}
.starter-template .content h1 .smaller {
font-size: 40px;
color: #f2b7bd;
}
.starter-template .content .lead {
font-size: 25px;
color: #f2b7bd;
}
.starter-template .content .lead .font-normal {
color: #ffffff;
}
.starter-template .links {
float: right;
right: 0;
margin-top: 125px;
}
.starter-template .links ul {
display: block;
padding: 0;
margin: 0;
}
.starter-template .links ul li {
list-style: none;
display: inline;
margin: 0 10px;
}
.starter-template .links ul li:first-child {
margin-left: 0;
}
.starter-template .links ul li:last-child {
margin-right: 0;
}
.starter-template .links ul li.current-version {
color: #f2b7bd;
font-weight: 400;
}
.starter-template .links ul li a, a {
color: #f2b7bd;
text-decoration: underline;
}
.starter-template .links ul li a:hover, a:hover {
color: #ffffff;
text-decoration: underline;
}
.starter-template .links ul li .icon-muted {
color: #eb8b95;
margin-right: 5px;
}
.starter-template .links ul li:hover .icon-muted {
color: #ffffff;
}
.starter-template .copyright {
margin-top: 10px;
font-size: 0.9em;
color: #f2b7bd;
text-transform: lowercase;
float: right;
right: 0;
}
@media (max-width: 1199px) {
.starter-template .content h1 {
font-size: 45px;
}
.starter-template .content h1 .smaller {
font-size: 30px;
}
.starter-template .content .lead {
font-size: 20px;
}
}
@media (max-width: 991px) {
.starter-template {
margin-top: 0;
}
.starter-template .logo {
margin: 40px auto;
}
.starter-template .content {
margin-left: 0;
text-align: center;
}
.starter-template .content h1 {
margin-bottom: 20px;
}
.starter-template .links {
float: none;
text-align: center;
margin-top: 60px;
}
.starter-template .copyright {
float: none;
text-align: center;
}
}
@media (max-width: 767px) {
.starter-template .content h1 .smaller {
font-size: 25px;
display: block;
}
.starter-template .content .lead {
font-size: 16px;
}
.starter-template .links {
margin-top: 40px;
}
.starter-template .links ul li {
display: block;
margin: 0;
}
.starter-template .links ul li .icon-muted {
display: none;
}
.starter-template .copyright {
margin-top: 20px;
}
}

3
production.ini

@ -16,6 +16,9 @@ sqlalchemy.url = sqlite:///%(here)s/ordr3.sqlite @@ -16,6 +16,9 @@ sqlalchemy.url = sqlite:///%(here)s/ordr3.sqlite
retry.attempts = 3
session.secret = "change me for production"
session.auto_csrf = true
[pshell]
setup = ordr3.pshell.setup

Loading…
Cancel
Save