Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding disqus drush modules. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added disqus-tools/.DS_Store
Binary file not shown.
43 changes: 43 additions & 0 deletions disqus-tools/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---------------------------------------------------------------------
NYS DISQUS TOOLS AND UTILITIES
---------------------------------------------------------------------

nys_disqus_processor
A drush module that contains utility commands.
Most are just wrappers for disqus API calls.

get-thread Gets the data about a thread.

update-thread-id Updates the threads Identifier.

update-thread-link Updates the threads Link.

survey-threads Surveys the threads in an input table

get-posts Gets the posts for a thread.

get-post Gets a single post.


---------------------------------------------------------------------
process_disqus_export_file.php script.

Loads the `nys_disqus_comments` table from a disqus export file.


---------------------------------------------------------------------
extract_nids_from disqus_xml_file.php

Parses the disqus xml export file.
Creates multiple output csv files for the different styles of identifiers.

---------------------------------------------------------------------
nys_scraper

Contains 4 drush commands for processing a Survey created with the
survey-threads drush command.

---------------------------------------------------------------------



63 changes: 63 additions & 0 deletions disqus-tools/extract_nids_from disqus_xml_file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/*
* Loads the xml export file from disqus
* splits it out to differnt output files depending on the data
*/

$xml = simplexml_load_file('/Users/sethsnyder/Desktop/NYSENATE/DISQUS/XML-EXTRACT-TNG/V1all.xml');

$count_of_threads = 0;

$node_slash_nid_style_identifiers = fopen("/Users/sethsnyder/Desktop/NYSENATE/DISQUS/XML-EXTRACT-TNG/node_slash_nid_style_identifiers.csv","w");
$other_style_identifiers = fopen("/Users/sethsnyder/Desktop/NYSENATE/DISQUS/XML-EXTRACT-TNG/other_style_identifiers.csv","w");
$links_for_empty_identifiers = fopen("/Users/sethsnyder/Desktop/NYSENATE/DISQUS/XML-EXTRACT-TNG/links_for_empty_identifiers.csv","w");

foreach ($xml->thread as $thread) {

// Split it out and write it tothe appropriateoutput stream.
process_thread($thread, $node_slash_nid_style_identifiers, $other_style_identifiers, $links_for_empty_identifiers);
//fputcsv($file,$fields);

$count_of_threads++;

//if ($count_of_threads == 100)
// break;
}

fclose($node_slash_nid_style_identifiers);
fclose($other_style_identifiers);
fclose($links_for_empty_identifiers);

print "\r\n\r\nNumber of threads processed = $count_of_threads \r\n";

print 'done';


function process_thread($thread, $node_slash_nid_style_identifiers, $other_style_identifiers, $links_for_empty_identifiers) {
// Get the thee identifier
$thread_identifier = $thread->id->__toString();

if (empty($thread_identifier) == TRUE) {
// Empty Identifier.
$thread_link = $thread->link->__toString();
fputcsv($links_for_empty_identifiers, array($thread_link));

}
else {
// Non empty identifier.
// if node/nnnnn style
if (strncmp($thread_identifier, 'node/', 5 ) == 0) {
$thread_identifier_array = explode ('/', $thread_identifier);
if (count($thread_identifier_array) == 2) {
$node_id = $thread_identifier_array[1];
fputcsv($node_slash_nid_style_identifiers, array($node_id));
}
}
else {
// A link or some other style identifier.
fputcsv($other_style_identifiers, array($thread_identifier));
}

}

}
Binary file added disqus-tools/nys_disqus_processor/.DS_Store
Binary file not shown.
74 changes: 74 additions & 0 deletions disqus-tools/nys_disqus_processor/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
NYS DISQUS PROCESSOR DSQUS DRUSH COMMANDS
---------------------------------------------------------------------
load-token
Unused

---------------------------------------------------------------------
get-token
Returns the disqus token

---------------------------------------------------------------------
get-thread (ThreadID | Thread Identifier | Thread Link)
Gets the data about a thread.
Argument 1:
You can pass in a numeric ThreadID
You can pass in an alphanumeric identifier
You can pass in a Thread Link

Argument 2
Nothing for a numeric ThreadID
Nothing for an alphanumeric identifier
`ident` for a numeric identifier
`link` for a link.

---------------------------------------------------------------------
update-thread-id (ThreadId, New Thread Identifier)
Updates the threads Identifier.

Argument 1:
You can pass in a numeric ThreadID.

Argument 2
You pass in the new thread identifier.

---------------------------------------------------------------------
update-thread-link (ThreadId, New Thread Link)
Updates the threads Link.

Argument 1:
You can pass in a numeric ThreadID.

Argument 2
You pass in the new Thread Link.

---------------------------------------------------------------------
survey-threads (Input Table Name)
Surveys the threads in an input table.
Input tables are loaded from disqus export files
using the process_disqus_export_file.php script.

---------------------------------------------------------------------
remove-thread (ThreadId)
Removes a thread
This Disqus API call does not seem to actually work as advertised.

Argument 1:
You can pass in a numeric ThreadID.

---------------------------------------------------------------------
get-posts (ThreadId)
Gets the posts for a thread.
One of the items returned is the Post ID.

Argument 1:
You can pass in a numeric ThreadID.

---------------------------------------------------------------------
get-post (PostId)
Gets the data for a post.

Argument 1:
You can pass in a numeric PostID.

---------------------------------------------------------------------

Loading