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

| {% set title = 'homepage' %}

| {% block og %}
meta(property="og:type", content="website")
meta(property="og:url", content="https://cloud.blender.org/")

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 body %}
.dashboard-container
	section.dashboard-main

		section.blog-stream
			ul.blog-stream__list
				| {% if latest_posts %}
				| {% for node in latest_posts %}
				| {{ render_blog_post(node) }}
				| {% endfor %}
				| {% else %}
				li
					.blog-stream__list-details
						ul.meta
							li.when No blog entries... yet!
				| {% endif %}

			.more
				a(href="{{ url_for('main.main_blog') }}")
					| See All Blog Posts

			a.feed(
				href="{{ url_for('main.feeds_blogs') }}",
				title="Blogs Feed",
				data-toggle="tooltip",
				data-placement="left")
				i.pi-rss


	section.dashboard-secondary
		| {{ navigation_tabs(title) }}

		section.dashboard-in-production
			h4 In Production
			span.section-lead.
				Check out these projects currently in production!

			a.in-production-project(href="https://cloud.blender.org/p/spring/")
				img(src="{{ url_for('static', filename='assets/img/projects/spring_450x150.jpg')}}")
				p.
					#[strong Spring] - A poetic short film about a mountain spirit and her wise little dog.

			a.in-production-project(href="https://cloud.blender.org/p/hero/")
				img(src="{{ url_for('static', filename='assets/img/projects/hero_450x150.jpg')}}")
				p.
					#[strong Hero] - A '2D' trailer-style movie focused on getting grease pencil
					production ready for Blender 2.8.

		section.stream

			h4 Latest Assets

			ul.activity-stream__list
				| {% for n in activity_stream %}
				li(
					class="{{ n.node_type }} {{ n.properties.content_type }} {% if n.picture %}with-picture{% endif %}",
					data-url="{{ n.url }}")
					a.activity-stream__list-thumbnail(
						class="{{ n.properties.content_type }}",
						href="{{ n.url }}")
						| {% if n.picture %}
						img(src="{{ n.picture.thumbnail('m', api=api) }}")
						| {% endif %}

						.activity-stream__list-thumbnail-icon
							| {% if n.node_type == 'asset' %}
							| {% if n.properties.content_type == 'video' %}
							i.pi-play
							| {% 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 %}


					.activity-stream__list-details
						a.title(href="{{ n.url }}")
							| {{ n.name }}

						| {% if n.permissions.world %}
						.ribbon
							span free
						| {% endif %}
						ul.meta
							| {% if not n.picture %}
							li.when
								a(href="{{ n.url }}", title="{{ n._created }}") {{ n._created | pretty_date_time }}
							li.who {{ n.user.full_name }}
							| {% endif %}

							| {% if n.attached_to %}
							li.where-parent
								a(href="{{ n.attached_to.url }}") {{ n.attached_to.name }}
							| {% endif %}
							li.where-project
								a.project(href="{{ url_for('projects.view', project_url=n.project.url) }}") {{ n.project.name }}
							li.what
								| {% if n.node_type == 'asset' %}
								| {{ n.properties.content_type | undertitle  }}
								| {% endif %}

						| {% if n.picture %}
						ul.meta.extra
							li.when
								a(href="{{ n.url }}", title="{{ n._created }}") {{ n._created | pretty_date_time }}
							li.who {{ n.user.full_name }}
						| {% endif %}
				| {% endfor %}

				li.activity-stream__list-item.empty#activity-stream__empty
					| No items to list.


		section.random-asset
			h4
				a(href="/search") Explore the Cloud
			span.section-lead Random selection of the best assets &amp; tutorials

			ul.random-asset__list
				| {% 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.meta
							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.meta
						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.meta
							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

			h4 Latest Comments

			ul
				| {% 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.meta
						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 %}
