Skip to content

Commit

Permalink
OUBlog: Tweet a (publicly accessible) post#11762
Browse files Browse the repository at this point in the history
  • Loading branch information
athompson697 authored and sammarshallou committed Oct 28, 2014
1 parent e3f9f06 commit c26a977
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 3 deletions.
127 changes: 127 additions & 0 deletions internaldoc/testcase.socialmedia.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
This script describes steps to test OU Blog standard tweet functionality.
It is intended to cover just the Tweet UI feature.

NOTE: In this test case, the word 'blog' always refers to the OU blog.

Some test steps in this script follow on from each other and aren't independent.
In these cases the prerequisite steps are listed.

Initial setup
=============

This test case requires:

- a text file 'post1.txt' for attachment-upload.
- a user with administration rights
- access to the personal blog.

The test server must have debugging set to DEVELOPER level and to display
errors; during all parts of the test script, there should be no debugging
warnings.

Note: With Javascript enabled a Twitter "Tweet" widget button will be provided,
without Javascript a "Tweet" link will be provided.

TCR Creating blog data
======================

TCR01 / admin.
Log in and access the 'Personal Blog'.
Select the 'New blog post' button.
Enter 'TCR01 tweet a titled post' into the 'Title' field.
Enter some text into the 'Message' field.
Change 'Who can read this?' to the 'Visible to anyone in the world' setting.
Select 'Add post' button to save the new post and return to main blog view.
-- Verify post created is displayed at the top of the posts area.
-- Confirm that the post has a dark grey box in its top right corner,
with the label 'Share this post' with a 'Tweet' button/link beneath.

TCR02 / admin.
Select the 'New blog post' button.
Leave the 'Title' field empty.
Enter 'TCR02 tweet an untitled post' into the 'Message' field.
-- Attach the text file to the post.
Change 'Who can read this?' to the 'Visible to anyone in the world' setting.
Select 'Add post' button to save the new post and return to main blog view.
-- Verify this new post created is displayed at the top of the posts area.
-- Confirm that the post has a light grey box in its top right corner, with the label
'Attachments' with an icon and 'post1.txt' download link beneath.
-- Confirm that beneath the 'Attachments' box is the dark grey box, with the label
'Share this post' with a 'Tweet' button/link beneath.

TCR03 / admin.
Select the 'New blog post' button.
Enter 'TCR03 can only tweet a public post' into the 'Title' field.
Enter some text into the 'Message' field.
Change 'Who can read this?' to 'Visible to everyone who is logged in to the system'.
-- Verify that the post does not have the dark grey box, with the label
'Share this post' with a 'Tweet' button/link beneath.


TWT Testing Tweet button
========================

TWT01 / admin
On the post titled "TCR01 tweet a titled post".
Click 'Permalink' link, to open the post in another tab.
Note the post=id in the viewpost.php page URL.

Return to the post "TCR01" on the blog main page.

TWT02 / admin
Click the 'Tweet' button/link for post "TCR01 tweet a titled post".
-- Confirm that a new 'Share a link on Twitter' window pops up.
-- Verify that the text box 'Share a link with your followers' contains
'TCR01 tweet a titled post {Admin user's blog}'
-- Confirm that this is followed by the URL of the viewpost.php page for the post "TCR01".

Close the popup window.

TWT03 / admin
On the Untitled post "TCR02".
Click 'Permalink' link, to open this post in another tab.
Note the post=id in the viewpost.php page URL.

Return to the post "TCR02" on the blog main page.

TWT04 / admin
Click the 'Tweet' button/link for the Untitled post "TCR02".
-- Confirm that a new 'Share a link on Twitter' window pops up.
-- Verify that the text box 'Share a link with your followers' contains
'Untitled post {Admin user's blog}'
-- Confirm that this is followed by the URL of the viewpost.php page for the post "TCR02".

Close the popup window.

TWT05 / admin
On the post titled "TCR01 tweet a titled post".
Click 'Permalink' link, to open the post in the viewpost.php page.
Click the 'Tweet' button/link for the post.
-- Confirm that a new 'Share a link on Twitter' window pops up.
-- Verify that the text box 'Share a link with your followers' contains
'TCR01 tweet a titled post {Admin user's blog}'
-- Confirm that this is followed by the URL of this viewpost.php page for the post "TCR01".

Close the popup window.

TWT06 / admin
In the Blog summary block.
Click the 'View site entries' link.
-- Verify the the allposts.php page opens showing 'Personal blogs'
-- Confirm that only posts 'Visible to anyone in the world' have the dark grey box,
with the label 'Share this post' with a 'Tweet' button/link beneath.

TWT07 / admin
Repeat steps TWT01-TWT04 to confirm functionality for allposts, 'Personal blogs' page.

Log out or open a different browser.

TWT08 / Not logged in user
-- Confirm that only posts 'Visible to anyone in the world' are available.
-- Confirm that they have the dark grey box, with the label 'Share this post'
with a 'Tweet' button/link beneath.

TWT09 / Not logged in user
Repeat steps TWT01-TWT04 to confirm functionality for 'Non logged in user'.

