| {% extends 'layout.html' %}
| {% from '_macros/_navigation.html' import navigation_tabs %}
| {% from '_macros/_asset_list_item.html' import asset_list_item %}
| {% from 'nodes/custom/blog/_macros.html' import render_blog_post %}

include ../../../pillar/src/templates/mixins/components

| {% set title = 'homepage' %}

| {% block og %}
meta(property="og:type", content="website")
meta(property="og:url", content="{{ request.url }}")

meta(property="og:title", content="Blender Cloud")
meta(name="twitter:title", content="Blender Cloud")

meta(property="og:description", content="Blender Cloud is a web based service developed by Blender Institute that allows people to access the training videos and all the data from the open projects.")
meta(name="twitter:description", content="Blender Cloud is a web based service developed by Blender Institute that allows people to access the training videos and all the data from the open projects.")

meta(property="og:image", content="{% if main_project.picture_header %}{{ main_project.picture_header.thumbnail('l', api=api) }}{% else %}{{ url_for('static', filename='assets/img/backgrounds/background_agent327_04.jpg')}}{% endif %}")
meta(name="twitter:image", content="{% if main_project.picture_header %}{{ main_project.picture_header.thumbnail('l', api=api) }}{% else %}{{ url_for('static', filename='assets/img/backgrounds/background_agent327_04.jpg')}}{% endif %}")
| {% endblock %}

| {% block navigation_tabs %}
| {{ navigation_tabs(title) }}
| {% endblock navigation_tabs %}

| {% block body %}
.container-fluid.dashboard-container.imgs-fluid
	.row
		.col-md-9.col-xl-10
			section.blog
				| {% if latest_posts %}
				| {% for node in latest_posts %}
				| {{ render_blog_post(node) }}
				| {% endfor %}
				| {% else %}
				| No blog entries... yet!
				| {% endif %}

				.d-block.text-center
					a.d-inline-block.p-3.text-muted(href="{{ url_for('main.main_blog') }}")
						| See All Blog Posts

					a.d-inline-block.p-3.text-muted(
						href="{{ url_for('main.feeds_blogs') }}",
						title="Blogs Feed",
						data-toggle="tooltip",
						data-placement="left")
						i.pi-rss
						| RSS Feed

		.col-md-3.col-xl-2
			.dashboard-sidebar
				section.pt-3
					h6.title-underline In Production
					a(href="/p/spring/")
						img(src="{{ url_for('static', filename='assets/img/projects/spring_450x150.jpg')}}")

					p.text-muted.pt-2.
						A poetic short film about a mountain spirit and her wise little dog. #[a(href="/p/spring/") Check it out].

				section.stream.py-3
					h6.title-underline Latest Assets

					| {% if activity_stream %}
					.card-padless.p-2
						| {% for child in activity_stream %}
						| {% if child.node_type not in ['comment'] %}
						| {{ asset_list_item(child, current_user) }}
						| {% endif %}
						| {% endfor %}
					| {% else %}
					.card
						.card-body
							h6.card-title
								| No assets.
					| {% endif %}

				section.random-asset.py-3
					h6.title-underline
						a(href="/search") Explore the Cloud
					.pb-3.text-muted Random selection of the best assets &amp; tutorials

					ul.random-asset__list.list-unstyled
						| {% for n in random_featured %}
						| {% if n.picture and loop.first %}
						li.random-asset__list-item.project
							| {% if n.project.picture_square %}
							a.random-asset__list-thumbnail(
								href="{{ n.project.url }}")
								img.image(src="{{ n.project.picture_square.thumbnail('s', api=api) }}")
							| {% endif %}
							.random-asset__list-details
								a.title(href="{{ n.project.url }}") {{ n.project.name }}
								| {% if n.project.summary %}
								ul.list-unstyled.d-flex.text-muted
									li.what
										a(href="{{ n.project.url }}") {{ n.project.summary }}
								| {% endif %}

						li.random-asset__list-item.featured
							| {% if n.permissions.world %}
							.ribbon
								span FREE
							| {% endif %}
							a.random-asset__thumbnail(
								href="{{ n.url }}",
								class="{{ n.properties.content_type }}")
								| {% if n.picture %}
								img(src="{{ n.picture.thumbnail('l', api=api) }}")

								| {% if n.properties.content_type == 'video' %}
								i.pi-play
								| {% endif %}

								| {% endif %}

							a.title(href="{{ n.url }}")
								| {{ n.name }}
							ul.list-unstyled.d-flex.text-muted
								li.what
									a(href="{{ n.url }}")
										| {% if n.properties.content_type %}{{ n.properties.content_type | undertitle }}{% else %}Folder{% endif %}
								li.where
									a(href="{{ n.project.url }}")
										| {{ n.project.name }}
						| {% else %}

						li
							| {% if n.permissions.world %}
							.ribbon
								span FREE
							| {% endif %}
							a.random-asset__list-thumbnail(
								href="{{ n.url }}",
								class="{{ n.properties.content_type }}")
								| {% if n.picture %}
								img.image(src="{{ n.picture.thumbnail('s', api=api) }}")
								| {% else %}
								| {% if n.properties.content_type == 'video' %}
								i.pi-film-thick
								| {% elif n.properties.content_type == 'image' %}
								i.pi-picture
								| {% elif n.properties.content_type == 'file' %}
								i.pi-file-archive
								| {% else %}
								i.pi-folder
								| {% endif %}
								| {% endif %}
							.random-asset__list-details
								a.title(href="{{ n.url }}") {{ n.name }}
								ul.list-unstyled.d-flex.text-muted
									li.what
										a(href="{{ n.url }}")
											| {% if n.properties.content_type %}{{ n.properties.content_type }}{% else %}Folder{% endif %}
									li.where
										a(href="{{ n.project.url }}") {{ n.project.name }}

						| {% endif %}
						| {% endfor %}


				section.comments.py-3
					h6.title-underline Latest Comments

					ul.list-unstyled
						| {% if latest_comments %}
						| {% for n in latest_comments %}
						li(
							class="{{ n.node_type }}",
							data-url="{{ n.url }}")

							a.comment-content(href="{{ n.url }}")
								| {{ n.properties.content | striptags | truncate(200) }}

							ul.list-unstyled.d-flex.text-muted
								li.who {{ n.user.full_name }}
								| {% if n.attached_to %}

								li.where-parent
									a(href="{{ n.attached_to.url }}") {{ n.attached_to.name }}
								| {% endif %}

								li.when
									a(href="{{ n.url }}", title="{{ n._created }}")
										| {{ n._created | pretty_date_time }}
						| {% endfor %}

						| {% else %}
						li.activity-stream__list-item.empty#activity-stream__empty
							| No comments... yet!

						| {% endif %}

| {% endblock %}


| {% block footer_scripts %}
script.
	$(function () {

	/* cleanup mentions in comments  */
	$('.comment-content').each(function(){
		$(this).text($(this).text().replace(/\*|\@|\<(.*?)\>/g, ''));
	});

	/* Click on the whole asset/comment row to go */
	$('.activity-stream__list li, .comments ul li').click(function(e){
		window.location.href = $(this).data('url');
		$(this).addClass('active');
	});

	hopToTop(); // Display jump to top button
	});
| {% endblock %}
