pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
pycross.utils.onlineservices.Share Class Reference

Interface class for the Shareaholic service. More...

Public Member Functions

def __init__ (self, Cloudstorage cloud, on_upload=None, on_clipboard_write=None, on_prepare_url=None, stop_check=None, timeout=5000)
 
def share (self, file_or_url, social='twitter', title='My new crossword', notes=_('See my new crossword'), url_shortener='shrlc', tags='pycrossword, crossword, python', source='pycrossword')
 Shares a given URL or file in selected social networks. More...
 

Public Attributes

 on_upload
 callable function called when a file is uploaded More...
 
 on_clipboard_write
 callable callback called when data is written to the system clipboard (as one sharing option) More...
 
 on_prepare_url
 callable callback called when the request URL to Shareaholic is prepared More...
 
 stop_check
 callable callback that takes no arguments and returns True to stop the current sharing operation or False to continue More...
 
 timeout
 int network request timeout (in msec) More...
 
 cloud
 Cloudstorage pointer to the Cloudstorage object More...
 

Static Public Attributes

string APPID = 'abf1b67f10817416ba9fee9b76455bef'
 ID of pycrossword app on Shareaholic. More...
 
string BASEURL = 'https://www.shareaholic.com/api/share/?v=1&apitype=1'
 base URL for Shareaholic API requests More...
 
dictionary ERRMAP = {'message': 'data', 'code': 'code'}
 error message key map More...
 
dictionary SERVICES
 enabled social networks and their Shareaholic internal numbers More...
 

Detailed Description

Interface class for the Shareaholic service.

The application has a free account on Shareaholic to enable social sharing, i.e. posting text / URLs to your Twitter, Facebook and other social networks.

See also
Shareaholic Share API docs

Constructor & Destructor Documentation

◆ __init__()

def pycross.utils.onlineservices.Share.__init__ (   self,
Cloudstorage  cloud,
  on_upload = None,
  on_clipboard_write = None,
  on_prepare_url = None,
  stop_check = None,
  timeout = 5000 
)
Parameters
cloudCloudstorage pointer to a Cloudstorage object
on_uploadcallable function called when a file is uploaded to the cloud storage; takes to args:
  1. str full path to the uploaded file
  2. str generated public link (URL)
on_clipboard_writecallable callback called when data is written to the system clipboard (as one sharing option); takes one arg: str generated public link (URL)
on_prepare_urlcallable callback called when the request URL to Shareaholic is prepared; takes one arg: str the request URL
stop_checkcallable callback that takes no arguments and returns True to stop the current sharing operation or False to continue
timeoutint network request timeout (in msec)

Member Function Documentation

◆ share()

def pycross.utils.onlineservices.Share.share (   self,
  file_or_url,
  social = 'twitter',
  title = 'My new crossword',
  notes = _('See my new crossword'),
  url_shortener = 'shrlc',
  tags = 'pycrossword,crossword,python',
  source = 'pycrossword' 
)

Shares a given URL or file in selected social networks.

This method is the main interface for the application, since it encapsulates the lower-level cloud storage functionality to upload files and create public links.

Warning
This method is called in a separate thread, so it is designed for maximum thread safety. That is also the reason why it doesn't return any results but rather replies on callback functions.
Parameters
file_or_urlstr full path to a local file or a prepared link (URL)
socialstr social network short name, e.g. 'twitter' – see Share::SERVICES
titlestr title (caption) for your post
notesstr message body for your post
url_shortenerstr URL shortening service to shorten your link URL; see Shareaholic docs for available options
tagsstr comma-separated tags for your post
sourcestr name of the sharing app ('pycrossword')

Member Data Documentation

◆ APPID

string pycross.utils.onlineservices.Share.APPID = 'abf1b67f10817416ba9fee9b76455bef'
static

ID of pycrossword app on Shareaholic.

◆ BASEURL

string pycross.utils.onlineservices.Share.BASEURL = 'https://www.shareaholic.com/api/share/?v=1&apitype=1'
static

base URL for Shareaholic API requests

◆ cloud

pycross.utils.onlineservices.Share.cloud

Cloudstorage pointer to the Cloudstorage object

◆ ERRMAP

dictionary pycross.utils.onlineservices.Share.ERRMAP = {'message': 'data', 'code': 'code'}
static

error message key map

◆ on_clipboard_write

pycross.utils.onlineservices.Share.on_clipboard_write

callable callback called when data is written to the system clipboard (as one sharing option)

◆ on_prepare_url

pycross.utils.onlineservices.Share.on_prepare_url

callable callback called when the request URL to Shareaholic is prepared

◆ on_upload

pycross.utils.onlineservices.Share.on_upload

callable function called when a file is uploaded

◆ SERVICES

dictionary pycross.utils.onlineservices.Share.SERVICES
static
Initial value:
= {'twitter': 7, 'facebook': 5, 'pinterest': 309, 'linkedin': 88, 'gmail': 52,
'yahoomail': 54, 'aolmail': 55, 'hotmail': 53, 'myspace': 39,
'reddit': 40, 'skype': 989, 'tumblr': 78, 'yandex': 267, 'clipboard': 0}

enabled social networks and their Shareaholic internal numbers

◆ stop_check

pycross.utils.onlineservices.Share.stop_check

callable callback that takes no arguments and returns True to stop the current sharing operation or False to continue

◆ timeout

pycross.utils.onlineservices.Share.timeout

int network request timeout (in msec)


The documentation for this class was generated from the following file: