Shivam Mishra | c8c790a | 2019-05-21 12:04:50 +0530 | [diff] [blame] | 1 | {% extends "templates/base.html" %} |
Shivam Mishra | ae2871f | 2019-05-29 13:11:34 +0530 | [diff] [blame] | 2 | {% block title %}{{ content.name or 'Content Page' }}{% endblock %} |
Shivam Mishra | c8c790a | 2019-05-21 12:04:50 +0530 | [diff] [blame] | 3 | |
| 4 | {% block head_include %} |
| 5 | <style> |
| 6 | div.card-hero-img { |
| 7 | height: 220px; |
| 8 | background-size: cover; |
| 9 | background-repeat: no-repeat; |
| 10 | background-position: center; |
| 11 | background-color: rgb(250, 251, 252); |
| 12 | } |
| 13 | |
| 14 | .card-image-wrapper { |
| 15 | display: flex; |
| 16 | overflow: hidden; |
| 17 | height: 220px; |
| 18 | background-color: rgb(250, 251, 252); |
| 19 | justify-content: center; |
| 20 | } |
| 21 | |
| 22 | .image-body { |
| 23 | align-self: center; |
| 24 | color: #d1d8dd; |
| 25 | font-size: 24px; |
| 26 | font-weight: 600; |
| 27 | line-height: 1; |
| 28 | padding: 20px; |
| 29 | } |
| 30 | </style> |
| 31 | <link rel="stylesheet" href="https://cdn.plyr.io/3.5.3/plyr.css" /> |
| 32 | {% endblock %} |
| 33 | |
| 34 | {% macro navigation() %} |
| 35 | <div class="row"> |
| 36 | <div class="col-md-7"> |
| 37 | <h1>{{ content.name }}</h1> |
| 38 | </div> |
| 39 | <div class="col-md-5 text-right"> |
| 40 | {% if previous %} |
| 41 | <a href="/lms/content?course={{ course }}&topic={{ topic }}&type={{ previous.content_type }}&content={{ previous.content }}" class='btn btn-outline-secondary'>Previous</a> |
| 42 | {% else %} |
| 43 | <a href="/lms/course?name={{ course }}" class='btn btn-outline-secondary'>Back to Course</a> |
| 44 | {% endif %} |
| 45 | |
| 46 | {% if next %} |
| 47 | <button id="nextButton" onclick="handle('/lms/content?course={{ course }}&topic={{ topic }}&type={{ next.content_type }}&content={{ next.content }}')" class='btn btn-primary' disabled="true">Next</button> |
| 48 | {% else %} |
| 49 | <button id="nextButton" onclick="handle('/lms/course?name={{ course }}')" class='btn btn-primary' disabled="true">Finish Topic</button> |
| 50 | {% endif %} |
| 51 | </div> |
| 52 | </div> |
| 53 | {% endmacro %} |
| 54 | |
| 55 | {% macro video() %} |
| 56 | <div class="mb-5"> |
| 57 | {{ navigation() }} |
| 58 | <div class="text-muted"> |
| 59 | {% if content.duration %} |
| 60 | {{ content.duration }} Mins |
| 61 | {% endif %} |
| 62 | |
| 63 | {% if content.publish_date and content.duration%} |
| 64 | - |
| 65 | {% endif %} |
| 66 | |
| 67 | {% if content.publish_date %} |
| 68 | Published on {{ content.publish_date.strftime('%d, %b %Y') }} |
| 69 | {% endif %} |
| 70 | </div> |
| 71 | </div> |
| 72 | <div id="player" data-plyr-provider="{{ content.provider|lower }}" data-plyr-embed-id="{{ content.url }}"></div> |
| 73 | <div class="my-5"> |
| 74 | {{ content.description }} |
| 75 | </div> |
Shivam Mishra | c8c790a | 2019-05-21 12:04:50 +0530 | [diff] [blame] | 76 | {% endmacro %} |
| 77 | |
| 78 | {% macro article() %} |
| 79 | <div class="mb-5"> |
| 80 | {{ navigation() }} |
| 81 | <div class="text-muted"> |
| 82 | {% if content.author or content.publish_date %} |
| 83 | Published |
| 84 | {% endif %} |
| 85 | {% if content.author %} |
| 86 | by {{ content.author }} |
| 87 | {% endif %} |
| 88 | {% if content.publish_date %} |
| 89 | on {{ content.publish_date.strftime('%d, %b %Y') }} |
| 90 | {% endif %} |
| 91 | </div> |
| 92 | </div> |
Shivam Mishra | 24bd07d | 2019-05-30 16:36:58 +0530 | [diff] [blame^] | 93 | <div style="line-height: 1.8em;"> |
Shivam Mishra | c8c790a | 2019-05-21 12:04:50 +0530 | [diff] [blame] | 94 | {{ content.content }} |
| 95 | </div> |
| 96 | {% endmacro %} |
| 97 | |
| 98 | {% block content %} |
| 99 | <section class="section"> |
| 100 | <div> |
| 101 | <div class='container pb-5'> |
| 102 | {% if content_type=='Video' %} |
| 103 | {{ video() }} |
| 104 | {% elif content_type=='Article'%} |
| 105 | {{ article() }} |
| 106 | {% elif content_type=='Quiz' %} |
| 107 | <h2>Quiz: {{ content.name }}</h2> |
| 108 | {% endif %} |
| 109 | </div> |
| 110 | </div> |
| 111 | </section> |
Shivam Mishra | ae2871f | 2019-05-29 13:11:34 +0530 | [diff] [blame] | 112 | {% endblock %} |
| 113 | |
| 114 | {% block script %} |
| 115 | {% if content_type=='Video' %} |
| 116 | <script src="https://cdn.plyr.io/3.5.3/plyr.js"></script> |
| 117 | {% endif %} |
| 118 | <script> |
| 119 | {% if content_type=='Video' %} |
| 120 | const player = new Plyr('#player'); |
| 121 | {% endif %} |
| 122 | |
| 123 | frappe.ready(() => { |
| 124 | next = document.getElementById('nextButton') |
| 125 | next.disabled = false; |
| 126 | }) |
| 127 | |
| 128 | function handle(url) { |
| 129 | frappe.call("add_activity", |
| 130 | { |
| 131 | course: "{{ course }}", |
| 132 | content_type: "{{ content_type }}", |
| 133 | content: "{{ content.name }}", |
| 134 | } |
| 135 | ) |
| 136 | } |
| 137 | </script> |
Shivam Mishra | c8c790a | 2019-05-21 12:04:50 +0530 | [diff] [blame] | 138 | {% endblock %} |