Skip to content

Commit

Permalink
Added AAQ mobile template.
Browse files Browse the repository at this point in the history
* Done with mobile/new_question.html general structure.
* TODO: lots of CSS, new_question_login.html, confirm_email.html
  • Loading branch information
rlr authored and Paul Craciunoiu committed Feb 23, 2011
1 parent 29f9bd8 commit 47c4433
Show file tree
Hide file tree
Showing 9 changed files with 284 additions and 124 deletions.
15 changes: 10 additions & 5 deletions apps/questions/question_config.py
Expand Up @@ -4,7 +4,8 @@

products = SortedDict([
('desktop', {
'name': _lazy(u'Firefox 3.6 or earlier on Desktops/Laptops/Netbooks'),
'name': _lazy(u'Firefox 3.6'),
'subtitle': _lazy(u'on Desktops/Laptops/Netbooks'),
'extra_fields': ['troubleshooting', 'ff_version', 'os', 'plugins'],
'tags': ['desktop'],
'categories': SortedDict([
Expand Down Expand Up @@ -106,7 +107,8 @@
])
}),
('beta', {
'name': _lazy(u'Firefox 4 betas on Desktops/Laptops/Netbooks'),
'name': _lazy(u'Firefox 4 Betas '),
'subtitle': _lazy(u'on Desktops/Laptops/Netbooks'),
'extra_fields': ['troubleshooting', 'ff_version', 'os', 'plugins'],
'tags': ['beta'],
'categories': SortedDict([
Expand Down Expand Up @@ -145,7 +147,8 @@
])
}),
('mobile', {
'name': _lazy(u'Firefox on Mobile (Android or Maemo systems)'),
'name': _lazy(u'Firefox for Mobile'),
'subtitle': _lazy(u'Android or Maemo systems'),
'extra_fields': ['ff_version', 'os', 'plugins'],
'tags': ['mobile'],
'categories': SortedDict([
Expand Down Expand Up @@ -226,7 +229,8 @@
])
}),
('home', {
'name': _lazy(u'Firefox Home App for iPhone'),
'name': _lazy(u'Firefox Home'),
'subtitle': _lazy(u'App for iPhone'),
'tags': ['FxHome'],
'categories': SortedDict([
('i1', {
Expand Down Expand Up @@ -340,7 +344,8 @@
])
}),
('other', {
'name': _lazy(u"Thunderbird (Mozilla's email client) or other Mozilla product"),
'name': _lazy(u"Thunderbird"),
'subtitle': _lazy(u"or other Mozilla product"),
'html': 'Support for Thunderbird and other Mozilla products can be found at'
' <a href="http://www.mozilla.org/support">Mozilla Support</a>.',
'categories': SortedDict([]),
Expand Down
99 changes: 99 additions & 0 deletions apps/questions/templates/questions/includes/aaq_macros.html
@@ -0,0 +1,99 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% macro select_product(products) -%}
<h2>{{ _('Which Firefox product would you like to post a question about?') }}</h2>
<ul class="select-one">
{% for key, product in products.iteritems() %}
<li>
<a href="{{ url('questions.new_question')|urlparams(product=key) }}">
{{ product.name }}
<span>{{ product.subtitle }}</span>
</a>
</li>
{% endfor %}
</ul>
{%- endmacro %}

{% macro selected_product(product, can_change) -%}
<div class="selected">
<label>{{ _('Product') }}:</label>
<span>{{ product.name }}</span>
{% if can_change %}
<a href="{{ url('questions.new_question') }}">{{ _('change') }}</a>
{% endif %}
</div>
{%- endmacro %}

{% macro select_category(product) -%}
<h2>{{ _('Which of these categories best describes your problem?') }}</h2>
<ul class="select-one">
{% for key, category in product.categories.iteritems() %}
<li>
<a href="{{ url('questions.new_question')|urlparams(product=product.key, category=key) }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
{%- endmacro %}

{% macro selected_category(category, product, can_change) -%}
<div class="selected">
<label>{{ _('Category') }}:</label>
<span>{{ category.name }}</span>
{% if can_change %}
<a href="{{ url('questions.new_question')|urlparams(product=product.key) }}">{{ _('change') }}</a>
{% endif %}
</div>
{%- endmacro %}

{% macro current_articles_and_html(articles, html, category) -%}
{% if html %}
<h2>{{ html|safe }}</h2>
{% else %}
<h2>{{ _('We have lots of helpful articles on <mark>{category}</mark> and hundreds of questions in our database. Try one of the following:')|fe(category=category.name) }}</h2>
{% endif %}
{% if articles %}
<ul class="articles select-one">
{% for article in articles %}
<li>
<a href="{{ article.url }}" target="_blank">{{ article.title }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{%- endmacro %}

{% macro aaq_search_form(product, category, settings, request) -%}
<form id="ask-search-form" class="aaq search" action="{% if settings.SESSION_COOKIE_SECURE %}https://{{ host }}{{ request.get_full_path() }}{% endif %}" method="get">
<input type="hidden" name="product" value="{{ product.key }}" />
<input type="hidden" name="category" value="{{ category.key }}" />
<input type="text" class="question" name="search" value="{{ request.GET.search }}" />
<input type="submit" class="btn btn-important" value="{{ _('Ask this') }}" />
</form>
{%- endmacro %}

{% macro show_results(search_results, product, category, request) -%}
{% if search_results %}
<h2>{{ _("We've found some articles and previously answered questions that may solve your issue:") }}</h2>
<ul class="select-one search-results">
{% for result in search_results %}
<li>
<a href="{{ result['url'] }}">{{ result['title'] }}</a>
<p>
{{ result['excerpt_html']|safe }}
</p>
</li>
{% endfor %}
</ul>
{% set button_text = _('None of these solve my problem') %}
{% else %}
<h2 class="no-results">{{ _('This question has not been asked before.') }}</h2>
{% set button_text = _('Provide more details') %}
{% endif %}

<form action="" method="get">
<input type="hidden" name="product" value="{{ product.key }}" />
<input type="hidden" name="category" value="{{ category.key }}" />
<input type="hidden" name="search" value="{{ request.GET.search }}" />
<input type="hidden" name="showform" value="1" />
<input type="submit" id="show-form-btn" class="btn" value="{{ button_text }}" />
</form>
{%- endmacro %}
Expand Up @@ -12,6 +12,7 @@
{% extends "questions/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "includes/common_macros.html" import content_editor %}
{% from "questions/includes/aaq_macros.html" import selected_product, selected_category %}
{% set classes = 'new-question' %}

{% block content %}
Expand All @@ -22,23 +23,13 @@ <h1>{% block headline %}Do Something to a Question{% endblock %}</h1>

{% block product %}
{% if current_product %}
<div class="selected">
<label>{{ _('Firefox Product') }}:</label>
<span>{{ current_product.name }}</span>
{% block product_changer %}
{% endblock %}
</div>
{{ selected_product(current_product, can_edit_product) }}
{% endif %}
{% endblock %}

{% block category %}
{% if current_product and current_category %}
<div class="selected">
<label>Category:</label>
<span>{{ current_category.name }}</span>
{% block category_changer %}
{% endblock %}
</div>
{{ selected_category(current_category, current_product, can_edit_category) }}
{% endif %}
{% endblock %}

Expand Down
75 changes: 75 additions & 0 deletions apps/questions/templates/questions/mobile/new_question.html
@@ -0,0 +1,75 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "mobile/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "questions/includes/aaq_macros.html" import select_product, selected_product, select_category, selected_category, current_articles_and_html, aaq_search_form, show_results %}
{% set title = _('Ask a New Question') %}
{% set classes = 'aaq' %}
{% set hide_extra_content = True %}

{% block content %}
<h1 class="title">{{ title }}</h1>

{% if not current_product %}
{{ select_product(products) }}
{% endif %}

{% if current_product and not current_category and current_product.categories %}
{{ select_category(current_product) }}
{% endif %}

{% if not tried_search and (current_articles or current_html) and not search_results and not form %}
{{ current_articles_and_html(current_articles, current_html, current_category) }}
{% if not form and not deadend %}
{% set form_header_set = True %}
<h2>{{ _('or, summarize your question in a sentence:') }}</h2>
{% endif %}
{% endif %}

{% if not tried_search and current_category and ((current_articles or search_results or current_html)
or not (current_articles and search_results and current_html))
and not form and not deadend %}
{% if not form_header_set %}
<h2>{{ _('Summarize your question in a sentence:') }}</h2>
{% endif %}
{{ aaq_search_form(current_product, current_category, settings, request) }}
{% endif %}

{% if tried_search and not form %}
{{ show_results(search_results, current_product, current_category, request) }}
{% endif %}

{% if form %}
<form id="question-form" action="" method="post">
{{ csrf() }}
<h2>{{ _('Fill in the details of your question:') }}</h2>
<h3>{{ _('The more information you can provide, the better the chance your question will be answered.') }}</h3>
{{ errorlist(form) }}
{% for field in form.hidden_fields() %}
{{ field|safe }}
{% endfor %}
<ol>
{% for field in form.visible_fields() %}
<li class="{% if field.errors %}invalid{% endif %}">
{{ field.label_tag()|safe }}
{{ field|safe }}
</li>
{% endfor %}
<li class="submit">
<input type="submit" value="{{ _('Post Question') }}" />
</li>
</ol>
</form>
{% endif %}

<div class="selections">
{% if current_product %}
{{ selected_product(current_product, True) }}
{% endif %}
{% if current_product and current_category %}
{{ selected_category(current_category, current_product, True) }}
{% endif %}
{% if tried_search %}
{{ aaq_search_form(current_product, current_category, settings, request) }}
{% endif %}
</div>
{% endblock %}
82 changes: 8 additions & 74 deletions apps/questions/templates/questions/new_question.html
@@ -1,71 +1,34 @@
{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "questions/includes/question_editing_frame.html" %}
{% from "questions/includes/aaq_macros.html" import select_product, select_category, current_articles_and_html, aaq_search_form, show_results %}
{% set title = _('Ask a Question') %}
{% set crumbs = [(url('questions.questions'), _('Forum')),
(None, _('Ask a New Question'))] %}
{% set can_edit_product = True %}
{% set can_edit_category = True %}

{% block headline %}{{ _('Ask a New Question') }}{% endblock %}

{% block product %}
{% if not current_product %}
<h2>{{ _('Which Firefox product would you like to post a question about?') }}</h2>
<ul class="select-one">
{% for key, product in products.iteritems() %}
<li>
<a href="{{ url('questions.new_question')|urlparams(product=key) }}">{{ product.name }}</a>
</li>
{% endfor %}
</ul>
{{ select_product(products) }}
{% else %}
{{ super() }}
{% endif %}
{% endblock %}

{% block product_changer %}
{% if current_product %}
<a href="{{ url('questions.new_question') }}">{{ _('change') }}</a>
{% endif %}
{% endblock %}


{% block category %}
{% if current_product and not current_category and current_product.categories %}
<h2>{{ _('Which of these categories best describes your problem?') }}</h2>
<ul class="select-one">
{% for key, category in current_product.categories.iteritems() %}
<li>
<a href="{{ url('questions.new_question')|urlparams(product=current_product.key, category=key) }}">{{ category.name }}</a>
</li>
{% endfor %}
</ul>
{{ select_category(current_product) }}
{% else %}
{{ super() }}
{% endif %}
{% endblock %}

{% block category_changer %}
{% if not (current_product and not current_category) %}
<a href="{{ url('questions.new_question')|urlparams(product=current_product.key) }}">{{ _('change') }}</a>
{% endif %}
{% endblock %}

{% block articles_and_search_results %}
{% set form_header_set = False %}
{% if (current_articles or current_html) and not search_results and not form %}
{% if current_html %}
<h2>{{ current_html|safe }}</h2>
{% else %}
<h2>{{ _('We have lots of helpful articles on <mark>{category}</mark> and hundreds of questions in our database. Try one of the following:')|fe(category=current_category.name) }}</h2>
{% endif %}
{% if current_articles %}
<ul class="articles">
{% for article in current_articles %}
<li>
<a href="{{ article.url }}" target="_blank">{{ article.title }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{{ current_articles_and_html(current_articles, current_html, current_category) }}
{% if not form and not deadend %}
{% set form_header_set = True %}
<h2>{{ _('or, summarize your question in a sentence:') }}</h2>
Expand All @@ -78,40 +41,11 @@ <h2>{{ _('or, summarize your question in a sentence:') }}</h2>
{% if not form_header_set %}
<h2>{{ _('Summarize your question in a sentence:') }}</h2>
{% endif %}
<form id="ask-search-form" class="search" action="{% if settings.SESSION_COOKIE_SECURE %}https://{{ host }}{{ request.get_full_path() }}{% endif %}#ask-search-form" method="get">
<input type="hidden" name="product" value="{{ current_product.key }}" />
<input type="hidden" name="category" value="{{ current_category.key }}" />
<input type="text" class="question" name="search" value="{{ request.GET.search }}" />
<input type="submit" class="btn btn-important" value="{{ _('Ask this') }}" />
</form>
{{ aaq_search_form(current_product, current_category, settings, request) }}
{% endif %}

{% if tried_search and not form %}
{% if search_results %}
<h3>{{ _("We've found some articles and previously answered questions that may solve your issue:") }}</h3>
<ul class="search-results">
{% for result in search_results %}
<li>
<a href="{{ result['url'] }}">{{ result['title'] }}</a>
<p>
{{ result['excerpt_html']|safe }}
</p>
</li>
{% endfor %}
</ul>
{% set button_text = _('None of these solve my problem') %}
{% else %}
<h3 class="no-results">{{ _('This question has not been asked before.') }}</h3>
{% set button_text = _('Provide more details') %}
{% endif %}

<form action="#question-form" method="get">
<input type="hidden" name="product" value="{{ current_product.key }}" />
<input type="hidden" name="category" value="{{ current_category.key }}" />
<input type="hidden" name="search" value="{{ request.GET.search }}" />
<input type="hidden" name="showform" value="1" />
<input type="submit" id="show-form-btn" class="btn" value="{{ button_text }}" />
</form>
{{ show_results(search_results, current_product, current_category, request) }}
{% endif %}

{% endblock %}
Expand Down

0 comments on commit 47c4433

Please sign in to comment.