From ebdcc3bb6a447e75414c63e852a3776616cf1cf1 Mon Sep 17 00:00:00 2001 From: Marco Morales Date: Tue, 17 Mar 2015 14:05:56 -0400 Subject: [PATCH] Add social sharing feature (Twitter, Facebook) to student dashboard --- .../modulestore/tests/sample_courses.py | 2 +- lms/envs/common.py | 7 +++ lms/static/sass/multicourse/_dashboard.scss | 23 +++++----- lms/templates/dashboard.html | 3 +- .../dashboard/_dashboard_course_listing.html | 46 ++++++++++++++++++- 5 files changed, 66 insertions(+), 15 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py b/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py index 752c61eada..b46460b976 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/sample_courses.py @@ -51,7 +51,7 @@ TOY_BLOCK_INFO_TREE = [ }, [ BlockInfo( "secret:toylab", "html", { - "data": "Lab 2A: Superposition Experiment\n\n<<<<<<< Updated upstream\n

Isn't the toy course great?

\n\n

Let's add some markup that uses non-ascii characters.\nFor example, we should be able to write words like encyclopædia, or foreign words like français.\nLooking beyond latin-1, we should handle math symbols: πr² ≤ ∞.\nAnd it shouldn't matter if we use entities or numeric codes — Ω ≠ π ≡ Ω ≠ π.\n

\n=======\n

Isn't the toy course great? — ≤

\n>>>>>>> Stashed changes\n", + "data": "Lab 2A: Superposition Experiment\n\n\n

Isn't the toy course great?

\n\n

Let's add some markup that uses non-ascii characters.\n'For example, we should be able to write words like encyclopædia, or foreign words like français.\nLooking beyond latin-1, we should handle math symbols: πr² ≤ ∞.\nAnd it shouldn't matter if we use entities or numeric codes — Ω ≠ π ≡ Ω ≠ π.\n

\n\n", # pylint: disable=line-too-long "xml_attributes": {"filename": ["html/secret/toylab.xml", "html/secret/toylab.xml"]}, "display_name": "Toy lab" }, [] diff --git a/lms/envs/common.py b/lms/envs/common.py index abdfdbd01a..4e72642093 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -364,6 +364,13 @@ FEATURES = { # Certificates Web/HTML Views 'CERTIFICATES_HTML_VIEW': False, + + # Social Media Sharing on Student Dashboard + 'DASHBOARD_SHARE_SETTINGS': { + 'FACEBOOK_SHARING': False, + 'TWITTER_SHARING': False, + 'TWITTER_SHARING_TEXT': None + }, } # Ignore static asset files on import which match this pattern diff --git a/lms/static/sass/multicourse/_dashboard.scss b/lms/static/sass/multicourse/_dashboard.scss index af6a01c3e0..2918e8adac 100644 --- a/lms/static/sass/multicourse/_dashboard.scss +++ b/lms/static/sass/multicourse/_dashboard.scss @@ -1,7 +1,7 @@ // lms - views - user/student dashboard // ==================== -// Table of Contents +// Table of Contents // * +Dashboard - Sidebar // * +Dashboard - Course Listing // * +Dashboard - Course Item @@ -10,7 +10,7 @@ // +Dashboard - Sidebar -// ==================== +// ==================== .dashboard { @include clearfix(); padding: ($baseline*2) 0 0 0; @@ -214,7 +214,7 @@ } // +Dashboard - Course Listing -// ==================== +// ==================== .dashboard { .my-courses { @include float(left); @@ -289,7 +289,7 @@ } // +Dashboard - Course -// ==================== +// ==================== .dashboard .my-courses { // UI: individual course item @@ -409,7 +409,6 @@ .course-actions { // UI: course item actions - .action { @include box-sizing(border-box); @include margin-right($baseline/2); @@ -419,7 +418,8 @@ border-radius: 3px; padding: 12px; border: 1px solid $white; - + text-align: center; + &:hover, &:focus { color: $gray-d3; border: 1px solid $gray-l4; @@ -447,7 +447,6 @@ position: relative; @include float(right); - .actions-dropdown { @extend %ui-no-list; @extend %ui-depth1; @@ -968,7 +967,7 @@ } } - // TYPE: pre-requisites + // TYPE: pre-requisites .prerequisites { @include clearfix; @@ -1069,7 +1068,7 @@ } // +Misc - Uncategorized -// ==================== +// ==================== .dashboard .my-courses { // status - language @@ -1256,7 +1255,7 @@ border:0; color:white; box-shadow:none; - + &.archived { @include button(simple, $button-archive-color); font: normal 15px/1.6rem $sans-serif; @@ -1279,8 +1278,8 @@ } // +Dashboard - Banner -// ==================== -.dashboard .my-courses { +// ==================== +.dashboard .my-courses { .dashboard-banner { &:empty { diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index 6aa2c15d5a..818baf536b 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -81,6 +81,7 @@ % if len(course_enrollment_pairs) > 0: % else: diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html index 19e5af2c9b..f9991f9362 100644 --- a/lms/templates/dashboard/_dashboard_course_listing.html +++ b/lms/templates/dashboard/_dashboard_course_listing.html @@ -1,6 +1,8 @@ -<%page args="course, enrollment, show_courseware_link, cert_status, show_email_settings, course_mode_info, show_refund_option, is_paid_course, is_course_blocked, verification_status, course_requirements, dashboard_index" /> +<%page args="course, enrollment, show_courseware_link, cert_status, show_email_settings, course_mode_info, show_refund_option, is_paid_course, is_course_blocked, verification_status, course_requirements, dashboard_index, share_settings" /> <%! +import urllib + from django.utils.translation import ugettext as _ from django.utils.translation import ungettext from django.core.urlresolvers import reverse @@ -113,6 +115,48 @@ from student.helpers import ( ${_('View Course')} ${course.display_name_with_default} % endif % endif + + % if share_settings: + <% share_url = urllib.quote_plus(request.build_absolute_uri(reverse('about_course', args=[unicode(course.id)]))) %> + <% share_window_name = 'shareWindow' %> + <% share_window_config = 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=640, height=480' %> + % if share_settings.get('FACEBOOK_SHARING', False): + <% facebook_url = 'https://www.facebook.com/sharer/sharer.php?u=' + share_url %> + + % endif + % if share_settings.get('TWITTER_SHARING', False): + <% share_text_default = _("I'm learning on {platform_name}:").format(platform_name=settings.PLATFORM_NAME) %> + <% share_text = share_settings.get('TWITTER_SHARING_TEXT', share_text_default) %> + <% twitter_url = 'https://twitter.com/intent/tweet?text=' + share_text + '%20' + share_url %> + + % endif + % endif +