SlideShare una empresa de Scribd logo
1 de 25
Styling Molly
                           Bangor University
                              11 May 2011




                       Chris Northwood
                             Lead Developer
                   Oxford University Computing Services




                                     Mobile Oxford             Molly Project
University of Oxford
                                    http://m.ox.ac.uk     http://mollyproject.org
http://www.ox.ac.uk
                                       @mobileox              @mollyproject
TEMPLATE INHERITANCE



•   Template inheritance is used to define a base site template
    (base.html) which all pages can use to ensure consistent styling
    along the site
BLOCKS



•   Base templates define blocks, which are the areas of the template
    which can be overridden by child templates
TEMPLATE STRUCTURE

    base.html        Molly comes with a complete set
                     of generic templates which can be
                     used to get a site up and running
                                 very quickly.
library/base.html

                         Any single template in the
                      hierarchy can be replaced with
library/index.html        one unique to your site.
CUSTOMISING A TEMPLATE

                         base.html

                                          Your template is
                                                 used
                     library/base.html    in preference to
                                                  the
                                             built-in one
mysite/templates/
                     library/index.html
library/index.html
FINER GRAINED CONTROL


•   Replacing a whole template is often a coarse tool, especially if
    most of the code remains the same. You lose the benefit of any
    upstream template improvements.

•   More useful is the ability to only replace part of the template.

•   We can do this by extending the original template and only
    overriding the part of it we’re interested in.
EXTENDING THE ORIGINAL
      TEMPLATE

                         base.html



                     library/base.html



library/index.html   library/index.html
EXTENDING THE ORIGINAL
           TEMPLATE


•   However, extending isn’t quite that simple, your replacement
    template hides the original, so you can’t address it in the
    traditional method

•   To get around this, Molly also exposes all of its templates under
    the prefix of ‘molly_default’
library/index.html
                            (in Molly tree)




    library/index.html
(in Mobile Oxford tree)
•   This can be done at any point up the hierarchy

•   At the very least, most sites will want to customise
    base.html

•   Documentation for the full list of templates, and
    overrideable blocks within them is incomplete, the
    best way to determine what’s available is to read the
    code.
•   Template paths from the point of view of Django are
    relative to the containing ‘templates’ folder, i.e., ‘molly/
    apps/places/templates/places/entity_detail.html’ is
    referenced as ‘places/entity_detail.html’

•   Core templates (404.html, etc) are stored in the
    ‘templates’ subdirectory of Molly. Templates for apps
    are stored in the ‘templates’ subdirectory of that app.
•   If a template isn’t customisable enough for you, raise
    an issue on http://issues.mollyproject.org and
    additional blocks will be added to the main Molly
    code.
PRACTICAL TIME
MINIFYING MEDIA


•   Molly includes a powerful framework for handling CSS and
    JavaScript, including concatenating it into single files, and minifying
    the code

•   This is based on the django-compress library: http://
    code.google.com/p/django-compress/
CONCATENATION


•   Each app is self-contained in Molly, including any styles and
    JavaScript

•   New HTTP requests are expensive over GPRS, reducing the
    amount of external files is desirable
SPECIAL FILES


•   Molly treats the files smart.css, dumb.css and smart.js specially -
    served to appropriate device classes

•   For serving, each app’s smart.css, etc, file is concatenated with all
    the other apps, to result in one smart.css, etc, for the entire site

•   This means there’s no need to reference these files specifically
    within your template
IT’S NOT PERFECT

•   Your CSS/JS ends up on pages that it’s not intended for. Careful
    class names and JavaScript guards are needed to avoid
    unintentional side effects.

•   The resulting files are larger than are strictly necessary in the
    context of a single page

•   However, in the context of the whole site, this means fewer
    requests and is better in most cases
MINIFICATION

•   Well-understood and widely used

•   “Compresses” code by removing whitespace, replacing variable
    names with single letters, etc

•   Combined with gzip at server-time makes a significant difference
    to file size

