updated vue and vue bootrap + template improvements
This commit is contained in:
@ -1,24 +1,35 @@
|
||||
import bleach
|
||||
import markdown as md
|
||||
from bleach_whitelist import markdown_tags, markdown_attrs
|
||||
from jinja2 import Template
|
||||
from jinja2 import Template, TemplateSyntaxError
|
||||
|
||||
from cookbook.helper.mdx_attributes import MarkdownFormatExtension
|
||||
from cookbook.helper.mdx_urlize import UrlizeExtension
|
||||
|
||||
|
||||
class IngredientObject(object):
|
||||
amount = None
|
||||
unit = None
|
||||
food = None
|
||||
amount = ""
|
||||
unit = ""
|
||||
food = ""
|
||||
note = ""
|
||||
|
||||
def __init__(self, ingredient):
|
||||
if ingredient.no_amount:
|
||||
self.amount = ""
|
||||
else:
|
||||
self.amount = f'[[calculateAmount({ingredient.amount})]]'
|
||||
if ingredient.unit:
|
||||
self.unit = ingredient.unit
|
||||
else:
|
||||
self.unit = ""
|
||||
self.food = ingredient.food
|
||||
self.note = ingredient.note
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.amount} {self.unit} {self.food}'
|
||||
ingredient = self.amount
|
||||
if self.unit != "":
|
||||
ingredient += f' {self.unit}'
|
||||
return f'{ingredient} {self.food}'
|
||||
|
||||
|
||||
def render_instructions(step): # TODO deduplicate markdown cleanup code
|
||||
@ -28,8 +39,11 @@ def render_instructions(step): # TODO deduplicate markdown cleanup code
|
||||
for i in step.ingredients.all():
|
||||
ingredients.append(IngredientObject(i))
|
||||
|
||||
try:
|
||||
template = Template(step.instruction)
|
||||
instructions = template.render(ingredients=ingredients)
|
||||
except TemplateSyntaxError:
|
||||
instructions = step.instruction
|
||||
|
||||
tags = markdown_tags + ['pre', 'table', 'td', 'tr', 'th', 'tbody', 'style', 'thead']
|
||||
parsed_md = md.markdown(instructions, extensions=['markdown.extensions.fenced_code', 'tables', UrlizeExtension(), MarkdownFormatExtension()])
|
||||
|
4
cookbook/static/css/bootstrap-vue.min.css
vendored
4
cookbook/static/css/bootstrap-vue.min.css
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* Vue.js v2.6.11
|
||||
* (c) 2014-2019 Evan You
|
||||
* Vue.js v2.6.12
|
||||
* (c) 2014-2020 Evan You
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
(function (global, factory) {
|
||||
@ -5443,7 +5443,7 @@
|
||||
value: FunctionalRenderContext
|
||||
});
|
||||
|
||||
Vue.version = '2.6.11';
|
||||
Vue.version = '2.6.12';
|
||||
|
||||
/* */
|
||||
|
||||
@ -7649,7 +7649,7 @@
|
||||
// skip the update if old and new VDOM state is the same.
|
||||
// `value` is handled separately because the DOM value may be temporarily
|
||||
// out of sync with VDOM state due to focus, composition and modifiers.
|
||||
// This #4521 by skipping the unnecesarry `checked` update.
|
||||
// This #4521 by skipping the unnecessary `checked` update.
|
||||
cur !== oldProps[key]
|
||||
) {
|
||||
// some property updates can throw
|
||||
@ -9894,7 +9894,7 @@
|
||||
}
|
||||
},
|
||||
comment: function comment (text, start, end) {
|
||||
// adding anyting as a sibling to the root node is forbidden
|
||||
// adding anything as a sibling to the root node is forbidden
|
||||
// comments should still be allowed, but ignored
|
||||
if (currentParent) {
|
||||
var child = {
|
||||
|
6
cookbook/static/js/vue.min.js
vendored
6
cookbook/static/js/vue.min.js
vendored
File diff suppressed because one or more lines are too long
@ -325,6 +325,10 @@
|
||||
@click="ingredient.no_amount = false"><i
|
||||
class="fas fa-balance-scale-right fa-fw"></i> {% trans 'Enable Amount' %}
|
||||
</button>
|
||||
<button type="button" class="dropdown-item"
|
||||
@click="copyTemplateReference(index)"><i
|
||||
class="fas fa-code"></i> {% trans 'Copy Template Reference' %}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -699,6 +703,14 @@
|
||||
},
|
||||
removeNutrition: function () {
|
||||
this.recipe.nutrition = null
|
||||
},
|
||||
copyTemplateReference: function (index) {
|
||||
const el = document.createElement('textarea');
|
||||
el.value = `\u007B\u007B ingredients[${index}] \u007D\u007D`;
|
||||
document.body.appendChild(el);
|
||||
el.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(el);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user