Commits

jfinkels committed 8fabddc

Moved container styles which depend on application configuration up to templates/layout.html, since every page needs to know the width of div.container.

Comments (0)

Files changed (4)

ophot/static/style/style.css

 .container {
   left: 50%;
   /**
-   * The following values must be declared in templates/splash.html because
+   * The following values must be declared in templates/layout.html because
    * they depend on the application configuration.
    *
    * `width` should be the width of the splash photo as specified in the

ophot/templates/layout.html

   {% if logged_in %}
   <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style/admin.css') }}" />
   {% endif %}
+  <style type="text/css">
+    /**
+     * The height and width of the splash photo is specified in the application
+     * configuration.
+     */
+    .container {
+      margin-left: -{{ splash_photo_width // 2}}px;
+      width: {{ splash_photo_width }}px;
+    }
+  </style>
   {% endblock %}
 
   {% block scripts %}

ophot/templates/splash.html

      * The height and width of the splash photo is specified in the application
      * configuration.
      */
-    .container {
-      margin-left: -{{ splash_photo_width // 2}}px;
-      width: {{ splash_photo_width }}px;
-    }
-
     .photos-container {
       height: {{ photo_height + 10 }}px;
       min-width: {{ splash_photo_width }}px;
 
 def render_template(*args, **kw):
     """Delegates to Flask's :func:`flask.render_template` function, but first
-    assigns values to the keyword arguments ``logged_in`` and ``realname``,
-    which are expected by every template.
+    assigns values to the keyword arguments ``logged_in``, ``realname``, and
+    ``splash_photo_width`` which are expected by every template.
+
+    ``logged_in`` is a boolean representing whether the administrator is
+    currently logged in. It specified whether links for editing and managing
+    photos will be shown.
+
+    ``realname`` is the full (human) name of the photographer. It is displayed
+    in parts of the header and footer on each page.
+
+    ``splash_photo_width`` is the width of the background photo on the splash
+    page as specified in the application configuration (see
+    :file:`config.py`). The width of the main ``div`` containing the content of
+    each page depends on the width of the splash photo (so that the content of
+    each page has a consistent width).
 
     """
-    kw['logged_in'] = current_user.is_authenticated()
-    kw['realname'] = app.config['NAME']
+    kw.update(logged_in=current_user.is_authenticated(),
+              realname=app.config['NAME'],
+              splash_photo_width=app.config['SPLASH_PHOTO_WIDTH'])
     return _render_template(*args, **kw)
 
 
     """Shows the splash page as the root."""
     user = json.loads(UserAPI().get().data)
     categories = json.loads(_get_categories().data)['items']
-    splash_width = app.config['SPLASH_PHOTO_WIDTH']
     splash_height = app.config['SPLASH_PHOTO_HEIGHT']
     splash_filename = app.config['SPLASH_PHOTO_FILENAME']
     photo_height = app.config['PHOTO_HEIGHT']
                            purchase=user['purchase'], contact=user['contact'],
                            purchase_email=app.config['PURCHASE_EMAIL'],
                            filename=splash_filename,
-                           splash_photo_width=splash_width,
                            splash_photo_height=splash_height,
                            photo_height=photo_height)