•   Obfuscates code and makes it hard to debug
DJANGO-COMPRESS

•   Disabled when debug mode is on

•   Any file ending ‘.css’ or ‘.js’ is minified

•   Adds a timestamp to the filename which allows for clients to
    aggressively cache files, whilst also working around cache
    breakages

•   Templates can access these files using the compress_css and
    compress_js template tags, rather than linking to the files directly
DJANGO-STATICFILES


•   An external library prior to Django 1.3, now part of core Django

•   Copies all media files from various places to a single ‘media’
    directory in your site

•   Also allows for overriding of files - placing an image in your
    site_media folder will cause that file to be used, rather than the
    default one - useful for replacing logos, etc
WHERE MOLLY KEEPS FILES


•   Images, CSS and JS that are associated with an app are stored in
    the ‘static’ subdirectory of that app

•   The ‘media’ folder in the main Molly directory contains site-wide
    files - core icons, CSS, logos, etc

•   The ‘site_media’ folder in your site contains your manual
    overrides
BEWARE!

•   Django-staticfiles copies all of the files to a ‘media’ folder in your
    site folder

•   This is where your webserver should serve the files from - but
    these are not the source files!

•   Files in here should not be edited, as they will be replaced the
    next time media is rebuilt - only edit the source files, or replace a
    core Molly file in your ‘site_media’ folder
HOW TO OVERRIDE A FILE


•   Find the relative path name of the image to be replaced (either
    through the documentation, exploring the source tree, or by
    looking at the URL of the item)

•   Place the file you would like to replace that file under the same
    path/filename in your ‘site_media’ folder

•   Rebuild the media (e.g., re-run the quickinstaller)
PRACTICAL TIME

Más contenido relacionado

La actualidad más candente

Drupal content editor flexibility
Drupal content editor flexibilityDrupal content editor flexibility
Drupal content editor flexibilityhernanibf
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp Londonhernanibf
 
My site is slow
My site is slowMy site is slow
My site is slowhernanibf
 
Transformations - a TLCC & Teamstudio Webinar
Transformations - a TLCC & Teamstudio WebinarTransformations - a TLCC & Teamstudio Webinar
Transformations - a TLCC & Teamstudio WebinarOliver Busse
 
Making Multisite Work for You
Making Multisite Work for YouMaking Multisite Work for You
Making Multisite Work for Youdrywallbmb
 
Academic Websites in Plone
Academic Websites in PloneAcademic Websites in Plone
Academic Websites in PloneJazkarta, Inc.
 
Online exhibits in Plone
Online exhibits in PloneOnline exhibits in Plone
Online exhibits in PloneJazkarta, Inc.
 
Deployer - Deployment tool for PHP
Deployer - Deployment tool for PHPDeployer - Deployment tool for PHP
Deployer - Deployment tool for PHPhernanibf
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsJoe Querin
 
Responsive Web Design using ZURB Foundation
Responsive Web Design using ZURB FoundationResponsive Web Design using ZURB Foundation
Responsive Web Design using ZURB FoundationSolTech, Inc.
 
EPUB for Website Producers
EPUB for Website ProducersEPUB for Website Producers
EPUB for Website Producerswaldoj
 
The WordPress University
The WordPress UniversityThe WordPress University
The WordPress UniversityStephanie Leary
 
Web Development with Joomla - Past, Present & Future
Web Development with Joomla - Past, Present & FutureWeb Development with Joomla - Past, Present & Future
Web Development with Joomla - Past, Present & FutureThemeXpert
 
OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...
OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...
OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...C. Daniel Chase
 
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DayCreating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DaySuzanne Dergacheva
 
Drupal - Blocks vs Context vs Panels
Drupal - Blocks vs Context vs PanelsDrupal - Blocks vs Context vs Panels
Drupal - Blocks vs Context vs PanelsDavid Burns
 
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreCreating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreSuzanne Dergacheva
 
Online Exhibits in Plone
Online Exhibits in PloneOnline Exhibits in Plone
Online Exhibits in PloneJazkarta, Inc.
 

