Introducing attachments fixes for blog posts and assets.
Requires migration of attachments schema using python manage.py maintenance upgrade_attachment_schema --all
This commit is contained in:
@@ -23,6 +23,14 @@ _attachments_embedded_schema = {
|
|||||||
'type': 'objectid',
|
'type': 'objectid',
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
},
|
||||||
|
'link': {
|
||||||
|
'type': 'string',
|
||||||
|
'allowed': ['self', 'none', 'custom'],
|
||||||
|
'default': 'self',
|
||||||
|
},
|
||||||
|
'link_custom': {
|
||||||
|
'type': 'string',
|
||||||
|
},
|
||||||
'collection': {
|
'collection': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'allowed': ['files'],
|
'allowed': ['files'],
|
||||||
|
@@ -148,7 +148,6 @@ def main_posts_create():
|
|||||||
@blueprint.route('/p/<project_url>/blog/<url>')
|
@blueprint.route('/p/<project_url>/blog/<url>')
|
||||||
def project_blog(project_url, url=None):
|
def project_blog(project_url, url=None):
|
||||||
"""View project blog"""
|
"""View project blog"""
|
||||||
|
|
||||||
return posts_view(project_url=project_url, url=url)
|
return posts_view(project_url=project_url, url=url)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ def render_attachments(node, field_value):
|
|||||||
att = node_attachments[slug]
|
att = node_attachments[slug]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return u'[attachment "%s" not found]' % slug
|
return u'[attachment "%s" not found]' % slug
|
||||||
|
|
||||||
return render_attachment(att)
|
return render_attachment(att)
|
||||||
|
|
||||||
return shortcode_re.sub(replace, field_value)
|
return shortcode_re.sub(replace, field_value)
|
||||||
@@ -60,14 +59,14 @@ def render_attachment(attachment):
|
|||||||
log.error(u'Unable to render attachment from collection %s', collection)
|
log.error(u'Unable to render attachment from collection %s', collection)
|
||||||
return u'Unable to render attachment'
|
return u'Unable to render attachment'
|
||||||
|
|
||||||
return renderer(oid)
|
return renderer(attachment)
|
||||||
|
|
||||||
|
|
||||||
def render_attachment_file(oid):
|
def render_attachment_file(attachment):
|
||||||
"""Renders a file attachment."""
|
"""Renders a file attachment."""
|
||||||
|
|
||||||
api = system_util.pillar_api()
|
api = system_util.pillar_api()
|
||||||
sdk_file = pillarsdk.File.find(oid, api=api)
|
sdk_file = pillarsdk.File.find(attachment[u'oid'], api=api)
|
||||||
|
|
||||||
file_renderers = {
|
file_renderers = {
|
||||||
'image': render_attachment_file_image
|
'image': render_attachment_file_image
|
||||||
@@ -79,15 +78,15 @@ def render_attachment_file(oid):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return flask.render_template('nodes/attachments/file_generic.html', file=sdk_file)
|
return flask.render_template('nodes/attachments/file_generic.html', file=sdk_file)
|
||||||
|
|
||||||
return renderer(sdk_file)
|
return renderer(sdk_file, attachment)
|
||||||
|
|
||||||
|
|
||||||
def render_attachment_file_image(sdk_file):
|
def render_attachment_file_image(sdk_file, attachment):
|
||||||
"""Renders an image file."""
|
"""Renders an image file."""
|
||||||
|
|
||||||
variations = {var.size: var for var in sdk_file.variations}
|
variations = {var.size: var for var in sdk_file.variations}
|
||||||
return flask.render_template('nodes/attachments/file_image.html',
|
return flask.render_template('nodes/attachments/file_image.html',
|
||||||
file=sdk_file, vars=variations)
|
file=sdk_file, vars=variations, attachment=attachment)
|
||||||
|
|
||||||
|
|
||||||
def attachment_form_group_create(schema_prop):
|
def attachment_form_group_create(schema_prop):
|
||||||
@@ -104,6 +103,8 @@ def _attachment_build_single_field(schema_prop):
|
|||||||
fake_schema = {
|
fake_schema = {
|
||||||
'slug': schema_prop['propertyschema'],
|
'slug': schema_prop['propertyschema'],
|
||||||
'oid': schema_prop['valueschema']['schema']['oid'],
|
'oid': schema_prop['valueschema']['schema']['oid'],
|
||||||
|
'link': schema_prop['valueschema']['schema']['link'],
|
||||||
|
'link_custom': schema_prop['valueschema']['schema']['link_custom'],
|
||||||
}
|
}
|
||||||
file_select_form_group = build_file_select_form(fake_schema)
|
file_select_form_group = build_file_select_form(fake_schema)
|
||||||
return file_select_form_group
|
return file_select_form_group
|
||||||
@@ -125,7 +126,12 @@ def attachment_form_group_set_data(db_prop_value, schema_prop, field_list):
|
|||||||
# Even uglier hard-coded
|
# Even uglier hard-coded
|
||||||
subform.slug = slug
|
subform.slug = slug
|
||||||
subform.oid = att_data['oid']
|
subform.oid = att_data['oid']
|
||||||
|
subform.link = 'self'
|
||||||
|
subform.link_custom = None
|
||||||
|
if 'link' in att_data:
|
||||||
|
subform.link = att_data['link']
|
||||||
|
if 'link_custom' in att_data:
|
||||||
|
subform.link_custom = att_data['link_custom']
|
||||||
field_list.append_entry(subform)
|
field_list.append_entry(subform)
|
||||||
|
|
||||||
|
|
||||||
@@ -138,6 +144,8 @@ def attachment_form_parse_post_data(data):
|
|||||||
for allprops in data:
|
for allprops in data:
|
||||||
oid = allprops['oid']
|
oid = allprops['oid']
|
||||||
slug = allprops['slug']
|
slug = allprops['slug']
|
||||||
|
link = allprops['link']
|
||||||
|
link_custom = allprops['link_custom']
|
||||||
|
|
||||||
if not allprops['slug'] and not oid:
|
if not allprops['slug'] and not oid:
|
||||||
continue
|
continue
|
||||||
@@ -145,5 +153,9 @@ def attachment_form_parse_post_data(data):
|
|||||||
if slug in attachments:
|
if slug in attachments:
|
||||||
raise ValueError('Slug "%s" is used more than once' % slug)
|
raise ValueError('Slug "%s" is used more than once' % slug)
|
||||||
attachments[slug] = {'oid': oid}
|
attachments[slug] = {'oid': oid}
|
||||||
|
attachments[slug]['link'] = link
|
||||||
|
|
||||||
|
if link == 'custom':
|
||||||
|
attachments[slug]['link_custom'] = link_custom
|
||||||
|
|
||||||
return attachments
|
return attachments
|
||||||
|
@@ -73,7 +73,6 @@ def posts_view(project_id=None, project_url=None, url=None):
|
|||||||
|
|
||||||
post['properties']['content'] = pillar.web.nodes.attachments.render_attachments(
|
post['properties']['content'] = pillar.web.nodes.attachments.render_attachments(
|
||||||
post, post['properties']['content'])
|
post, post['properties']['content'])
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'nodes/custom/post/view{0}.html'.format(main_project_template),
|
'nodes/custom/post/view{0}.html'.format(main_project_template),
|
||||||
blog=blog,
|
blog=blog,
|
||||||
@@ -141,52 +140,6 @@ def posts_create(project_id):
|
|||||||
api=api)
|
api=api)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/posts/<post_id>/edit", methods=['GET', 'POST'])
|
|
||||||
@login_required
|
|
||||||
def posts_edit(post_id):
|
|
||||||
api = system_util.pillar_api()
|
|
||||||
|
|
||||||
try:
|
|
||||||
post = Node.find(post_id, {
|
|
||||||
'embedded': '{"user": 1}'}, api=api)
|
|
||||||
except ResourceNotFound:
|
|
||||||
return abort(404)
|
|
||||||
# Check if user is allowed to edit the post
|
|
||||||
if not post.has_method('PUT'):
|
|
||||||
return abort(403)
|
|
||||||
|
|
||||||
project = Project.find(post.project, api=api)
|
|
||||||
attach_project_pictures(project, api)
|
|
||||||
|
|
||||||
node_type = project.get_node_type(post.node_type)
|
|
||||||
form = get_node_form(node_type)
|
|
||||||
if form.validate_on_submit():
|
|
||||||
if process_node_form(form, node_id=post_id, node_type=node_type,
|
|
||||||
user=current_user.objectid):
|
|
||||||
# The the post is published, add it to the list
|
|
||||||
if form.status.data == 'published':
|
|
||||||
project_update_nodes_list(post, project_id=project._id, list_name='blog')
|
|
||||||
return redirect(url_for_node(node=post))
|
|
||||||
form.parent.data = post.parent
|
|
||||||
form.name.data = post.name
|
|
||||||
form.content.data = post.properties.content
|
|
||||||
form.status.data = post.properties.status
|
|
||||||
form.url.data = post.properties.url
|
|
||||||
if post.picture:
|
|
||||||
form.picture.data = post.picture
|
|
||||||
# Embed picture file
|
|
||||||
post.picture = get_file(post.picture, api=api)
|
|
||||||
if post.properties.picture_square:
|
|
||||||
form.picture_square.data = post.properties.picture_square
|
|
||||||
return render_template('nodes/custom/post/edit.html',
|
|
||||||
node_type=node_type,
|
|
||||||
post=post,
|
|
||||||
form=form,
|
|
||||||
project=project,
|
|
||||||
api=api)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setup_app(app):
|
def setup_app(app):
|
||||||
global posts_view
|
global posts_view
|
||||||
|
|
||||||
|
@@ -28,9 +28,9 @@ from pillar.web.nodes.forms import process_node_form
|
|||||||
from pillar.web.nodes.custom.storage import StorageNode
|
from pillar.web.nodes.custom.storage import StorageNode
|
||||||
from pillar.web.projects.routes import project_update_nodes_list
|
from pillar.web.projects.routes import project_update_nodes_list
|
||||||
from pillar.web.utils import get_file
|
from pillar.web.utils import get_file
|
||||||
|
from pillar.web.utils import attach_project_pictures
|
||||||
from pillar.web.utils.jstree import jstree_build_children
|
from pillar.web.utils.jstree import jstree_build_children
|
||||||
from pillar.web.utils.jstree import jstree_build_from_node
|
from pillar.web.utils.jstree import jstree_build_from_node
|
||||||
from pillar.web.utils.forms import ProceduralFileSelectForm
|
|
||||||
from pillar.web.utils.forms import build_file_select_form
|
from pillar.web.utils.forms import build_file_select_form
|
||||||
from pillar.web import system_util
|
from pillar.web import system_util
|
||||||
|
|
||||||
@@ -120,8 +120,9 @@ def view(node_id):
|
|||||||
|
|
||||||
node_type_name = node.node_type
|
node_type_name = node.node_type
|
||||||
|
|
||||||
if node_type_name == 'post':
|
if node_type_name == 'post' and not request.args.get('embed'):
|
||||||
# Posts shouldn't be shown at this route, redirect to the correct one.
|
# Posts shouldn't be shown at this route (unless viewed embedded, tipically
|
||||||
|
# after an edit. Redirect to the correct one.
|
||||||
return redirect(url_for_node(node=node))
|
return redirect(url_for_node(node=node))
|
||||||
|
|
||||||
# Set the default name of the template path based on the node name
|
# Set the default name of the template path based on the node name
|
||||||
@@ -353,12 +354,14 @@ def edit(node_id):
|
|||||||
if not form[prop_name].choices:
|
if not form[prop_name].choices:
|
||||||
form[prop_name].choices = [(d, d) for d in db_prop_value]
|
form[prop_name].choices = [(d, d) for d in db_prop_value]
|
||||||
# Choices should be a tuple with value and name
|
# Choices should be a tuple with value and name
|
||||||
|
|
||||||
if not set_data:
|
if not set_data:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Assign data to the field
|
# Assign data to the field
|
||||||
if prop_name == 'attachments':
|
if prop_name == 'attachments':
|
||||||
|
# If attachments is an empty list, do not append data
|
||||||
|
if not db_prop_value:
|
||||||
|
continue
|
||||||
attachments.attachment_form_group_set_data(db_prop_value, schema_prop,
|
attachments.attachment_form_group_set_data(db_prop_value, schema_prop,
|
||||||
form[prop_name])
|
form[prop_name])
|
||||||
elif prop_name == 'files':
|
elif prop_name == 'files':
|
||||||
@@ -391,7 +394,6 @@ def edit(node_id):
|
|||||||
dyn_schema = node_type['dyn_schema'].to_dict()
|
dyn_schema = node_type['dyn_schema'].to_dict()
|
||||||
form_schema = node_type['form_schema'].to_dict()
|
form_schema = node_type['form_schema'].to_dict()
|
||||||
error = ""
|
error = ""
|
||||||
|
|
||||||
node_properties = node.properties.to_dict()
|
node_properties = node.properties.to_dict()
|
||||||
|
|
||||||
ensure_lists_exist_as_empty(node.to_dict(), node_type)
|
ensure_lists_exist_as_empty(node.to_dict(), node_type)
|
||||||
@@ -405,8 +407,6 @@ def edit(node_id):
|
|||||||
project_update_nodes_list(node, project_id=project._id, list_name='blog')
|
project_update_nodes_list(node, project_id=project._id, list_name='blog')
|
||||||
else:
|
else:
|
||||||
project_update_nodes_list(node, project_id=project._id)
|
project_update_nodes_list(node, project_id=project._id)
|
||||||
# Emergency hardcore cache flush
|
|
||||||
# cache.clear()
|
|
||||||
return redirect(url_for('nodes.view', node_id=node_id, embed=1,
|
return redirect(url_for('nodes.view', node_id=node_id, embed=1,
|
||||||
_external=True,
|
_external=True,
|
||||||
_scheme=current_app.config['SCHEME']))
|
_scheme=current_app.config['SCHEME']))
|
||||||
@@ -416,7 +416,6 @@ def edit(node_id):
|
|||||||
else:
|
else:
|
||||||
if form.errors:
|
if form.errors:
|
||||||
log.debug('Form errors: %s', form.errors)
|
log.debug('Form errors: %s', form.errors)
|
||||||
|
|
||||||
# Populate Form
|
# Populate Form
|
||||||
form.name.data = node.name
|
form.name.data = node.name
|
||||||
form.description.data = node.description
|
form.description.data = node.description
|
||||||
@@ -424,7 +423,6 @@ def edit(node_id):
|
|||||||
form.picture.data = node.picture
|
form.picture.data = node.picture
|
||||||
if node.parent:
|
if node.parent:
|
||||||
form.parent.data = node.parent
|
form.parent.data = node.parent
|
||||||
|
|
||||||
set_properties(dyn_schema, form_schema, node_properties, form, set_data=True)
|
set_properties(dyn_schema, form_schema, node_properties, form, set_data=True)
|
||||||
|
|
||||||
# Get previews
|
# Get previews
|
||||||
@@ -443,9 +441,10 @@ def edit(node_id):
|
|||||||
if request.args.get('embed') == '1':
|
if request.args.get('embed') == '1':
|
||||||
# Define the prefix for the embedded template
|
# Define the prefix for the embedded template
|
||||||
embed_string = '_embed'
|
embed_string = '_embed'
|
||||||
|
else:
|
||||||
|
attach_project_pictures(project, api)
|
||||||
|
|
||||||
template = '{0}/edit{1}.html'.format(node_type['name'], embed_string)
|
template = '{0}/edit{1}.html'.format(node_type['name'], embed_string)
|
||||||
|
|
||||||
# We should more simply check if the template file actually exsists on
|
# We should more simply check if the template file actually exsists on
|
||||||
# the filesystem level
|
# the filesystem level
|
||||||
try:
|
try:
|
||||||
@@ -459,6 +458,7 @@ def edit(node_id):
|
|||||||
api=api)
|
api=api)
|
||||||
except TemplateNotFound:
|
except TemplateNotFound:
|
||||||
template = 'nodes/edit{1}.html'.format(node_type['name'], embed_string)
|
template = 'nodes/edit{1}.html'.format(node_type['name'], embed_string)
|
||||||
|
is_embedded_edit = True if embed_string else False
|
||||||
return render_template(
|
return render_template(
|
||||||
template,
|
template,
|
||||||
node=node,
|
node=node,
|
||||||
@@ -466,7 +466,10 @@ def edit(node_id):
|
|||||||
form=form,
|
form=form,
|
||||||
errors=form.errors,
|
errors=form.errors,
|
||||||
error=error,
|
error=error,
|
||||||
api=api)
|
api=api,
|
||||||
|
project=project,
|
||||||
|
is_embedded_edit=is_embedded_edit,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def ensure_lists_exist_as_empty(node_doc, node_type):
|
def ensure_lists_exist_as_empty(node_doc, node_type):
|
||||||
|
@@ -108,12 +108,6 @@ class FileSelectField(StringField):
|
|||||||
self.widget = CustomFileSelectWidget(file_format=file_format)
|
self.widget = CustomFileSelectWidget(file_format=file_format)
|
||||||
|
|
||||||
|
|
||||||
class ProceduralFileSelectForm(Form):
|
|
||||||
file = FileSelectField('file')
|
|
||||||
size = StringField()
|
|
||||||
slug = StringField()
|
|
||||||
|
|
||||||
|
|
||||||
def build_file_select_form(schema):
|
def build_file_select_form(schema):
|
||||||
class FileSelectForm(Form):
|
class FileSelectForm(Form):
|
||||||
pass
|
pass
|
||||||
|
@@ -427,8 +427,11 @@ html(lang="en")
|
|||||||
$('[data-toggle="popover"]').popover();
|
$('[data-toggle="popover"]').popover();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
| {% block footer_scripts_pre %}{% endblock %}
|
||||||
| {% block footer_scripts %}{% endblock %}
|
| {% block footer_scripts %}{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
script.
|
script.
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
@@ -1 +1,11 @@
|
|||||||
img(src="{{ vars['l'].link }}",alt="{{ file.filename }}")
|
| {% if 'link' in attachment and attachment['link'] != 'none' %}
|
||||||
|
| {% if attachment['link'] == 'self' %}
|
||||||
|
a(href="{{ vars['l'].link }}")
|
||||||
|
img(src="{{ vars['l'].link }}", alt="{{ file.filename }}")
|
||||||
|
| {% elif attachment['link'] == 'custom' %}
|
||||||
|
a(href="{{ attachment['link_custom'] }}")
|
||||||
|
img(src="{{ vars['l'].link }}", alt="{{ file.filename }}")
|
||||||
|
| {% endif %}
|
||||||
|
| {% else %}
|
||||||
|
img(src="{{ vars['l'].link }}", alt="{{ file.filename }}")
|
||||||
|
| {% endif %}
|
||||||
|
@@ -77,7 +77,6 @@
|
|||||||
| {% endif %}
|
| {% endif %}
|
||||||
|
|
||||||
| {% block comment_scripts %}
|
| {% block comment_scripts %}
|
||||||
script(src="{{ url_for('static_pillar', filename='assets/js/markdown.min.js', v=171020161) }}")
|
|
||||||
script.
|
script.
|
||||||
|
|
||||||
// Markdown initialization
|
// Markdown initialization
|
||||||
|
@@ -1,168 +0,0 @@
|
|||||||
| {% extends 'layout.html' %}
|
|
||||||
|
|
||||||
| {% set title = 'blog' %}
|
|
||||||
|
|
||||||
| {% block page_title %}New {{ node_type.name }}{% endblock %}
|
|
||||||
|
|
||||||
| {% block body %}
|
|
||||||
|
|
||||||
.container
|
|
||||||
form(
|
|
||||||
method='POST',
|
|
||||||
action="{{url_for('nodes.posts_edit', post_id=post._id)}}")
|
|
||||||
|
|
||||||
#blog_container.post-create
|
|
||||||
|
|
||||||
| {% with errors = errors %}
|
|
||||||
| {% if errors %}
|
|
||||||
| {% for field in errors %}
|
|
||||||
.alert.alert-danger(role='alert')
|
|
||||||
strong {{field}}
|
|
||||||
| {% for message in errors[field] %}
|
|
||||||
| {{message}}|
|
|
||||||
| {% endfor %}
|
|
||||||
| {% endfor %}
|
|
||||||
| {% endif %}
|
|
||||||
| {% endwith %}
|
|
||||||
|
|
||||||
#blog_index-sidebar
|
|
||||||
| {% if project._id != config.MAIN_PROJECT_ID %}
|
|
||||||
.blog_project-card
|
|
||||||
a.item-header(
|
|
||||||
href="{{ url_for('projects.view', project_url=project.url) }}")
|
|
||||||
|
|
||||||
.overlay
|
|
||||||
| {% if project.picture_header %}
|
|
||||||
img.background(src="{{ project.picture_header.thumbnail('m', api=api) }}")
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
a.card-thumbnail(
|
|
||||||
href="{{ url_for('projects.view', project_url=project.url) }}")
|
|
||||||
| {% if project.picture_square %}
|
|
||||||
img.thumb(src="{{ project.picture_square.thumbnail('m', api=api) }}")
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
.item-info
|
|
||||||
|
|
||||||
a.item-title(
|
|
||||||
href="{{ url_for('projects.view', project_url=project.url) }}")
|
|
||||||
| {{ project.name }}
|
|
||||||
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
.blog_project-sidebar
|
|
||||||
#blog_post-edit-form
|
|
||||||
| {% for field in form %}
|
|
||||||
| {% if field.name in ['picture', 'status'] %}
|
|
||||||
|
|
||||||
.form-group(class="{{field.name}}{% if field.errors %} error{% endif %}")
|
|
||||||
| {{ field.label }}
|
|
||||||
| {{ field(class='form-control') }}
|
|
||||||
|
|
||||||
| {% if field.errors %}
|
|
||||||
ul.error
|
|
||||||
| {% for error in field.errors %}
|
|
||||||
li {{ error }}
|
|
||||||
| {% endfor %}
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
| {% endif %}
|
|
||||||
| {% endfor %}
|
|
||||||
|
|
||||||
button.btn.btn-default.button-create(type='submit')
|
|
||||||
i.pi-check
|
|
||||||
| Update {{ node_type.name }}
|
|
||||||
|
|
||||||
a.btn.btn-default.button-back(href="{{ url_for_node(node=post) }}")
|
|
||||||
i.pi-angle-left
|
|
||||||
| Back to Post
|
|
||||||
|
|
||||||
a.btn.btn-default.button-back(href="{{ url_for('projects.view', project_url=project.url) }}blog")
|
|
||||||
| Go to Blog
|
|
||||||
|
|
||||||
#blog_post-edit-container
|
|
||||||
#blog_post-edit-title
|
|
||||||
| Edit {{ node_type.name }}
|
|
||||||
|
|
||||||
#blog_post-edit-form
|
|
||||||
| {% for field in form %}
|
|
||||||
| {% if field.name == 'csrf_token' %}
|
|
||||||
| {{ field }}
|
|
||||||
| {% else %}
|
|
||||||
| {% if field.type == 'HiddenField' %}
|
|
||||||
| {{ field }}
|
|
||||||
| {% else %}
|
|
||||||
|
|
||||||
| {% if field.name not in ['description', 'picture', 'category', 'status'] %}
|
|
||||||
|
|
||||||
.form-group(class="{{field.name}}{% if field.errors %} error{% endif %}")
|
|
||||||
| {{ field.label }}
|
|
||||||
| {{ field(class='form-control') }}
|
|
||||||
|
|
||||||
| {% if field.errors %}
|
|
||||||
ul.error
|
|
||||||
| {% for error in field.errors %}
|
|
||||||
li {{ error }}
|
|
||||||
| {% endfor %}
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
| {% endif %}
|
|
||||||
| {% endif %}
|
|
||||||
| {% endif %}
|
|
||||||
| {% endfor %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| {% endblock %}
|
|
||||||
|
|
||||||
| {% block footer_scripts %}
|
|
||||||
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.ui.widget.min.js') }}")
|
|
||||||
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.iframe-transport.min.js') }}")
|
|
||||||
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.fileupload.min.js') }}")
|
|
||||||
script(src="{{ url_for('static_pillar', filename='assets/js/file_upload.min.js') }}")
|
|
||||||
|
|
||||||
script(type="text/javascript").
|
|
||||||
var convert = new Markdown.getSanitizingConverter().makeHtml;
|
|
||||||
ProjectUtils.setProjectAttributes({projectId: "{{project._id}}"});
|
|
||||||
|
|
||||||
/* Build the markdown preview when typing in textarea */
|
|
||||||
$(function() {
|
|
||||||
|
|
||||||
var $textarea = $('.form-group.content textarea'),
|
|
||||||
$loader = $('<div class="md-preview-loading"><i class="pi-spin spin"></i></div>').insertAfter($textarea),
|
|
||||||
$preview = $('<div class="node-edit-form-md-preview" />').insertAfter($loader);
|
|
||||||
|
|
||||||
$loader.hide();
|
|
||||||
|
|
||||||
// Delay function to not start converting heavy posts immediately
|
|
||||||
var delay = (function(){
|
|
||||||
var timer = 0;
|
|
||||||
return function(callback, ms){
|
|
||||||
clearTimeout (timer);
|
|
||||||
timer = setTimeout(callback, ms);
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
$textarea.keyup(function() {
|
|
||||||
/* If there's an iframe (YouTube embed), delay markdown convert 1.5s */
|
|
||||||
if (/iframe/i.test($textarea.val())) {
|
|
||||||
$loader.show();
|
|
||||||
|
|
||||||
delay(function(){
|
|
||||||
// Convert markdown
|
|
||||||
$preview.html(convert($textarea.val()));
|
|
||||||
$loader.hide();
|
|
||||||
}, 1500 );
|
|
||||||
} else {
|
|
||||||
// Convert markdown
|
|
||||||
$preview.html(convert($textarea.val()));
|
|
||||||
};
|
|
||||||
}).trigger('keyup');
|
|
||||||
});
|
|
||||||
|
|
||||||
| {% endblock %}
|
|
||||||
|
|
||||||
| {% block footer_navigation %}
|
|
||||||
| {% endblock %}
|
|
||||||
| {% block footer %}
|
|
||||||
| {% endblock %}
|
|
@@ -1,55 +1,15 @@
|
|||||||
| {% extends 'projects/view.html' %}
|
| {% extends 'projects/view.html' %}
|
||||||
| {% set title = 'blog' %}
|
| {% set title = 'blog' %}
|
||||||
|
|
||||||
| {% block page_title %}{{node.name}} - Blog{% endblock%}
|
| {% block page_title %}{{node.name}} - Blog{% endblock%}
|
||||||
|
|
||||||
| {% block css %}
|
| {% block css %}
|
||||||
link(href="{{ url_for('static_pillar', filename='assets/css/font-pillar.css', v=6220171) }}", rel="stylesheet")
|
| {{ super() }}
|
||||||
link(href="{{ url_for('static_pillar', filename='assets/css/base.css', v=6220171) }}", rel="stylesheet")
|
|
||||||
link(href="{{ url_for('static_pillar', filename='assets/css/project-main.css', v=6220171) }}", rel="stylesheet")
|
|
||||||
link(href="{{ url_for('static_pillar', filename='assets/css/blog.css', v=6220171) }}", rel="stylesheet")
|
link(href="{{ url_for('static_pillar', filename='assets/css/blog.css', v=6220171) }}", rel="stylesheet")
|
||||||
| {% endblock %}
|
| {% endblock %}
|
||||||
|
|
||||||
| {% block project_context %}
|
| {% block project_context %}
|
||||||
#blog_container(class="{% if project._id == config.MAIN_PROJECT_ID %}cloud-blog{% endif %}")
|
| {% include 'nodes/custom/post/view_embed.html' %}
|
||||||
|
|
||||||
#blog_post-container
|
|
||||||
| {% if project._id == config.MAIN_PROJECT_ID %}
|
|
||||||
a.btn.btn-default.button-back(href="{{ url_for('projects.view', project_url=project.url) }}blog")
|
|
||||||
| Back to Blog
|
|
||||||
|
|
||||||
| {% if node.has_method('PUT') %}
|
|
||||||
a.btn.btn-default.button-edit(href="{{url_for('nodes.posts_edit', post_id=node._id)}}")
|
|
||||||
i.pi-edit
|
|
||||||
| Edit Post
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
.clearfix
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
| {% if node.picture %}
|
|
||||||
.blog_index-header
|
|
||||||
img(src="{{ node.picture.thumbnail('l', api=api) }}")
|
|
||||||
| {% endif %}
|
|
||||||
.blog_index-item
|
|
||||||
|
|
||||||
.item-title
|
|
||||||
| {{node.name}}
|
|
||||||
|
|
||||||
.item-info.
|
|
||||||
<span title="{{node._created}}">{{node._created | pretty_date }}</span>
|
|
||||||
{% if node._created != node._updated %}
|
|
||||||
<span title="{{node._updated}}">(updated {{node._updated | pretty_date }})</span>
|
|
||||||
{% endif %}
|
|
||||||
{% if node.properties.category %}| {{node.properties.category}}{% endif %}
|
|
||||||
| by {{node.user.full_name}}
|
|
||||||
|
|
||||||
.item-content
|
|
||||||
| {{ node.properties.content }}
|
|
||||||
|
|
||||||
|
|
||||||
#comments-embed
|
|
||||||
#comments-list-items-loading
|
|
||||||
i.pi-spin
|
|
||||||
| {% endblock %}
|
| {% endblock %}
|
||||||
|
|
||||||
| {% block project_tree %}
|
| {% block project_tree %}
|
||||||
@@ -57,18 +17,18 @@ link(href="{{ url_for('static_pillar', filename='assets/css/blog.css', v=6220171
|
|||||||
ul.jstree-container-ul.jstree-children
|
ul.jstree-container-ul.jstree-children
|
||||||
li.jstree-node(data-node-type="page")
|
li.jstree-node(data-node-type="page")
|
||||||
a.jstree-anchor(
|
a.jstree-anchor(
|
||||||
href="{{ url_for('projects.view', project_url=project.url) }}")
|
href="{{ url_for('projects.view', project_url=project.url) }}")
|
||||||
| Browse Project
|
| Browse Project
|
||||||
|
|
||||||
li.jstree-node.jstree-leaf(data-node-type="page")
|
li.jstree-node.jstree-leaf(data-node-type="page")
|
||||||
a.jstree-anchor(
|
a.jstree-anchor(
|
||||||
href="{{ url_for('main.project_blog', project_url=project.url) }}") Blog
|
href="{{ url_for('main.project_blog', project_url=project.url) }}") Blog
|
||||||
|
|
||||||
| {% for post in posts %}
|
| {% for post in posts %}
|
||||||
li.jstree-node
|
li.jstree-node
|
||||||
a.jstree-anchor(
|
a.jstree-anchor(
|
||||||
href="{{ url_for_node(node=post) }}",
|
href="{{ url_for_node(node=post) }}",
|
||||||
class="{% if post._id == node._id %}jstree-clicked{% endif %}")
|
class="{% if post._id == node._id %}jstree-clicked{% endif %}")
|
||||||
.tree-item-thumbnail
|
.tree-item-thumbnail
|
||||||
| {% if post.picture %}
|
| {% if post.picture %}
|
||||||
img(src="{{ post.picture.thumbnail('s', api=api) }}")
|
img(src="{{ post.picture.thumbnail('s', api=api) }}")
|
||||||
@@ -83,32 +43,25 @@ link(href="{{ url_for('static_pillar', filename='assets/css/blog.css', v=6220171
|
|||||||
|
|
||||||
| {% block footer_scripts %}
|
| {% block footer_scripts %}
|
||||||
|
|
||||||
include ../_scripts
|
|
||||||
script.
|
script.
|
||||||
{% if project.has_method('PUT') %}
|
ProjectUtils.setProjectAttributes({projectId: "{{project._id}}", isProject: false, nodeId: '{{node._id}}'});
|
||||||
/* Edit Button */
|
|
||||||
$('#item_edit').click(function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
$('.button-edit-icon').addClass('pi-spin spin').removeClass('pi-edit');
|
|
||||||
window.location.replace("{{url_for('nodes.posts_edit', post_id=node._id)}}");
|
|
||||||
});
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
/* Expand images when their link points to a jpg/png/gif */
|
/* Expand images when their link points to a jpg/png/gif */
|
||||||
/* TODO: De-duplicate code from blog index */
|
/* TODO: De-duplicate code from blog index */
|
||||||
$('.blog_index-item .item-content a img').on('click', function(e){
|
var page_overlay = document.getElementById('page-overlay');
|
||||||
|
$('.blog_index-item .item-content a img').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var href = $(this).parent().attr('href');
|
var href = $(this).parent().attr('href').split("?")[0];
|
||||||
var src = $(this).attr('src');
|
var src = $(this).attr('src');
|
||||||
|
|
||||||
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
|
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
|
||||||
var page_overlay = document.getElementById('page-overlay');
|
|
||||||
$(page_overlay)
|
$(page_overlay)
|
||||||
.addClass('active')
|
.addClass('active')
|
||||||
.html('<img src="' + src + '"/>');
|
.html('<img src="' + src + '"/>');
|
||||||
} else {
|
} else {
|
||||||
window.location.href = href;
|
window.location.href = href;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
| {% endblock %}
|
|
||||||
|
| {% endblock footer_scripts %}
|
||||||
|
@@ -1,111 +1,43 @@
|
|||||||
| {% set title = 'blog' %}
|
|
||||||
|
|
||||||
| {% block body %}
|
#blog_container(class="{% if project and project._id == config.MAIN_PROJECT_ID %}cloud-blog{% endif %}")
|
||||||
|
|
||||||
.container
|
#blog_post-container
|
||||||
#blog_container(class="{% if project._id == config.MAIN_PROJECT_ID %}cloud-blog{% endif %}")
|
| {% if project and project._id == config.MAIN_PROJECT_ID %}
|
||||||
|
a.btn.btn-default.button-back(href="{{ url_for('projects.view', project_url=project.url) }}blog")
|
||||||
|
| Back to Blog
|
||||||
|
|
||||||
#blog_post-container
|
| {% if node.has_method('PUT') %}
|
||||||
| {% if project._id == config.MAIN_PROJECT_ID %}
|
a.btn.btn-default.button-edit(href="{{url_for('nodes.edit', node_id=node._id)}}")
|
||||||
a.btn.btn-default.button-back(href="{{ url_for('projects.view', project_url=project.url) }}blog")
|
i.pi-edit
|
||||||
| Back to Blog
|
| Edit Post
|
||||||
|
|
||||||
| {% if node.has_method('PUT') %}
|
|
||||||
a.btn.btn-default.button-edit(href="{{url_for('nodes.posts_edit', post_id=node._id)}}")
|
|
||||||
i.pi-edit
|
|
||||||
| Edit Post
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
.clearfix
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
| {% if node.picture %}
|
|
||||||
.blog_index-header
|
|
||||||
img(src="{{ node.picture.thumbnail('l', api=api) }}")
|
|
||||||
| {% endif %}
|
|
||||||
.blog_index-item
|
|
||||||
|
|
||||||
.item-title
|
|
||||||
| {{node.name}}
|
|
||||||
|
|
||||||
.item-info.
|
|
||||||
<span title="{{node._created}}">{{node._created | pretty_date }}</span>
|
|
||||||
{% if node._created != node._updated %}
|
|
||||||
<span title="{{node._updated}}">(updated {{node._updated | pretty_date }})</span>
|
|
||||||
{% endif %}
|
|
||||||
{% if node.properties.category %}| {{node.properties.category}}{% endif %}
|
|
||||||
| by {{node.user.full_name}}
|
|
||||||
|
|
||||||
.item-content
|
|
||||||
| {{ node.properties.content }}
|
|
||||||
|
|
||||||
|
|
||||||
#comments-embed
|
|
||||||
#comments-list-items-loading
|
|
||||||
i.pi-spin
|
|
||||||
|
|
||||||
| {% if project._id != config.MAIN_PROJECT_ID %}
|
|
||||||
#blog_index-sidebar
|
|
||||||
.blog_project-card
|
|
||||||
a.item-header(
|
|
||||||
href="{{ url_for('projects.view', project_url=project.url) }}")
|
|
||||||
|
|
||||||
.overlay
|
|
||||||
| {% if project.picture_header %}
|
|
||||||
img.background(src="{{ project.picture_header.thumbnail('m', api=api) }}")
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
a.card-thumbnail(
|
|
||||||
href="{{ url_for('projects.view', project_url=project.url) }}")
|
|
||||||
| {% if project.picture_square %}
|
|
||||||
img.thumb(src="{{ project.picture_square.thumbnail('m', api=api) }}")
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
.item-info
|
|
||||||
|
|
||||||
a.item-title(
|
|
||||||
href="{{ url_for('projects.view', project_url=project.url) }}")
|
|
||||||
| {{ project.name }}
|
|
||||||
|
|
||||||
| {% if project.summary %}
|
|
||||||
p.item-description
|
|
||||||
| {{project.summary|safe}}
|
|
||||||
| {% endif %}
|
|
||||||
.blog_project-sidebar
|
|
||||||
| {% if node.has_method('PUT') %}
|
|
||||||
a.btn.btn-default.button-create(href="{{url_for('nodes.posts_edit', post_id=node._id)}}")
|
|
||||||
| Edit Post
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
a.btn.btn-default.button-back(href="{{ url_for('projects.view', project_url=project.url) }}blog")
|
|
||||||
| Back to Blog
|
|
||||||
| {% endif %}
|
| {% endif %}
|
||||||
|
|
||||||
|
.clearfix
|
||||||
|
| {% endif %}
|
||||||
|
|
||||||
| {% endblock %}
|
| {% if node.picture %}
|
||||||
|
.blog_index-header
|
||||||
|
img(src="{{ node.picture.thumbnail('l', api=api) }}")
|
||||||
|
| {% endif %}
|
||||||
|
.blog_index-item
|
||||||
|
|
||||||
|
.item-title
|
||||||
|
| {{node.name}}
|
||||||
|
|
||||||
|
.item-info.
|
||||||
|
<span title="{{node._created}}">{{node._created | pretty_date }}</span>
|
||||||
|
{% if node._created != node._updated %}
|
||||||
|
<span title="{{node._updated}}">(updated {{node._updated | pretty_date }})</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if node.properties.category %}| {{node.properties.category}}{% endif %}
|
||||||
|
| by {{node.user.full_name}}
|
||||||
|
|
||||||
|
.item-content
|
||||||
|
| {{ node.properties.content }}
|
||||||
|
|
||||||
|
|
||||||
| {% block footer_scripts %}
|
#comments-embed
|
||||||
|
#comments-list-items-loading
|
||||||
|
i.pi-spin
|
||||||
|
|
||||||
include ../_scripts
|
include ../_scripts
|
||||||
script.
|
|
||||||
hopToTop(); // Display jump to top button
|
|
||||||
|
|
||||||
/* Expand images when their link points to a jpg/png/gif */
|
|
||||||
/* TODO: De-duplicate code from view post */
|
|
||||||
var page_overlay = document.getElementById('page-overlay');
|
|
||||||
$('.blog_index-item .item-content a img').on('click', function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var href = $(this).parent().attr('href');
|
|
||||||
var src = $(this).attr('src');
|
|
||||||
|
|
||||||
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
|
|
||||||
$(page_overlay)
|
|
||||||
.addClass('active')
|
|
||||||
.html('<img src="' + src + '"/>');
|
|
||||||
} else {
|
|
||||||
window.location.href = href;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
| {% endblock %}
|
|
||||||
|
@@ -1,4 +1,37 @@
|
|||||||
| {% extends 'layout.html' %}
|
| {% extends 'layout.html' %}
|
||||||
| {% block page_title %}{{node.name}} - Blog{% endblock%}
|
| {% block page_title %}{{node.name}} - Blog{% endblock%}
|
||||||
|
|
||||||
include view_embed
|
| {% set title = 'blog' %}
|
||||||
|
|
||||||
|
| {% block body %}
|
||||||
|
|
||||||
|
.container
|
||||||
|
| {% include 'nodes/custom/post/view_embed.html' %}
|
||||||
|
|
||||||
|
| {% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
| {% block footer_scripts %}
|
||||||
|
|
||||||
|
script.
|
||||||
|
hopToTop(); // Display jump to top button
|
||||||
|
|
||||||
|
/* Expand images when their link points to a jpg/png/gif */
|
||||||
|
/* TODO: De-duplicate code from view post */
|
||||||
|
var page_overlay = document.getElementById('page-overlay');
|
||||||
|
$('.blog_index-item .item-content a img').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var href = $(this).parent().attr('href').split("?")[0];
|
||||||
|
var src = $(this).attr('src');
|
||||||
|
|
||||||
|
|
||||||
|
if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
|
||||||
|
$(page_overlay)
|
||||||
|
.addClass('active')
|
||||||
|
.html('<img src="' + src + '"/>');
|
||||||
|
} else {
|
||||||
|
window.location.href = href;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
| {% endblock %}
|
||||||
|
@@ -1,11 +1,17 @@
|
|||||||
| {% extends 'layout.html' %}
|
| {% extends 'projects/view.html' %}
|
||||||
|
|
||||||
| {% block body %}
|
| {% block body %}
|
||||||
div.container
|
#project-container.container
|
||||||
div.page-content
|
div.page-content
|
||||||
| {% include 'nodes/edit_embed.html' %}
|
| {% include 'nodes/edit_embed.html' %}
|
||||||
| {% endblock %}
|
| {% endblock body %}
|
||||||
|
|
||||||
| {% block footer_scripts %}
|
| {% block footer_scripts %}
|
||||||
| {% include '_macros/_file_uploader_javascript.html' %}
|
| {{ super() }}
|
||||||
| {% endblock %}
|
script.
|
||||||
|
$(function () {
|
||||||
|
updateUi('', 'edit');
|
||||||
|
});
|
||||||
|
|
||||||
|
| {% endblock footer_scripts %}
|
||||||
|
|
||||||
|
@@ -148,10 +148,19 @@ script(type="text/javascript").
|
|||||||
|
|
||||||
|
|
||||||
/* Submit changes */
|
/* Submit changes */
|
||||||
$("#node-edit-form").unbind( "submit" )
|
$("#node-edit-form").unbind("submit").submit(function(e) {
|
||||||
.submit(function(e) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Assets always need a file
|
||||||
|
var $file = $('.form-group.file #file');
|
||||||
|
if ($file.val() == '') {
|
||||||
|
$file.addClass('error');
|
||||||
|
statusBarSet('error', 'No File Selected', 'pi-warning', 5000);
|
||||||
|
return jQuery.Deferred().reject("nofile");
|
||||||
|
}
|
||||||
|
|
||||||
|
$file.removeClass('error');
|
||||||
|
|
||||||
/* Let us know started saving */
|
/* Let us know started saving */
|
||||||
$("li.button-save").addClass('saving');
|
$("li.button-save").addClass('saving');
|
||||||
$("li.button-save a#item_save").html('<i class="pi-spin spin"></i> Saving...');
|
$("li.button-save a#item_save").html('<i class="pi-spin spin"></i> Saving...');
|
||||||
@@ -181,7 +190,10 @@ script(type="text/javascript").
|
|||||||
})
|
})
|
||||||
.done(function(dataHtml){
|
.done(function(dataHtml){
|
||||||
/* Success! */
|
/* Success! */
|
||||||
|
// Disable beforeunolad when submitting a form
|
||||||
|
$(window).off('beforeunload');
|
||||||
|
|
||||||
|
{% if is_embedded_edit %}
|
||||||
/* Load content*/
|
/* Load content*/
|
||||||
$('#project_context').html(dataHtml);
|
$('#project_context').html(dataHtml);
|
||||||
statusBarSet('success', 'Saved Successfully', 'pi-check');
|
statusBarSet('success', 'Saved Successfully', 'pi-check');
|
||||||
@@ -194,24 +206,18 @@ script(type="text/javascript").
|
|||||||
//- $('#project_tree').jstree("refresh");
|
//- $('#project_tree').jstree("refresh");
|
||||||
|
|
||||||
updateUi(ProjectUtils.nodeId(), 'view');
|
updateUi(ProjectUtils.nodeId(), 'view');
|
||||||
|
{% else %}
|
||||||
|
// This code runs only if we are in direct node editing mode, and since we do a redirect,
|
||||||
|
// nothing of what follows is executed, because of the redirect.
|
||||||
|
location.href = "{{ url_for('nodes.view', node_id=node._id)}}";
|
||||||
|
{% endif %}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#item_save, .item-save').click(function(e){
|
$('#item_save, .item-save').click(function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
$("#node-edit-form").submit();
|
||||||
// Assets always need a file
|
|
||||||
if ($('.form-group.file #file').val() == ''){
|
|
||||||
$('.form-group.file').addClass('error');
|
|
||||||
statusBarSet('error', 'No File Selected', 'pi-warning', 5000);
|
|
||||||
} else {
|
|
||||||
$('.form-group.file').removeClass('error');
|
|
||||||
$("#node-edit-form").submit();
|
|
||||||
|
|
||||||
// Disable beforeunolad when submitting a form
|
|
||||||
$(window).off('beforeunload');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#item_cancel, .item-cancel').click(function(e){
|
$('#item_cancel, .item-cancel').click(function(e){
|
||||||
|
@@ -137,7 +137,7 @@ link(href="{{ url_for('static_pillar', filename='assets/css/project-main.css', v
|
|||||||
|
|
||||||
| {% block project_tree %}
|
| {% block project_tree %}
|
||||||
#project_tree
|
#project_tree
|
||||||
| {% endblock %}
|
| {% endblock project_tree %}
|
||||||
| {% endif %}
|
| {% endif %}
|
||||||
|
|
||||||
.project_split(title="Toggle Navigation [T]")
|
.project_split(title="Toggle Navigation [T]")
|
||||||
@@ -246,7 +246,7 @@ link(href="{{ url_for('static_pillar', filename='assets/css/project-main.css', v
|
|||||||
| {% if show_project %}
|
| {% if show_project %}
|
||||||
| {% include "projects/view_embed.html" %}
|
| {% include "projects/view_embed.html" %}
|
||||||
| {% endif %}
|
| {% endif %}
|
||||||
| {% endblock %}
|
| {% endblock project_context %}
|
||||||
|
|
||||||
#overlay-mode-move-container
|
#overlay-mode-move-container
|
||||||
.overlay-container
|
.overlay-container
|
||||||
@@ -265,8 +265,8 @@ link(href="{{ url_for('static_pillar', filename='assets/css/project-main.css', v
|
|||||||
| {% block footer_navigation %}{% endblock %}
|
| {% block footer_navigation %}{% endblock %}
|
||||||
| {% block footer %}{% endblock %}
|
| {% block footer %}{% endblock %}
|
||||||
|
|
||||||
| {% block footer_scripts %}
|
|
||||||
script(src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.1/jstree.min.js")
|
| {% block footer_scripts_pre %}
|
||||||
|
|
||||||
| {% if project.has_method('PUT') %}
|
| {% if project.has_method('PUT') %}
|
||||||
| {# JS containing the Edit, Add, Featured, and Move functions #}
|
| {# JS containing the Edit, Add, Featured, and Move functions #}
|
||||||
@@ -274,24 +274,6 @@ script(type="text/javascript", src="{{ url_for('static_pillar', filename='assets
|
|||||||
| {% endif %}
|
| {% endif %}
|
||||||
|
|
||||||
script.
|
script.
|
||||||
{% if show_project %}
|
|
||||||
ProjectUtils.setProjectAttributes({projectId: "{{project._id}}", isProject: true, nodeId: ''});
|
|
||||||
{% else %}
|
|
||||||
{% if node %}
|
|
||||||
ProjectUtils.setProjectAttributes({projectId: "{{project._id}}", isProject: false, nodeId: '{{node._id}}'});
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
var projectTree = document.getElementById('project_tree');
|
|
||||||
|
|
||||||
var urlNodeMove = "{{url_for('projects.move_node')}}";
|
|
||||||
var urlNodeFeature = "{{url_for('projects.add_featured_node')}}";
|
|
||||||
var urlNodeDelete = "{{url_for('projects.delete_node')}}";
|
|
||||||
var urlNodeTogglePublic = "{{url_for('projects.toggle_node_public')}}";
|
|
||||||
var urlNodeToggleProjHeader = "{{url_for('projects.toggle_node_project_header')}}";
|
|
||||||
var urlProjectDelete = "{{url_for('projects.delete')}}";
|
|
||||||
var urlProjectEdit = "{{url_for('projects.edit', project_url=project.url)}}";
|
|
||||||
|
|
||||||
function updateToggleProjHeaderMenuItem() {
|
function updateToggleProjHeaderMenuItem() {
|
||||||
var $toggle_projheader = $('#item_toggle_projheader');
|
var $toggle_projheader = $('#item_toggle_projheader');
|
||||||
|
|
||||||
@@ -308,15 +290,15 @@ script.
|
|||||||
$(updateToggleProjHeaderMenuItem);
|
$(updateToggleProjHeaderMenuItem);
|
||||||
|
|
||||||
// Function to update the interface on loadNodeContent, and edit/saving assets
|
// Function to update the interface on loadNodeContent, and edit/saving assets
|
||||||
function updateUi(nodeId, mode){
|
function updateUi(nodeId, mode) {
|
||||||
|
|
||||||
if (mode === 'view') {
|
if (mode === 'view') {
|
||||||
$('.project-mode-view').show();
|
$('.project-mode-view').show();
|
||||||
$('.project-mode-edit').hide();
|
$('.project-mode-edit').hide();
|
||||||
|
|
||||||
$("#node-edit-form").unbind( "submit" );
|
$("#node-edit-form").unbind("submit");
|
||||||
$("#item_save").unbind( "click" );
|
$("#item_save").unbind("click");
|
||||||
$("#item_cancel").unbind( "click" );
|
$("#item_cancel").unbind("click");
|
||||||
} else if (mode === 'edit') {
|
} else if (mode === 'edit') {
|
||||||
$('.project-mode-view').hide();
|
$('.project-mode-view').hide();
|
||||||
$('.project-mode-edit').show();
|
$('.project-mode-edit').show();
|
||||||
@@ -352,11 +334,33 @@ script.
|
|||||||
// it's done like that in all users of updateUi().
|
// it's done like that in all users of updateUi().
|
||||||
$('#project-loading').removeAttr('class');
|
$('#project-loading').removeAttr('class');
|
||||||
}
|
}
|
||||||
|
| {% endblock %}
|
||||||
|
|
||||||
|
| {% block footer_scripts %}
|
||||||
|
script(src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.1/jstree.min.js")
|
||||||
|
|
||||||
|
script.
|
||||||
|
{% if show_project %}
|
||||||
|
ProjectUtils.setProjectAttributes({projectId: "{{project._id}}", isProject: true, nodeId: ''});
|
||||||
|
{% else %}
|
||||||
|
{% if node %}
|
||||||
|
ProjectUtils.setProjectAttributes({projectId: "{{project._id}}", isProject: false, nodeId: '{{node._id}}'});
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
var projectTree = document.getElementById('project_tree');
|
||||||
|
|
||||||
|
var urlNodeMove = "{{url_for('projects.move_node')}}";
|
||||||
|
var urlNodeFeature = "{{url_for('projects.add_featured_node')}}";
|
||||||
|
var urlNodeDelete = "{{url_for('projects.delete_node')}}";
|
||||||
|
var urlNodeTogglePublic = "{{url_for('projects.toggle_node_public')}}";
|
||||||
|
var urlNodeToggleProjHeader = "{{url_for('projects.toggle_node_project_header')}}";
|
||||||
|
var urlProjectDelete = "{{url_for('projects.delete')}}";
|
||||||
|
var urlProjectEdit = "{{url_for('projects.edit', project_url=project.url)}}";
|
||||||
|
|
||||||
|
|
||||||
function loadNodeContent(url, nodeId) {
|
function loadNodeContent(url, nodeId) {
|
||||||
$('#project-loading').addClass('active');
|
$('#project-loading').addClass('active');
|
||||||
|
|
||||||
$.get(url, function(dataHtml) {
|
$.get(url, function(dataHtml) {
|
||||||
// Update the DOM injecting the generate HTML into the page
|
// Update the DOM injecting the generate HTML into the page
|
||||||
$('#project_context').html(dataHtml);
|
$('#project_context').html(dataHtml);
|
||||||
@@ -608,8 +612,10 @@ script.
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize the page
|
{% if is_embedded_edit is not defined or is_embedded_edit %}
|
||||||
|
// Initialize the page if we are not directly editing a node (most of the time)
|
||||||
loadContent();
|
loadContent();
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
var project_container = document.getElementById('project-container');
|
var project_container = document.getElementById('project-container');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user