Skip to content

Commit

Permalink
[themes] several improvements
Browse files Browse the repository at this point in the history
- add ability to customize call to action button
- document fields in the admin
- use CharField instead of textfield where appropriate
- removed site description (use welcome_content instead) as it conflicts with search box
- mention in the doc
  • Loading branch information
olivierdalang committed Oct 15, 2018
1 parent 6b6b10e commit 1f6b9f6
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/admin/customize_lookfeel/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Customize the look and feel

.. warning:: These instructions are only valid if you've installed GeoNode following the guide at :ref:`setup_configure_httpd` !!

You might want to change the look of GeoNode, editing the colors and the logo of the website and adjust the templates for your needs. To do so, you first have to set up your own geonode project from a template. If you've successfully done this, you can go further and start theming your geonode project.
Since version 2.8.1, it is possible to do change some elements of look and feel (such as colors, logo, etc.) using the Geonode Theme application from the administration. For more advanced changes, you first have to set up your own geonode project from a template. If you've successfully done this, you can go further and start theming your geonode project.

.. toctree::
:hidden:
Expand Down
19 changes: 8 additions & 11 deletions geonode/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
<div class="container">
<h1>{{custom_theme.jumbotron_welcome_title|default:_("Welcome")}}</h1>
<p></p>
<p>{{custom_theme.jumbotron_welcome_content|default:_("GeoNode is an open source platform for sharing geospatial data and maps.")}}</p>
<a class="btn btn-default btn-lg" target="_blank" href="http://docs.geonode.org/en/master/tutorials/users/index.html" role="button">{% blocktrans %}Get Started &raquo;{% endblocktrans %}</a>
</div>
<p>{{custom_theme.jumbotron_welcome_content|default:_("GeoNode is an open source platform for sharing geospatial data and maps.")}}</p>
{% if not custom_theme.jumbotron_cta_hide %}
<a class="btn btn-default btn-lg" target="_blank" href="{{custom_theme.jumbotron_cta_link|default:_("http://docs.geonode.org/en/master/tutorials/users/index.html")}}" role="button">{{custom_theme.jumbotron_cta_text|default:_("Get Started &raquo;")}}</a>
{% endif %}
</div>
</div>
{% endif %}
{% endblock hero %}
Expand All @@ -32,11 +34,6 @@ <h1>{{custom_theme.jumbotron_welcome_title|default:_("Welcome")}}</h1>
{{ block.super }}
{% else %}
<div class="big-search">
{% if custom_theme.jumbotron_site_description %}
<div class="container">
<p>{{ custom_theme.jumbotron_site_description }}</p>
</div>
{% endif %}
<div class="container">
<h1>{% trans "Search for Data." %}</h1>
<div class="search">
Expand Down Expand Up @@ -315,14 +312,14 @@ <h4>{{ item.title | limitTo: 20 }}{{item.title.length > 20 ? '...' : ''}}</h4>
</section>
{% endblock showcase %}
{% block partners %}
{% if custom_theme.partners_title %}
{% if custom_theme.partners.all %}
<section id="partners">
<div class="container text-center">
<h2>{{ custom_theme.partners_title }}</h2>
<h2>{{ custom_theme.partners_title|default:_("Our partners") }}</h2>
<div class="row">
{% for partner in custom_theme.partners.all %}
<div class="col-md-6">
<div class="partner_logo"{% if partner.logo %} style="background-image: url({% if %}{{partner.logo.url}}{% else %}{% static 'geonode/img/missing_thumb.png' %}{% endif %})"{% endif %}></div>
<div class="partner_logo" style="background-image: url({% if partner.logo %}{{partner.logo.url}}{% else %}{% static 'geonode/img/missing_thumb.png' %}{% endif %})"></div>
<div><a href="{{ partner.partner_link }}" target="_blank">{{ partner.title }}</a></div>
</div>
{% endfor %}
Expand Down
149 changes: 149 additions & 0 deletions geonode/themes/migrations/0002_auto_20181015_1208.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-10-15 00:08
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('geonode_themes', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='geonodethemecustomization',
name='jumbotron_site_description',
),
migrations.AddField(
model_name='geonodethemecustomization',
name='jumbotron_cta_hide',
field=models.BooleanField(default=False, verbose_name=b'Hide call to action'),
),
migrations.AddField(
model_name='geonodethemecustomization',
name='jumbotron_cta_link',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name=b'Call to action link'),
),
migrations.AddField(
model_name='geonodethemecustomization',
name='jumbotron_cta_text',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name=b'Call to action text'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_administrative_area',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_city',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_country',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_delivery_point',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_email',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_facsimile',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_name',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_position',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_postal_code',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_street',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contact_voice',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='contactus',
field=models.BooleanField(default=False, verbose_name=b'Enable contact us box'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='date',
field=models.DateTimeField(auto_now_add=True, help_text=b'This will not appear anywhere.'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='description',
field=models.TextField(blank=True, help_text=b'This will not appear anywhere.', null=True),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='is_enabled',
field=models.BooleanField(default=False, help_text=b'Enabling this theme will disable the current enabled theme (if any)'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='jumbotron_bg',
field=models.ImageField(blank=True, null=True, upload_to=b'img/%Y/%m', verbose_name=b'Jumbotron background'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='jumbotron_welcome_content',
field=models.TextField(blank=True, null=True, verbose_name=b'Jumbotron content'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='jumbotron_welcome_hide',
field=models.BooleanField(default=False, help_text=b'Check this if the jumbotron backgroud image already contains text', verbose_name=b'Hide text in the jumbotron'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='jumbotron_welcome_title',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name=b'Jumbotron title'),
),
migrations.AlterField(
model_name='geonodethemecustomization',
name='name',
field=models.CharField(help_text=b'This will not appear anywhere.', max_length=100),
),
migrations.AlterField(
model_name='partner',
name='href',
field=models.CharField(max_length=255, verbose_name=b'Website'),
),
migrations.AlterField(
model_name='partner',
name='name',
field=models.CharField(help_text=b'This will not appear anywhere.', max_length=100),
),
migrations.AlterField(
model_name='partner',
name='title',
field=models.CharField(max_length=255, verbose_name=b'Display name'),
),
]
56 changes: 29 additions & 27 deletions geonode/themes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

class Partner(models.Model):
logo = models.ImageField(upload_to='img/%Y/%m', null=True, blank=True)
name = models.CharField(max_length=100)
title = models.CharField(max_length=255)
href = models.CharField(max_length=255)
name = models.CharField(max_length=100, help_text="This will not appear anywhere.")
title = models.CharField(max_length=255, verbose_name="Display name")
href = models.CharField(max_length=255, verbose_name="Website")

@property
def logo_class(self):
Expand All @@ -53,37 +53,39 @@ class Meta:

class GeoNodeThemeCustomization(models.Model):
identifier = models.CharField(max_length=255, editable=False)
name = models.CharField(max_length=100)
date = models.DateTimeField(auto_now_add=True, blank=True)
description = models.TextField(null=True, blank=True)
is_enabled = models.BooleanField(default=False)
name = models.CharField(max_length=100, help_text="This will not appear anywhere.")
date = models.DateTimeField(auto_now_add=True, blank=True, help_text="This will not appear anywhere.")
description = models.TextField(null=True, blank=True, help_text="This will not appear anywhere.")
is_enabled = models.BooleanField(default=False, help_text="Enabling this theme will disable the current enabled theme (if any)")
logo = models.ImageField(upload_to='img/%Y/%m', null=True, blank=True)
jumbotron_bg = models.ImageField(
upload_to='img/%Y/%m', null=True, blank=True)
jumbotron_welcome_hide = models.BooleanField(default=False)
jumbotron_welcome_title = models.CharField(max_length=255, null=True, blank=True)
jumbotron_welcome_content = models.TextField(null=True, blank=True)
jumbotron_site_description = models.TextField(null=True, blank=True)
upload_to='img/%Y/%m', null=True, blank=True, verbose_name="Jumbotron background")
jumbotron_welcome_hide = models.BooleanField(default=False, verbose_name="Hide text in the jumbotron", help_text="Check this if the jumbotron backgroud image already contains text")
jumbotron_welcome_title = models.CharField(max_length=255, null=True, blank=True, verbose_name="Jumbotron title")
jumbotron_welcome_content = models.TextField(null=True, blank=True, verbose_name="Jumbotron content")
jumbotron_cta_hide = models.BooleanField(default=False, blank=True, verbose_name="Hide call to action")
jumbotron_cta_text = models.CharField(max_length=255, null=True, blank=True, verbose_name="Call to action text")
jumbotron_cta_link = models.CharField(max_length=255, null=True, blank=True, verbose_name="Call to action link")
body_color = models.CharField(max_length=10, default="#333333")
navbar_color = models.CharField(max_length=10, default="#333333")
jumbotron_color = models.CharField(max_length=10, default="#2c689c")
copyright_color = models.CharField(max_length=10, default="#2c689c")
contactus = models.BooleanField(default=False)
copyright = models.TextField(null=True, blank=True)
contact_name = models.TextField(null=True, blank=True)
contact_position = models.TextField(null=True, blank=True)
contact_administrative_area = models.TextField(null=True, blank=True)
contact_city = models.TextField(null=True, blank=True)
contact_street = models.TextField(null=True, blank=True)
contact_postal_code = models.TextField(null=True, blank=True)
contact_city = models.TextField(null=True, blank=True)
contact_country = models.TextField(null=True, blank=True)
contact_delivery_point = models.TextField(null=True, blank=True)
contact_voice = models.TextField(null=True, blank=True)
contact_facsimile = models.TextField(null=True, blank=True)
contact_email = models.TextField(null=True, blank=True)
contactus = models.BooleanField(default=False, verbose_name="Enable contact us box")
contact_name = models.CharField(max_length=255, null=True, blank=True)
contact_position = models.CharField(max_length=255, null=True, blank=True)
contact_administrative_area = models.CharField(max_length=255, null=True, blank=True)
contact_city = models.CharField(max_length=255, null=True, blank=True)
contact_street = models.CharField(max_length=255, null=True, blank=True)
contact_postal_code = models.CharField(max_length=255, null=True, blank=True)
contact_city = models.CharField(max_length=255, null=True, blank=True)
contact_country = models.CharField(max_length=255, null=True, blank=True)
contact_delivery_point = models.CharField(max_length=255, null=True, blank=True)
contact_voice = models.CharField(max_length=255, null=True, blank=True)
contact_facsimile = models.CharField(max_length=255, null=True, blank=True)
contact_email = models.CharField(max_length=255, null=True, blank=True)
partners_title = models.CharField(max_length=100, null=True, blank=True, default="Our Partners")
partners = models.ManyToManyField(Partner, related_name="partners", blank=True)
copyright = models.TextField(null=True, blank=True)
copyright_color = models.CharField(max_length=10, default="#2c689c")

def file_link(self):
if self.logo:
Expand Down

0 comments on commit 1f6b9f6

Please sign in to comment.