La actualidad más candente (20)

Drupal content editor flexibility
Drupal content editor flexibilityDrupal content editor flexibility
Drupal content editor flexibility
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp London
 
My site is slow
My site is slowMy site is slow
My site is slow
 
72d5drupal
72d5drupal72d5drupal
72d5drupal
 
Transformations - a TLCC & Teamstudio Webinar
Transformations - a TLCC & Teamstudio WebinarTransformations - a TLCC & Teamstudio Webinar
Transformations - a TLCC & Teamstudio Webinar
 
Making Multisite Work for You
Making Multisite Work for YouMaking Multisite Work for You
Making Multisite Work for You
 
Academic Websites in Plone
Academic Websites in PloneAcademic Websites in Plone
Academic Websites in Plone
 
Online exhibits in Plone
Online exhibits in PloneOnline exhibits in Plone
Online exhibits in Plone
 
Deployer - Deployment tool for PHP
Deployer - Deployment tool for PHPDeployer - Deployment tool for PHP
Deployer - Deployment tool for PHP
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
 
Responsive Web Design using ZURB Foundation
Responsive Web Design using ZURB FoundationResponsive Web Design using ZURB Foundation
Responsive Web Design using ZURB Foundation
 
EPUB for Website Producers
EPUB for Website ProducersEPUB for Website Producers
EPUB for Website Producers
 
The WordPress University
The WordPress UniversityThe WordPress University
The WordPress University
 
Web Development with Joomla - Past, Present & Future
Web Development with Joomla - Past, Present & FutureWeb Development with Joomla - Past, Present & Future
Web Development with Joomla - Past, Present & Future
 
Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)
Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)
Module 4 - Dreamweaver Templates (Static vs. Dynamic Content)
 
OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...
OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...
OmniUpdate User Training Conference 2014: Our "Special Sauce" Responsive Desi...
 
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DayCreating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
 
Drupal - Blocks vs Context vs Panels
Drupal - Blocks vs Context vs PanelsDrupal - Blocks vs Context vs Panels
Drupal - Blocks vs Context vs Panels
 
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreCreating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
 
Online Exhibits in Plone
Online Exhibits in PloneOnline Exhibits in Plone
Online Exhibits in Plone
 

Destacado

E books roadmap-dunham
E books roadmap-dunhamE books roadmap-dunham
E books roadmap-dunhamBarbara Dunham
 
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi services
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi servicesOracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi services
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi servicesdbi services
 
хэрэглэгдэхүүн
хэрэглэгдэхүүнхэрэглэгдэхүүн
хэрэглэгдэхүүнtuul_48
 
Colony bee mô phỏng
Colony bee mô phỏngColony bee mô phỏng
Colony bee mô phỏngthanhnga_hera
 
Organizational behavior
Organizational behaviorOrganizational behavior
Organizational behaviorinmaX studio
 
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...dbi services
 

Destacado (7)

E books roadmap-dunham
E books roadmap-dunhamE books roadmap-dunham
E books roadmap-dunham
 
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi services
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi servicesOracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi services
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi services
 
хэрэглэгдэхүүн
хэрэглэгдэхүүнхэрэглэгдэхүүн
хэрэглэгдэхүүн
 
Colony bee mô phỏng
Colony bee mô phỏngColony bee mô phỏng
Colony bee mô phỏng
 
Organizational behavior
Organizational behaviorOrganizational behavior
Organizational behavior
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...
 

Similar a Introduction to styling Molly

BP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesBP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesAlfresco Software
 
BP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesBP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesAlfresco Software
 
How to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle coreHow to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle coreDan Poltawski
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesJer Clarke
 
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdfITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdfOrtus Solutions, Corp
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectIztok Smolic
 
Presentation 1 Web--dev
Presentation 1 Web--devPresentation 1 Web--dev
Presentation 1 Web--devaltsav
 
full-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptxfull-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptxPlasterdog Web Design
 
