| {% extends 'layout.html' %}
include ../../../pillar/src/templates/mixins/components

| {# Default case is Open Projects #}
| {% set page_title = 'Open Projects' %}
| {% set page_description = 'Full production data and tutorials from all open movies, for you to use freely' %}
| {% set page_header_image = url_for('static', filename='assets/img/backgrounds/background_agent327_01.jpg') %}
| {% set page_header_text = 'The iconic Blender Institute Open Movies. Featuring all the production files, assets, artwork, and never-seen-before content.' %}

| {% if title == 'courses' %}
| 	{% set page_title = 'Courses' %}
| 	{% set page_description = 'Production quality training by 3D professionals' %}
| 	{% set page_header_image = url_for('static', filename='assets/img/backgrounds/background_agent327_04.jpg') %}
| 	{% set page_header_text = 'Character modeling, 3D printing, VFX, rigging and more.' %}

| {% elif title == 'workshops' %}
| 	{% set page_title = 'Workshops' %}
| 	{% set page_description = 'Production quality training by 3D professionals' %}
| 	{% set page_header_image = url_for('static', filename='assets/img/backgrounds/background_agent327_04.jpg') %}
| 	{% set page_header_text = 'Enter the artist workshop and learn by example.' %}

| {% endif %}

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

meta(property="og:title", content="{{ page_title }} on Blender Cloud")
meta(name="twitter:title", content="{{ page_title }} on Blender Cloud")

meta(property="og:description", content="{{ page_description }}")
meta(name="twitter:description", content="{{ page_description }}")

meta(property="og:image", content="{{ page_header_image }}")
meta(name="twitter:image", content="{{ page_header_image }}")
| {% endblock %}

| {% block page_title %}
| {{ page_title }}
| {% endblock %}

| {% block navigation_tabs %}

| {% if title in ['courses', 'workshops'] %}
+nav-secondary
	+nav-secondary-link(
			class="{% if title == 'workshops' %}active{% endif %}",
			href="{{ url_for('cloud.workshops') }}")
		| Workshops

	+nav-secondary-link(
			class="{% if title == 'courses' %}active{% endif %}",
			href="{{ url_for('cloud.courses') }}")
		| Courses

	+nav-secondary-link(
			class="{% if title == 'gallery' %}active{% endif %}",
			href="{{ url_for('projects.view', project_url='gallery') }}")
		| Art Gallery
| {% endif %}

| {% endblock navigation_tabs %}

| {% block body %}

.container.pb-5
	.row
		.col-12
			.pt-4
				h2.text-uppercase.font-weight-bold
					| {{ page_title }}
				.lead
					| {{ page_header_text }}

				hr.pb-2

			+card-deck(3)
				| {% for project in projects %}

				| {% if (project.status == 'published') or (project.status == 'pending' and current_user.is_authenticated) and project._id != config.MAIN_PROJECT_ID %}
				+card(
					class='js-project-go card-fade cursor-pointer mb-4 mx-0',
					data-url="{{ url_for('projects.view', project_url=project.url) }}",
					tabindex='{{ loop.index }}')
					| {% if project.picture_header %}
					a(href="{{ url_for('projects.view', project_url=project.url) }}")
						img.card-img-top(
							src="{{ project.picture_header.thumbnail('l', api=api) }}", alt="{{ project.name }}")
					| {% endif %}

					.card-body
						h5.card-title
							| {{ project.name }}
							| {% if project.status == 'pending' and current_user.is_authenticated and current_user.has_role('admin') %}
							small (pending)
							| {% endif %}

						| {% if project.summary %}
						p.card-text
							| {{project.summary|safe}}
						| {% endif %}
				| {% endif %}
				| {% endfor %}

| {% endblock %}


| {% block footer_scripts %}
script.
	$('.js-project-go').on('click', function(e){
		e.preventDefault();
		window.location.href = $(this).data('url');
	});
| {% endblock %}
