##// END OF EJS Templates
Simplification of the logic.
damianavila -
Show More
@@ -1,179 +1,165 b''
1 {%- extends 'display_priority.tpl' -%}
1 {%- extends 'display_priority.tpl' -%}
2
2
3
3
4 {% block codecell %}
4 {% block codecell %}
5 <div class="cell border-box-sizing code_cell">
5 <div class="cell border-box-sizing code_cell">
6 {{ super() }}
6 {{ super() }}
7 </div>
7 </div>
8 {%- endblock codecell %}
8 {%- endblock codecell %}
9
9
10 {% block input_group -%}
10 {% block input_group -%}
11 <div class="input">
11 <div class="input">
12 {{ super() }}
12 {{ super() }}
13 </div>
13 </div>
14 {% endblock input_group %}
14 {% endblock input_group %}
15
15
16 {% block m_input_group -%}
17 <div class="input">
18 {{ super() }}
19 </div>
20 {% endblock m_input_group %}
21
22 {% block h_input_group -%}
23 <div class="input">
24 {{ super() }}
25 </div>
26 {% endblock h_input_group %}
27
28 {% block r_input_group -%}
29 {{ super() }}
30 {% endblock r_input_group %}
31
32 {% block u_input_group -%}
33 {{ super() }}
34 {% endblock u_input_group %}
35
36 {% block output_group %}
16 {% block output_group %}
37 <div class="output_wrapper">
17 <div class="output_wrapper">
38 <div class="output">
18 <div class="output">
39 {{ super() }}
19 {{ super() }}
40 </div>
20 </div>
41 </div>
21 </div>
42 {% endblock output_group %}
22 {% endblock output_group %}
43
23
44 {% block in_prompt -%}
24 {% block in_prompt -%}
45 <div class="prompt input_prompt">
25 <div class="prompt input_prompt">
46 In&nbsp;[{{ cell.prompt_number }}]:
26 In&nbsp;[{{ cell.prompt_number }}]:
47 </div>
27 </div>
48 {%- endblock in_prompt %}
28 {%- endblock in_prompt %}
49
29
50 {% block e_in_prompt -%}
30 {% block e_in_prompt -%}
51 <div class="prompt input_prompt">
31 <div class="prompt input_prompt">
52 </div>
32 </div>
53 {%- endblock e_in_prompt %}
33 {%- endblock e_in_prompt %}
54
34
55 {#
35 {#
56 output_prompt doesn't do anything in HTML,
36 output_prompt doesn't do anything in HTML,
57 because there is a prompt div in each output area (see output block)
37 because there is a prompt div in each output area (see output block)
58 #}
38 #}
59 {% block output_prompt %}
39 {% block output_prompt %}
60 {% endblock output_prompt %}
40 {% endblock output_prompt %}
61
41
62 {% block input %}
42 {% block input %}
63 <div class="input_area box-flex1">
43 <div class="input_area box-flex1">
64 {{ cell.input | highlight2html(metadata=cell.metadata) }}
44 {{ cell.input | highlight2html(metadata=cell.metadata) }}
65 </div>
45 </div>
66 {%- endblock input %}
46 {%- endblock input %}
67
47
68 {% block output %}
48 {% block output %}
69 <div class="output_area">
49 <div class="output_area">
70 {%- if output.output_type == 'pyout' -%}
50 {%- if output.output_type == 'pyout' -%}
71 <div class="prompt output_prompt">
51 <div class="prompt output_prompt">
72 Out[{{ cell.prompt_number }}]:
52 Out[{{ cell.prompt_number }}]:
73 {%- else -%}
53 {%- else -%}
74 <div class="prompt">
54 <div class="prompt">
75 {%- endif -%}
55 {%- endif -%}
76 </div>
56 </div>
77 {{ super() }}
57 {{ super() }}
78 </div>
58 </div>
79 {% endblock output %}
59 {% endblock output %}
80
60
81 {% block m_input %}
61 {% block markdowncell scoped %}
62 <div class="input">
63 {{ self.e_in_prompt() }}
82 <div class="inner_cell">
64 <div class="inner_cell">
83 <div class="text_cell_render border-box-sizing rendered_html">
65 <div class="text_cell_render border-box-sizing rendered_html">
84 {{ cell.source | markdown2html | strip_files_prefix }}
66 {{ cell.source | markdown2html | strip_files_prefix }}
85 </div>
67 </div>
86 </div>
68 </div>
87 {%- endblock m_input %}
69 </div>
70 {%- endblock markdowncell %}
88
71
89 {% block h_input %}
72 {% block headingcell scoped %}
73 <div class="input">
74 {{ self.e_in_prompt() }}
90 <div class="inner_cell">
75 <div class="inner_cell">
91 <div class="text_cell_render border-box-sizing rendered_html">
76 <div class="text_cell_render border-box-sizing rendered_html">
92 {{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2html | strip_files_prefix | add_anchor }}
77 {{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2html | strip_files_prefix | add_anchor }}
93 </div>
78 </div>
94 </div>
79 </div>
95 {% endblock h_input %}
80 </div>
81 {% endblock headingcell %}
96
82
97 {% block r_input %}
83 {%- block rawcell scoped -%}
98 {% if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype', '')).lower() in resources.get('raw_mimetypes', ['']) %}
84 {% if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype', '')).lower() in resources.get('raw_mimetypes', ['']) %}
99 {{ cell.source }}
85 {{ cell.source }}
100 {% endif %}
86 {% endif %}
101 {% endblock r_input %}
87 {%- endblock rawcell -%}
102
88
103 {% block u_input %}
89 {% block unknowncell scoped %}
104 unknown type {{ cell.type }}
90 unknown type {{ cell.type }}
105 {% endblock u_input %}
91 {% endblock unknowncell %}
106
92
107 {% block pyout -%}
93 {% block pyout -%}
108 <div class="box-flex1 output_subarea output_pyout">
94 <div class="box-flex1 output_subarea output_pyout">
109 {% block data_priority scoped %}
95 {% block data_priority scoped %}
110 {{ super() }}
96 {{ super() }}
111 {% endblock %}
97 {% endblock %}
112 </div>
98 </div>
113 {%- endblock pyout %}
99 {%- endblock pyout %}
114
100
115 {% block stream_stdout -%}
101 {% block stream_stdout -%}
116 <div class="box-flex1 output_subarea output_stream output_stdout">
102 <div class="box-flex1 output_subarea output_stream output_stdout">
117 <pre>
103 <pre>
118 {{ output.text | ansi2html }}
104 {{ output.text | ansi2html }}
119 </pre>
105 </pre>
120 </div>
106 </div>
121 {%- endblock stream_stdout %}
107 {%- endblock stream_stdout %}
122
108
123 {% block stream_stderr -%}
109 {% block stream_stderr -%}
124 <div class="box-flex1 output_subarea output_stream output_stderr">
110 <div class="box-flex1 output_subarea output_stream output_stderr">
125 <pre>
111 <pre>
126 {{ output.text | ansi2html }}
112 {{ output.text | ansi2html }}
127 </pre>
113 </pre>
128 </div>
114 </div>
129 {%- endblock stream_stderr %}
115 {%- endblock stream_stderr %}
130
116
131 {% block data_svg -%}
117 {% block data_svg -%}
132 {{ output.svg }}
118 {{ output.svg }}
133 {%- endblock data_svg %}
119 {%- endblock data_svg %}
134
120
135 {% block data_html -%}
121 {% block data_html -%}
136 <div class="output_html rendered_html">
122 <div class="output_html rendered_html">
137 {{ output.html }}
123 {{ output.html }}
138 </div>
124 </div>
139 {%- endblock data_html %}
125 {%- endblock data_html %}
140
126
141 {% block data_png %}
127 {% block data_png %}
142 <img src="data:image/png;base64,{{ output.png }}">
128 <img src="data:image/png;base64,{{ output.png }}">
143 {%- endblock data_png %}
129 {%- endblock data_png %}
144
130
145 {% block data_jpg %}
131 {% block data_jpg %}
146 <img src="data:image/jpeg;base64,{{ output.jpeg }}">
132 <img src="data:image/jpeg;base64,{{ output.jpeg }}">
147 {%- endblock data_jpg %}
133 {%- endblock data_jpg %}
148
134
149 {% block data_latex %}
135 {% block data_latex %}
150 {{ output.latex }}
136 {{ output.latex }}
151 {%- endblock data_latex %}
137 {%- endblock data_latex %}
152
138
153 {% block pyerr -%}
139 {% block pyerr -%}
154 <div class="box-flex1 output_subarea output_pyerr">
140 <div class="box-flex1 output_subarea output_pyerr">
155 <pre>{{ super() }}</pre>
141 <pre>{{ super() }}</pre>
156 </div>
142 </div>
157 {%- endblock pyerr %}
143 {%- endblock pyerr %}
158
144
159 {%- block traceback_line %}
145 {%- block traceback_line %}
160 {{ line | ansi2html }}
146 {{ line | ansi2html }}
161 {%- endblock traceback_line %}
147 {%- endblock traceback_line %}
162
148
163 {%- block data_text %}
149 {%- block data_text %}
164 <pre>
150 <pre>
165 {{ output.text | ansi2html }}
151 {{ output.text | ansi2html }}
166 </pre>
152 </pre>
167 {%- endblock -%}
153 {%- endblock -%}
168
154
169 {%- block data_javascript %}
155 {%- block data_javascript %}
170 <script type="text/javascript">
156 <script type="text/javascript">
171 {{ output.javascript }}
157 {{ output.javascript }}
172 </script>
158 </script>
173 {%- endblock -%}
159 {%- endblock -%}
174
160
175 {%- block display_data scoped -%}
161 {%- block display_data scoped -%}
176 <div class="box-flex1 output_subarea output_display_data">
162 <div class="box-flex1 output_subarea output_display_data">
177 {{ super() }}
163 {{ super() }}
178 </div>
164 </div>
179 {%- endblock display_data -%}
165 {%- endblock display_data -%}
@@ -1,106 +1,94 b''
1 {#
1 {#
2
2
3 DO NOT USE THIS AS A BASE,
3 DO NOT USE THIS AS A BASE,
4 IF YOU ARE COPY AND PASTING THIS FILE
4 IF YOU ARE COPY AND PASTING THIS FILE
5 YOU ARE PROBABLY DOING THINGS INCORRECTLY.
5 YOU ARE PROBABLY DOING THINGS INCORRECTLY.
6
6
7 Null template, does nothing except defining a basic structure
7 Null template, does nothing except defining a basic structure
8 To layout the different blocks of a notebook.
8 To layout the different blocks of a notebook.
9
9
10 Subtemplates can override blocks to define their custom representation.
10 Subtemplates can override blocks to define their custom representation.
11
11
12 If one of the block you do overwrite is not a leave block, consider
12 If one of the block you do overwrite is not a leave block, consider
13 calling super.
13 calling super.
14
14
15 {%- block nonLeaveBlock -%}
15 {%- block nonLeaveBlock -%}
16 #add stuff at beginning
16 #add stuff at beginning
17 {{ super() }}
17 {{ super() }}
18 #add stuff at end
18 #add stuff at end
19 {%- endblock nonLeaveBlock -%}
19 {%- endblock nonLeaveBlock -%}
20
20
21 consider calling super even if it is a leave block, we might insert more blocks later.
21 consider calling super even if it is a leave block, we might insert more blocks later.
22
22
23 #}
23 #}
24 {%- block header -%}
24 {%- block header -%}
25 {%- endblock header -%}
25 {%- endblock header -%}
26 {%- block body -%}
26 {%- block body -%}
27 {%- for worksheet in nb.worksheets -%}
27 {%- for worksheet in nb.worksheets -%}
28 {%- for cell in worksheet.cells -%}
28 {%- for cell in worksheet.cells -%}
29 {%- block any_cell scoped -%}
29 {%- block any_cell scoped -%}
30 {%- if cell.cell_type in ['code'] -%}
30 {%- if cell.cell_type in ['code'] -%}
31 {%- block codecell scoped -%}
31 {%- block codecell scoped -%}
32 {%- block input_group -%}
32 {%- block input_group -%}
33 {%- block in_prompt -%}{%- endblock in_prompt -%}
33 {%- block in_prompt -%}{%- endblock in_prompt -%}
34 {%- block input -%}{%- endblock input -%}
34 {%- block input -%}{%- endblock input -%}
35 {%- endblock input_group -%}
35 {%- endblock input_group -%}
36 {%- if cell.outputs -%}
36 {%- if cell.outputs -%}
37 {%- block output_group -%}
37 {%- block output_group -%}
38 {%- block output_prompt -%}{%- endblock output_prompt -%}
38 {%- block output_prompt -%}{%- endblock output_prompt -%}
39 {%- block outputs scoped -%}
39 {%- block outputs scoped -%}
40 {%- for output in cell.outputs -%}
40 {%- for output in cell.outputs -%}
41 {%- block output scoped -%}
41 {%- block output scoped -%}
42 {%- if output.output_type in ['pyout'] -%}
42 {%- if output.output_type in ['pyout'] -%}
43 {%- block pyout scoped -%}{%- endblock pyout -%}
43 {%- block pyout scoped -%}{%- endblock pyout -%}
44 {%- elif output.output_type in ['stream'] -%}
44 {%- elif output.output_type in ['stream'] -%}
45 {%- block stream scoped -%}
45 {%- block stream scoped -%}
46 {%- if output.stream in ['stdout'] -%}
46 {%- if output.stream in ['stdout'] -%}
47 {%- block stream_stdout scoped -%}
47 {%- block stream_stdout scoped -%}
48 {%- endblock stream_stdout -%}
48 {%- endblock stream_stdout -%}
49 {%- elif output.stream in ['stderr'] -%}
49 {%- elif output.stream in ['stderr'] -%}
50 {%- block stream_stderr scoped -%}
50 {%- block stream_stderr scoped -%}
51 {%- endblock stream_stderr -%}
51 {%- endblock stream_stderr -%}
52 {%- endif -%}
52 {%- endif -%}
53 {%- endblock stream -%}
53 {%- endblock stream -%}
54 {%- elif output.output_type in ['display_data'] -%}
54 {%- elif output.output_type in ['display_data'] -%}
55 {%- block display_data scoped -%}
55 {%- block display_data scoped -%}
56 {%- block data_priority scoped -%}
56 {%- block data_priority scoped -%}
57 {%- endblock data_priority -%}
57 {%- endblock data_priority -%}
58 {%- endblock display_data -%}
58 {%- endblock display_data -%}
59 {%- elif output.output_type in ['pyerr'] -%}
59 {%- elif output.output_type in ['pyerr'] -%}
60 {%- block pyerr scoped -%}
60 {%- block pyerr scoped -%}
61 {%- for line in output.traceback -%}
61 {%- for line in output.traceback -%}
62 {%- block traceback_line scoped -%}{%- endblock traceback_line -%}
62 {%- block traceback_line scoped -%}{%- endblock traceback_line -%}
63 {%- endfor -%}
63 {%- endfor -%}
64 {%- endblock pyerr -%}
64 {%- endblock pyerr -%}
65 {%- endif -%}
65 {%- endif -%}
66 {%- endblock output -%}
66 {%- endblock output -%}
67 {%- endfor -%}
67 {%- endfor -%}
68 {%- endblock outputs -%}
68 {%- endblock outputs -%}
69 {%- endblock output_group -%}
69 {%- endblock output_group -%}
70 {%- endif -%}
70 {%- endif -%}
71 {%- endblock codecell -%}
71 {%- endblock codecell -%}
72 {%- elif cell.cell_type in ['markdown'] -%}
72 {%- elif cell.cell_type in ['markdown'] -%}
73 {%- block markdowncell scoped-%}
73 {%- block markdowncell scoped-%}
74 {%- block m_input_group -%}
75 {%- block e_in_prompt -%}{%- endblock e_in_prompt -%}
76 {%- block m_input -%}{%- endblock m_input -%}
77 {%- endblock m_input_group -%}
78 {%- endblock markdowncell -%}
74 {%- endblock markdowncell -%}
79 {%- elif cell.cell_type in ['heading'] -%}
75 {%- elif cell.cell_type in ['heading'] -%}
80 {%- block headingcell scoped-%}
76 {%- block headingcell scoped-%}
81 {%- block h_input_group -%}
82 {{ self.e_in_prompt() }}
83 {%- block h_input -%}{%- endblock h_input -%}
84 {%- endblock h_input_group -%}
85 {%- endblock headingcell -%}
77 {%- endblock headingcell -%}
86 {%- elif cell.cell_type in ['raw'] -%}
78 {%- elif cell.cell_type in ['raw'] -%}
87 {%- block rawcell scoped -%}
79 {%- block rawcell scoped -%}
88 {% if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %}
80 {% if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %}
89 {{ cell.source }}
81 {{ cell.source }}
90 {% endif %}
82 {% endif %}
91 {%- endblock rawcell -%}
83 {%- endblock rawcell -%}
92 {%- else -%}
84 {%- else -%}
93 {%- block unknowncell scoped-%}
85 {%- block unknowncell scoped-%}
94 {%- block u_input_group -%}
95 {{ self.e_in_prompt() }}
96 {%- block u_input -%}{%- endblock u_input -%}
97 {%- endblock u_input_group -%}
98 {%- endblock unknowncell -%}
86 {%- endblock unknowncell -%}
99 {%- endif -%}
87 {%- endif -%}
100 {%- endblock any_cell -%}
88 {%- endblock any_cell -%}
101 {%- endfor -%}
89 {%- endfor -%}
102 {%- endfor -%}
90 {%- endfor -%}
103 {%- endblock body -%}
91 {%- endblock body -%}
104
92
105 {%- block footer -%}
93 {%- block footer -%}
106 {%- endblock footer -%}
94 {%- endblock footer -%}
General Comments 0
You need to be logged in to leave comments. Login now