Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
bug 1044093 - Display known information about kumascript errors, add …
Browse files Browse the repository at this point in the history
…toggle button

Complete kumascript error toggling

Fix test failures
  • Loading branch information
darkwing authored and groovecoder committed Aug 20, 2014
1 parent 0e7daac commit 86ac9e1
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 31 deletions.
85 changes: 55 additions & 30 deletions kuma/wiki/templates/wiki/includes/kumascript_errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,62 @@

</p>
{% if request.user.is_authenticated() %}
<button type="button">
{{ ngettext(
'More information about this error',
'More information about these errors',
kumascript_errors|count)
}}
<button type="button" class="kumascript-detail-toggle" data-alternate-message="{{ _('Hide error information') }}">
{{ ngettext(
'More information about this error',
'More information about these errors',
kumascript_errors|count)
}}
</button>
<p>{% trans %}
Anyone with an MDN account can edit a document to fix an error. Use the <a href="/docs/MDN/Kuma/Troubleshooting_KumaScript_errors">KumaScript troubleshooting guide</a> as a starting point.
{% endtrans %}</p>
<div>
{% for error in kumascript_errors %}
<p>
{% if error.args %}
{% set err_type = error.args[0] %}
{{ _('Error type:') }} <strong class="type">{{ err_type }}</strong><br>
<!-- if line and column (no more offest) -->
{{ _('Line:') }} <!-- line --><br>
{{ _('Column:') }} <!-- col --><br>
<!-- / if -->
<!-- if problem was in the macro not this document -->
{{ _('In macro:') }} <code><!-- macro name --></code> (<!-- link to edit -->)<br>
<!-- /if -->
<!-- if problem was figuring how which/how to include a macro -->
{{ _('Parsing macro:') }} <code><!-- macro name & arguments (the arguments are being output with a funny character in them right now, I think there is a problem with how they are being escaped/unescaped) --></code> (<!-- link to edit or create -->)<br>
<!-- / if -->
{{ _('Full text of error:') }}<br>
{% endif %}
<pre class="message brush: text">{{ error.message }}</pre>
</p>
{% endfor %}
<div class="kumascript-details hidden">
<p>{% trans %}
Anyone with an MDN account can edit a document to fix an error. Use the <a href="/docs/MDN/Kuma/Troubleshooting_KumaScript_errors">KumaScript troubleshooting guide</a> as a starting point.
{% endtrans %}</p>

<ul>
{% for error in kumascript_errors %}
<li>
{% if error.args %}

{% set error_type = error.args[0] %}
{{ _('Error type:') }} <strong class="type">{{ error_type }}</strong><br>

{% set error_meta = error.args[2] %}
{% if error_meta %}
{% set template_name = error_meta.name %}
{% set template_args = error_meta.args %}

{% if '$' not in template_name %}
{% set template_slug = 'Template:{name}' | f(name=template_name) %}
{% set edit_url = url('wiki.edit_document', template_slug) %}
{% set new_url = url('wiki.new_document') + '?slug=Template:{name}' | f(name=error_meta.name) %}
{% endif %}

{# TODO: Provide line and column instead off "offset" property, if possible
<!-- if line and column (no more offest) -->
{{ _('Line:') }} <!-- line --><br>
{{ _('Column:') }} {{ error_meta.offset }}<br>
<!-- / if -->
#}

{{ _('In macro:') }} <code>{{ error_meta.name }}</code>

{% if 'status 404' in error.message %}
{% if new_url %}
(<a href="{{ new_url }}">{{ _('Create Template') }}</a>)
{% endif %}
{% elif edit_url %}
(<a href="{{ edit_url }}">{{ _('Edit Template') }}</a>)
{% endif %}<br>

{{ _('Parsing macro:') }} <code>{{ error_meta.name }}({{ error_meta.token.args }})</code> (<a href="{{ url('wiki.edit_document', document.slug) }}">{{ _('Edit Document') }}</a>)<br>
{{ _('Full text of error:') }}<br>
{% endif %}
{% endif %}
<pre class="message brush: text">{{ error.message }}</pre>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
1 change: 0 additions & 1 deletion media/redesign/js/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@
Plugin to toggle button messages
*/
$.fn.toggleMessage = function(options){

var settings = $.extend({
event: 'click',
toggleCallback: noop
Expand Down
10 changes: 10 additions & 0 deletions media/redesign/js/wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@
});
});

/*
Toggle kumascript error detail pane
*/
$('.kumascript-detail-toggle').toggleMessage({
toggleCallback: function() {
$('.kumascript-details').toggleClass('hidden');
}
});


/*
Stack overflow search form, used for dev program
ex: http://stackoverflow.com/search?q=[firefox]+or+[firefox-os]+or+[html5-apps]+foobar
Expand Down
4 changes: 4 additions & 0 deletions media/redesign/stylus/wiki.styl
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ article {
}
}

.kumascript-details {
padding: $grid-spacing 0;
}

/* wiki summary, usually displays at the top of the article */
.summary {
background: $light-background-color;
Expand Down

0 comments on commit 86ac9e1

Please sign in to comment.