Plugin Directory

Changeset 833514


Ignore:
Timestamp:
01/05/2014 09:55:05 PM (12 years ago)
Author:
misterbisson
Message:

initial release of version 6. This is a breaking change from previous versions, but it's the virst time bStat has worked as a standalone plugin since 2005 or so. See the readme https://github.com/misterbisson/bstat/blob/master/readme.txt and the notes in the pull request https://github.com/misterbisson/bstat/pull/1 for more.

Location:
bstats/trunk
Files:
192 added
9 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • bstats/trunk

    • Property svn:ignore set to
      README.md
      .git
      .gitignore
      .gitmodules
      deploy/
  • bstats/trunk/bstat.php

    r531474 r833514  
    22/*
    33Plugin Name: bStat
    4 Plugin URI: http://maisonbisson.com/bsuite/
    5 Description: Stats!
    6 Version: 5.0
     4Plugin URI: http://maisonbisson.com/
     5Description: Blog stats and activity stream
     6Version: 6.0 alpha development
    77Author: Casey Bisson
    88Author URI: http://maisonbisson.com/blog/
    99*/
    10 /*
    11 // get options
    12 $bsoptions = get_option('bstat-options');
    1310
    14 // insert default options if the options array is empty
    15 if( empty( $bsoptions ))
    16 {
    17     $bsoptions = array(
    18         'open-graph' => 1,
    19         'featured-comments' => 1,
    20         'twitter-api' => 1,
    21         'twitter-comments' => 1,
    22         'twitter-app_id' => '',
    23         'facebook-api' => 1,
    24         'facebook-add_button' => 1,
    25         'facebook-comments' => 0,
    26         'facebook-admins' => '',
    27         'facebook-app_id' => '',
    28         'facebook-secret' => '',
    29     );
     11require_once __DIR__ . '/components/class-bstat.php';
     12bstat();
    3013
    31     update_option( 'bstat-options' , $bsoptions );
    32 }
     14register_activation_hook( __FILE__, array( bstat(), 'initial_setup' ) );
    3315
    34 // the admin menu
    35 if ( is_admin() )
    36     require_once dirname( __FILE__ ) . '/admin.php';
    37 */
    3816
    39 // Better describe your content to social sites
    40 require_once( dirname( __FILE__ ) .'/components/daemon.php' );
    41 $bstat_daemon = new bStat_Daemon;
    42 require_once( dirname( __FILE__ ) .'/components/behavior.php' );
    43 $bstat_behaviors = new bStat_Behaviors;
     17// comment tracking is kept separate as an example of how to build other integrations
     18require_once __DIR__ . '/components/class-bstat-comments.php';
     19bstat_comments();
  • bstats/trunk/components/js/bstat.js

    r531474 r833514  
    1 /********************************************
    2 bsuite._e
    3     escape strings
    4 -------------------------------
    5 bsuite._void
    6     generic return
    7 -------------------------------
    8 bsuite.$
    9     document.getElementById
    10 -------------------------------
    11 bsuite.fd
    12     fix domain
    13 -------------------------------
    14 bsuite.gb
    15     get browser data
    16 -------------------------------
    17 bsuite.img
    18     creates an img to make the log call
    19 -------------------------------
    20 bsuite.log
    21     a.k.a. do log.  sets a cookie and begins the log
    22 -------------------------------
     1(function($){
    232
    24 URI Variable Info:
    25 [misc data]
    26     api_key = site's api key
    27     api_sig = site's api sig
     3    // don't bother if the endpoint isn't defined
     4    if ( ! ('endpoint' in bstat) ) {
     5        return;
     6    }
    287
    29 [browser data] (prepended with the letter b)
    30     r = resolution
    31     b = bit depth
    32     l = language
    33     c = charset
     8    var bstat_t = {};
    349
    35 [page data] (prepended with the letter p)
    36     d = domain
    37     h = host
    38     r = referrer
    39     t = title
    40     u = uri
    41     n = Math.round(Math.random()*2147483647);
    42 ********************************************/
     10    // Track normal link click events a
     11    bstat_t.link_click = function( event ) {
    4312
    44 var bsuite={
    45     'id':'b-i-fr',
    46     'api_location':'',
    47     'api_key':'073ccf57bf2dc2a7ba98d51e2ec7cb7e',
    48     'api_sig':'',
    49     'doc':document,
    50     'url':document.location,
    51     '$':function(i){return document.getElementById(i);},
    52     '_e':function(s,u){
    53          if (typeof(encodeURIComponent)=='function'){
    54             if (u) return encodeURI(s);
    55             else return encodeURIComponent(s);
    56          }else{return escape(s);}
    57     },
    58     '_void':function(){return;},
    59     'fd':function(d){
    60         if (d.substring(0,4)=="www.") d=d.substring(4,d.length);
    61         return d;
    62     },
    63     'gb':function(){
    64 /********************************************
    65 [browser data] (prepended with the letter b)
    66     r = resolution
    67     b = bit depth
    68     l = language
    69     c = charset
    70 ********************************************/
    71         var b='-',c='-',l='-',r='-';
    72         var n=navigator;
    73         //grab browser language
    74         if(n.language) l=n.language.toLowerCase();
    75         else if (n.browserLanguage) l=n.browserLanguage.toLowerCase();
    76         //grab charset
    77         if (this.doc.characterSet) cs=this._e(this.doc.characterSet);
    78         else if (this.doc.charset) cs=this._e(this.doc.charset);
    79         //grab screen resolution
    80         if(self.screen)
    81         {
    82             r=screen.width+'x'+screen.height;
    83             b=screen.colorDepth+'-bit';
    84         }
    85         else if(self.java)
    86         {
    87             var j=java.awt.Toolkit.getDefaultToolkit();
    88             var s=j.getScreenSize();
    89             sr=s.width+"x"+s.height;
     13        // info is: nearest ID of the element that link is in, nearest ID of the widget that link is in, the link text
     14        var the_info = $(event.target).closest( '[id]' ).attr('id') + "|" + $(event.target).closest( '.widget' ).attr( 'id' ) + "|" + ( $(event.target).text() || $(event.target).children( 'img:first' ).attr( 'alt' ) );
     15
     16        // post it
     17        $.ajax({
     18            type : "POST",
     19            url : bstat.endpoint,
     20            dataType : 'jsonp',
     21            data : {
     22                "bstat[post]" : bstat.post,
     23                "bstat[blog]" : bstat.blog,
     24                "bstat[signature]" : bstat.signature,
     25                "bstat[component]" : "bstat",
     26                "bstat[action]" : "clklink",
     27                "bstat[info]" : the_info
     28            }
     29        });
     30    }
     31
     32    // @TODO: add tracking for clicks within forms
     33    // ...also maybe track progress through the form
     34
     35    // track the page view
     36    // @TODO: should I make a wrapper for the ajax call?
     37    $.ajax({
     38        type : "POST",
     39        url : bstat.endpoint,
     40        dataType : 'jsonp',
     41        data : {
     42            "bstat[post]" : bstat.post,
     43            "bstat[blog]" : bstat.blog,
     44            "bstat[signature]" : bstat.signature,
     45            "bstat[component]" : "bstat",
     46            "bstat[action]" : "pageview"
    9047        }
    91         return '&bb='+b+'&bc='+c+'&bl='+l+'&br='+r;
    92     },
    93     'img':function(){
    94         var args=arguments;
    95         if(this.$(this.id)){}
    96         else if(this.api_key!='')
    97         {
    98             //this.c();
    99 /********************************************
    100 [page data] (prepended with the letter p)
    101     d = domain
    102     h = host
    103     r = referrer
    104     t = title
    105     u = uri
    106     n = Math.round(Math.random()*2147483647);
    107 ********************************************/
    108             var src = this.api_location;
    109             //generate a random number to prevent caching
    110             var n = Math.round(Math.random()*2147483647);
    111             //set up the querystring
    112             src+='?bsuite_hit='+n;
    113             //grab referrer.  if there is none, set to -
    114             var ref=this.doc.referrer;
    115             if(!ref || ref=="") ref='-';
    116             src+='&pr='+this._e(ref);
    117             //tack on browser info
    118             src+=this.gb();
    119             //build image
    120             var script = document.createElement('script');
    121             script.src = src;
    122             script.type = 'text/javascript';
    123             script.defer = true;
    124             var head = document.getElementsByTagName('head').item(0);
    125             head.appendChild(script);
    126 /*
    127             var i=new Image(1,1);
    128             i.src=src;
     48    });
    12949
    130             i.onload=function(){return;};
    131 */
    132         }
    133     },
    134     'log':function(){var args=arguments;if(args[0]){this.img(args[0]);}else{this.img();}}
    135 };
     50    $( document ).on( 'click', 'a', bstat_t.link_click );
    13651
    137 bsuite.api_location = bstat['api_endpoint'];
    138 bsuite.log();
    139 
    140 
    141 /*
    142 ** the search word highlighting callback
    143 */
    144 function bsuite_highlight( words ) {
    145     if( bstat['highlight'] ) {
    146         jQuery('.hentry').each( function() {
    147             for( var i in words.terms ) {
    148                 jQuery.highlight(this, words.terms[i].toUpperCase() );
    149             }
    150         } );
    151     }
    152 }
     52})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.