How to customise Joomla
How to customise JoomlaHow to customise Joomla
How to customise JoomlaTim Plummer
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform AppsFITC
 
Produce and consume_linked_data_with_drupal
Produce and consume_linked_data_with_drupalProduce and consume_linked_data_with_drupal
Produce and consume_linked_data_with_drupalSTIinnsbruck
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDavid Lanier
 
Drupal, git and sanity
Drupal, git and sanityDrupal, git and sanity
Drupal, git and sanityCharlie Morris
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalRod Martin
 
University of Portsmouth Library: A practical approach to Responsive Design
University of Portsmouth Library: A practical approach to Responsive Design University of Portsmouth Library: A practical approach to Responsive Design
University of Portsmouth Library: A practical approach to Responsive Design Terminalfour
 
Ohio Valley Oracle Application User Group
Ohio Valley Oracle Application User GroupOhio Valley Oracle Application User Group
Ohio Valley Oracle Application User GroupKyle Goodfriend
 

Similar a Introduction to styling Molly (20)

BP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesBP-9 Share Customization Best Practices
BP-9 Share Customization Best Practices
 
BP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesBP-7 Share Customization Best Practices
BP-7 Share Customization Best Practices
 
Joomla Templates101
Joomla Templates101Joomla Templates101
Joomla Templates101
 
dmBridge & dmMonocle
dmBridge & dmMonocledmBridge & dmMonocle
dmBridge & dmMonocle
 
How to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle coreHow to guarantee your change is integrated to Moodle core
How to guarantee your change is integrated to Moodle core
 
Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
 
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdfITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal project
 
Presentation 1 Web--dev
Presentation 1 Web--devPresentation 1 Web--dev
Presentation 1 Web--dev
 
full-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptxfull-site-editing-theme-presentation.pptx
full-site-editing-theme-presentation.pptx
 
How to customise Joomla
How to customise JoomlaHow to customise Joomla
How to customise Joomla
 
Wordpress overview
Wordpress overviewWordpress overview
Wordpress overview
 
Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform Apps
 
Produce and consume_linked_data_with_drupal
Produce and consume_linked_data_with_drupalProduce and consume_linked_data_with_drupal
Produce and consume_linked_data_with_drupal
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
Drupal, git and sanity
Drupal, git and sanityDrupal, git and sanity
Drupal, git and sanity
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to Drupal
 
University of Portsmouth Library: A practical approach to Responsive Design
University of Portsmouth Library: A practical approach to Responsive Design University of Portsmouth Library: A practical approach to Responsive Design
University of Portsmouth Library: A practical approach to Responsive Design
 
Ohio Valley Oracle Application User Group
Ohio Valley Oracle Application User GroupOhio Valley Oracle Application User Group
Ohio Valley Oracle Application User Group
 

Último

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 

