| {% extends 'layout.html' %}
include 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="https://cloud.blender.org")

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 body %}

+jumbotron("{{ page_title }}", "{{ page_header_text }}", "{{ page_header_image }}")

.container.pb-5
	+nav-secondary("{% if title in ['courses', 'workshops'] %}Training{% else %}Open Projects{% endif %}")
		+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

	+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(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.rounded-0(
					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 %}
