Added in a few blank lines when a user edits the metadata of a file that has
[mediagoblin.git] / mediagoblin / templates / mediagoblin / edit / metadata.html
CommitLineData
fffc5dcf 1{#
2# GNU MediaGoblin -- federated, autonomous media hosting
3# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Affero General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#}
18{%- extends "mediagoblin/base.html" %}
19{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
e80596c8 20{% block mediagoblin_head %}
21 <script>
22 function add_new_row(table_id, row_number, input_prefix) {
23 new_row = $('<tr>').append(
24 $('<td>').attr(
25 'class','form_field_input').append(
26 $('<input>').attr('name',
27 input_prefix + row_number + "-identifier").attr('id',
28 input_prefix + row_number + "-identifier")
29 )
30 ).append(
31 $('<td>').attr(
32 'class','form_field_input').append(
33 $('<input>').attr('name',
34 input_prefix + row_number + "-value").attr('id',
35 input_prefix + row_number + "-value")
36 )
37 );
38 $(table_id).append(new_row);
39 }
40 function clear_empty_rows(list_id) {
41 $('table'+list_id+' tr').each(function(row){
42 id_input = $(this).find('td').find('input');
43 value_input = $(this).find('td').next().find('input');
9919fb08 44 if ((value_input.attr('value') == "") &&
e80596c8 45 (id_input.attr('value') == "")) {
46 $(this).remove();
47 }
48 })
49 }
fffc5dcf 50
e80596c8 51 $(document).ready(function(){
52 var context_lines = {{ form.context | length }};
53 var metadata_lines = {{ form.media_metadata | length }};
54 $("#add_new_metadata_row").click(function(){
9919fb08 55 add_new_row("#metadata_list",
e80596c8 56 metadata_lines,
57 'media_metadata-');
58 metadata_lines += 1;
59 })
60 $("#add_new_context_row").click(function(){
9919fb08 61 add_new_row("#context_list",
e80596c8 62 context_lines,
63 'context-');
64 context_lines += 1;
65 })
66 $("#clear_empty_rows").click(function(){
67 clear_empty_rows("#context_list");
68 clear_empty_rows("#metadata_list");
69 })
70 })
71 </script>
72{% endblock %}
fffc5dcf 73{% block mediagoblin_content %}
e80596c8 74 <h2>{% trans media_name=media.title -%}
75 Metadata for "{{ media_name }}"{% endtrans %}</h2>
76 <form action="" method="POST" id="metadata_form">
77<!-- This table holds all the information about the metadata's context.
78 visit http:/wwww.json-ld.org for more information. -->
79 <h3>{% trans %}Context{% endtrans %}</h3>
80 <table class="metadata_editor" id="context_list">
81 <tr>
82 <td><a class="strong highlight">
83 {% trans %}Identifier{% endtrans %}</a></td>
84 <td><a class="strong highlight">{% trans %}Value{% endtrans %}</a></td>
85 </tr>
86 {% for miniform in form.context -%}
87 {{ wtforms_util.render_table_row(miniform) }}
88 {% endfor -%}
89 </table>
90
91 <table class="metadata_editor" id="buttons_top">
92 <tr>
93 <td><input type=button value="{% trans %}Add new Row{% endtrans %}"
94 class="button_action" id="add_new_context_row" /></td>
95 <td></td>
96 </tr>
97 </table>
98
99<!-- This table holds all the information about the media entry's metadata -->
100 <h3>{% trans %}Data{% endtrans %}</h3>
101 <table class="metadata_editor" id="metadata_list" >
102 <tr>
103 <td><a class="strong highlight">
104 {% trans %}Identifier{% endtrans %}</a></td>
105 <td><a class="strong highlight">{% trans %}Value{% endtrans %}</a></td>
106 </tr>
107 {% for miniform in form.media_metadata -%}
108 {{ wtforms_util.render_table_row(miniform) }}
109 {% endfor -%}
110 </table>
111
112<!-- These are the buttons you use to control the form -->
113 <table class="metadata_editor" id="buttons_bottom">
114 <tr>
115 <td><input type=button value="{% trans %}Add new Row{% endtrans %}"
116 class="button_action" id="add_new_metadata_row" />
117 </td>
9919fb08 118 <td><input type=submit value="{% trans %}Update Metadata{% endtrans %}"
e80596c8 119 class="button_action_highlight" /></td>
120 </tr>
121 <tr>
122 <td><input type=button value="{% trans %}Clear empty Rows{% endtrans %}"
123 class="button_action" id="clear_empty_rows" /></td>
124 </tr>
125 </table>
126 {{ csrf_token }}
127 </form>
9919fb08 128
fffc5dcf 129{% endblock mediagoblin_content %}