Último (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

Introduction to styling Molly

  • 1. Styling Molly Bangor University 11 May 2011 Chris Northwood Lead Developer Oxford University Computing Services Mobile Oxford Molly Project University of Oxford http://m.ox.ac.uk http://mollyproject.org http://www.ox.ac.uk @mobileox @mollyproject
  • 2. TEMPLATE INHERITANCE • Template inheritance is used to define a base site template (base.html) which all pages can use to ensure consistent styling along the site
  • 3. BLOCKS • Base templates define blocks, which are the areas of the template which can be overridden by child templates
  • 4. TEMPLATE STRUCTURE base.html Molly comes with a complete set of generic templates which can be used to get a site up and running very quickly. library/base.html Any single template in the hierarchy can be replaced with library/index.html one unique to your site.
  • 5. CUSTOMISING A TEMPLATE base.html Your template is used library/base.html in preference to the built-in one mysite/templates/ library/index.html library/index.html
  • 6. FINER GRAINED CONTROL • Replacing a whole template is often a coarse tool, especially if most of the code remains the same. You lose the benefit of any upstream template improvements. • More useful is the ability to only replace part of the template. • We can do this by extending the original template and only overriding the part of it we’re interested in.
  • 7. EXTENDING THE ORIGINAL TEMPLATE base.html library/base.html library/index.html library/index.html
  • 8. EXTENDING THE ORIGINAL TEMPLATE • However, extending isn’t quite that simple, your replacement template hides the original, so you can’t address it in the traditional method • To get around this, Molly also exposes all of its templates under the prefix of ‘molly_default’
  • 9. library/index.html (in Molly tree) library/index.html (in Mobile Oxford tree)
  • 10. This can be done at any point up the hierarchy • At the very least, most sites will want to customise base.html • Documentation for the full list of templates, and overrideable blocks within them is incomplete, the best way to determine what’s available is to read the code.
  • 11. Template paths from the point of view of Django are relative to the containing ‘templates’ folder, i.e., ‘molly/ apps/places/templates/places/entity_detail.html’ is referenced as ‘places/entity_detail.html’ • Core templates (404.html, etc) are stored in the ‘templates’ subdirectory of Molly. Templates for apps are stored in the ‘templates’ subdirectory of that app.
  • 12. If a template isn’t customisable enough for you, raise an issue on http://issues.mollyproject.org and additional blocks will be added to the main Molly code.
  • 14. MINIFYING MEDIA • Molly includes a powerful framework for handling CSS and JavaScript, including concatenating it into single files, and minifying the code • This is based on the django-compress library: http:// code.google.com/p/django-compress/
  • 15. CONCATENATION • Each app is self-contained in Molly, including any styles and JavaScript • New HTTP requests are expensive over GPRS, reducing the amount of external files is desirable
  • 16. SPECIAL FILES • Molly treats the files smart.css, dumb.css and smart.js specially - served to appropriate device classes • For serving, each app’s smart.css, etc, file is concatenated with all the other apps, to result in one smart.css, etc, for the entire site • This means there’s no need to reference these files specifically within your template
  • 17. IT’S NOT PERFECT • Your CSS/JS ends up on pages that it’s not intended for. Careful class names and JavaScript guards are needed to avoid unintentional side effects. • The resulting files are larger than are strictly necessary in the context of a single page • However, in the context of the whole site, this means fewer requests and is better in most cases
  • 18. MINIFICATION • Well-understood and widely used • “Compresses” code by removing whitespace, replacing variable names with single letters, etc • Combined with gzip at server-time makes a significant difference to file size • Obfuscates code and makes it hard to debug
  • 19. DJANGO-COMPRESS • Disabled when debug mode is on • Any file ending ‘.css’ or ‘.js’ is minified • Adds a timestamp to the filename which allows for clients to aggressively cache files, whilst also working around cache breakages • Templates can access these files using the compress_css and compress_js template tags, rather than linking to the files directly
  • 20.
  • 21. DJANGO-STATICFILES • An external library prior to Django 1.3, now part of core Django • Copies all media files from various places to a single ‘media’ directory in your site • Also allows for overriding of files - placing an image in your site_media folder will cause that file to be used, rather than the default one - useful for replacing logos, etc
  • 22. WHERE MOLLY KEEPS FILES • Images, CSS and JS that are associated with an app are stored in the ‘static’ subdirectory of that app • The ‘media’ folder in the main Molly directory contains site-wide files - core icons, CSS, logos, etc • The ‘site_media’ folder in your site contains your manual overrides
  • 23. BEWARE! • Django-staticfiles copies all of the files to a ‘media’ folder in your site folder • This is where your webserver should serve the files from - but these are not the source files! • Files in here should not be edited, as they will be replaced the next time media is rebuilt - only edit the source files, or replace a core Molly file in your ‘site_media’ folder
  • 24. HOW TO OVERRIDE A FILE • Find the relative path name of the image to be replaced (either through the documentation, exploring the source tree, or by looking at the URL of the item) • Place the file you would like to replace that file under the same path/filename in your ‘site_media’ folder • Rebuild the media (e.g., re-run the quickinstaller)

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n