Test ends.
2 changes: 2 additions & 0 deletions lang/en/oublog.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,3 +602,5 @@
$string['nograde'] = 'No grade (default)';
$string['teachergrading'] = 'Teacher grades students';
$string['userrating'] = 'Use ratings';
$string['share'] = 'Share this post';
$string['tweet'] = 'Tweet';
40 changes: 40 additions & 0 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function render_post($cm, $oublog, $post, $baseurl, $blogtype,

$output .= html_writer::start_tag('div', array('class' => 'oublog-post'. $extraclasses));
$output .= html_writer::start_tag('div', array('class' => 'oublog-post-top'));
$output .= html_writer::start_tag('div', array('class' => 'oublog-social-container'));
$fs = get_file_storage();
if ($files = $fs->get_area_files($modcontext->id, 'mod_oublog', 'attachment', $post->id,
"timemodified", false)) {
Expand Down Expand Up @@ -100,6 +101,31 @@ public function render_post($cm, $oublog, $post, $baseurl, $blogtype,
}
$output .= html_writer::end_tag('div');
}
// Only show widgets if blog is global ect.
if ($oublog->global && $oublog->maxvisibility == OUBLOG_VISIBILITY_PUBLIC) {
if ($post->visibility == OUBLOG_VISIBILITY_PUBLIC && !$forexport && !$email) {
list($oublog, $oubloginstance) = oublog_get_personal_blog($post->userid);
$oubloginstancename = $oubloginstance->name;
$linktext = get_string('tweet', 'oublog');
$purl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
$postname = !(empty($post->title)) ? $post->title : get_string('untitledpost', 'oublog');
$output .= html_writer::start_tag('div', array('class' => 'oublog-post-socialshares'));
$output .= get_string('share', 'oublog');
$output .= html_writer::start_tag('div', array('class' => 'oublog-post-share'));
// Show tweet link.
$params = array('url' => $purl, 'dnt' => true, 'count' => 'none',
'text' => $postname . " " . $oubloginstance->name,
'class' => 'twitter-share-button');
$turl = new moodle_url('https://twitter.com/share', $params);
$output .= html_writer::link($turl, $linktext, $params);
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
// With JS enabled show twitters widget button.
self::render_twitter_js();
}
}
$output .= html_writer::end_tag('div');

$output .= html_writer::start_tag('div', array('class' => 'oublog-post-top-content'));
if (!$forexport) {
$output .= html_writer::start_tag('div', array('class' => 'oublog-userpic'));
Expand Down Expand Up @@ -1346,6 +1372,20 @@ public function render_tag_order($selected) {
return $output;
}

/**
* Renders Twitter widget js code into the page.
*/
public function render_twitter_js() {
global $PAGE;
static $loaded;
if ($loaded || $PAGE->devicetypeinuse == 'legacy') {
return;
} else {
$PAGE->requires->js_init_code("Y.Get.js('https://platform.twitter.com/widgets.js', {async:true})");
$loaded = true;
}
}

}

class oublog_statsinfo implements renderable {
Expand Down
27 changes: 25 additions & 2 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,34 @@
border-radius: 5px;
background-color: #E7E7E7;
width: 200px;
margin-bottom: 1em;
margin-bottom: 0.4em;
font-size: 0.85em;
}

.oublog-post .oublog-social-container {
float: right;
width: 200px;
}

.oublog-post .oublog-post-socialshares {
float: right;
padding: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background-color: #6E6E6E;
width: 200px;
font-size: 0.85em;
color: white;
margin-bottom: .5em;
}

.oublog-post .oublog-post-attachment {
display: inline;
word-break: break-all;
margin-right: .75em;
}
.oublog-post .oublog-post-share {
margin-top: .2em;
word-break: break-all;
margin-right: .75em;
}
Expand Down
47 changes: 47 additions & 0 deletions tests/behat/personalblog.feature
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,50 @@ Feature: Test Post and Comment on Personal OUBlog
Then I should see "Personal OUBlog post22"
And I should not see "Personal OUBlog post21"
And ".oublog-paging .next" "css_element" should not exist

# New scenario tests the tweet widget availability
Scenario: Admin tests the blog tweet facility
Given I log in as "admin"
And I am on homepage
And I follow "Personal Blogs"

# Admin adds a Private post Tweet not available
Given I press "New blog post"
And I should see "New blog post"
And I set the following fields to these values:
| Title | SC02 Personal OUBlog post01 |
| Message | SC02 Admin Persblog post01 content Private |
| Tags | SC02edap01 |
| Who can read this | Visible only to the blog owner (private) |
And I press "Add post"
Then I should see "SC02 Personal OUBlog post01"
And I should see "SC02 Admin Persblog post01 content Private"
And I should see "sc02edap01"
And I should not see "Share this post"
And I should not see "Tweet"

# Admin adds a WorldVis post and Tweet is available
Given I press "New blog post"
And I should see "New blog post"
And I set the following fields to these values:
| Title | SC02 Personal OUBlog post02 |
| Message | SC02 Admin Persblog post02 content WorldVis |
| Tags | SC02edap02 |
| Who can read this | Visible to anyone in the world |
And I press "Add post"
Then I should see "SC02 Personal OUBlog post02"
And I should see "SC02 Admin Persblog post02 content WorldVis"
And I should see "sc02edap02"
And I should see "Share this post"
And I should see "Tweet"

# Admin opens viewpost page and Tweet is available
And I click on "//a[contains(@href,'viewpost.php?post=2')]" "xpath_element"
And I wait to be redirected
Then I should see "SC02 Personal OUBlog post02"
And I should see "SC02 Admin Persblog post02 content WorldVis"
And I should see "sc02edap02"
And I should see "Share this post"
And I should see "Tweet"
And I should not see "SC02 Personal OUBlog post01"
And I should not see "SC02 Admin Persblog post01 content Private"
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @package oublog
**/

$plugin->version = 2014102300;
$plugin->version = 2014102700;
$plugin->requires = 2014051200;
$plugin->cron = 60*60*4; // 4 hours.
$plugin->component = 'mod_oublog';// Full name of the plugin (used for diagnostics)
Expand Down

0 comments on commit c26a977

Please sign in to comment.