Ways to split longer WordPress posts

These are ways to make longer posts easier to digest for readers. They are ways to split longer posts to keep readers engaged.

The Daily Post

We often think that our attention spans have grown shorter with the onslaught of digital media, but in fact longform writing — on WordPress.com and beyond — is alive and well. It’s sometimes challenging, however, to display longer pieces in a way that keeps your readers engaged.

If you’re looking for tips on presenting your latest longform creation, this post from last year, by Daily Post contributor Elizabeth, will introduce you to some nifty features built into your site. Whether you’re working on a meaty piece of prose for Blogging U.’s Writing 201 course, or just often have a lot to say, you should try these out.

Today, we’ll cover three features that can help you break up and organize longer posts, so that they display more cleanly and are easier for your readers to digest. We hope these tips come in handy!

Pagination

Longform posts are…

View original post 697 more words

web2py TO WordPress API with OAuth2

web2py TO WordPress API with OAuth2

This is an example of a web2py app using the WordPress.com REST API with OAuth2.

You need to go to developer.WordPress.com to setup your app.

N.B. I tested this on my website, however, if I messed up with writing this article, please let me know in the comments.

I found some hints on github Automattic

Love and peace,

Joe

controllers

default.py

import datetime, random, string
import urllib, urllib2
import requests

# TODO: Replace these globals with your own.
HOST      = 'yoursite.com'        # REGISTER with developer.wordpress.com
APPNAME   = 'yourappname'         # REGISTER with developer.wordpress.com
CLIENT_SECRET = 'BIG.LONG.STRING' # GET FROM developer.wordpress.com
CLIENT_ID = '12345'               # GET FROM developer.wordpress.com


def authorize_blog():
    """
    Initiates retrieval of OAuth2 credentials which 
        allows your user to aurhorize her blog for use by your app.   
    Generates an HTML page containing a WordPress Authorize button which 
        holds a redirect_uri callback to your app.
    When your user presses this button, she is sent to WordPress.com, where,
        IF she AUTHORIZES one of her blogs:
            WordPress.com will send OAuth2 credentials to YOUR callback URL.   
    see: http://developer.wordpress.com/docs/oauth2/            
    """

    # see [OAuth2 state Article on stackoverflow] (http://stackoverflow.com/questions/11071482/oauth2-0-server-stack-how-to-use-state-to-prevent-csrf-for-draft2-0-v20)
    state = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(30))
    state = str(datetime.datetime.now()).replace(':', '.').replace(' ', '') + '_' + state
    session.state = state


    params = {
        "response_type": "code",
        "client_id": CLIENT_ID,
        "redirect_uri": URL(f='connected', scheme='http', host=HOST, url_encode=False),
        "state": state,
    }

    authorize_url_0 = URL(a='oauth2', c='authorize', f='', vars=params, scheme='https', host='public-api.wordpress.com', url_encode=False)

    # The web2py URL function inserts an (in this case) UNNEEDED reference to the current web2py app.
    #     This string function gets rid of that reference. 
    authorize_url =  authorize_url_0.replace(APPNAME+'/', '',1)

    thehtml = XML(
        '<html><body><h2>Connect FROM YourWebsite.com TO WordPress.com</h2><a href="' +
        authorize_url +
        '"><img src="//s0.wp.com/i/wpcc-button.png" width="231" /></a></body></html>'
    ).xml()

    return thehtml

def connected():
    """
    1. Receive request.vars.code == a "time-limited code that your application can exchange for a full authorization token."
    see: http://developer.wordpress.com/docs/oauth2/   
        This is a time-limited code that your application can exchange for a full authorization token. 
        To do this you will need to pass the code to the token endpoint by making a POST request to the token endpoint: 
            You are required to pass 
                client_id, 
                client_secret, and 
                redirect_uri for web applications. 
                    These parameters have to match the details for your application, and 
                        the redirect_uri must match the redirect_uri used during the Authorize step (above). 
                grant_type has to be set to "authorization_code".   
    2. Convert time-limited code into  OAuth2 full authorization credentials.
        [NOT SHOWN: how to store credentials in db]    
    3. For demo purposes, list the blog with the credentials.    
    """

    # 1. Receive request.vars.code
    code = request.vars.code   # returned from WordPress.com
    if not code:
        redirect(URL('index'))

    # see [OAuth2 state Article on stackoverflow] (http://stackoverflow.com/questions/11071482/oauth2-0-server-stack-how-to-use-state-to-prevent-csrf-for-draft2-0-v20)    
    state = request.vars.state
    if not state:
        return dict(message='Warning! State variable missing after authorization.')

    if (not session.state):
        return dict(message='Warning! No session.atate! WHY NOT??? variable missing after authorization.')

    if state != session.state:
        return dict(message='Warning! State mismatch. Authorization attempt may have been compromised. This: ' + state + ' should be: ' + session.state)


    # 2. Convert time-limited code
    # TODO: Replace values client_id, client_secret with YOUR's, previously received from dev.WordPress.com setup.
    payload = { 'client_id': CLIENT_ID, 
                'client_secret': CLIENT_SECRET,
                'redirect_uri': 'http://'+HOST+'/'+APPNAME+'/default/connected',
                'grant_type': 'authorization_code',
                'code': request.vars.code,
    }

    # Call the token endpoint
    rsp_token_request = requests.post("https://public-api.wordpress.com/oauth2/token", data=payload)

    # 'Response [200]' means SUCCESS
    if not 'Response [200]' in str(rsp_token_request):     
        return dict(message='Problem! "Response [200]" not in response!')

    jsonDict     = rsp_token_request.json()

    access_token = jsonDict['access_token']
    blog_id      = jsonDict['blog_id']
    blog_url     = jsonDict['blog_url']

    # TODO: [NO SHOWN] Store access_token, blog_id, blog_url in the db for further use.   

    # For demo purposes, we will use these credentials here, to list this blog.
    base_url = 'https://public-api.wordpress.com/rest/v1/sites/' + blog_id
    payload = {}
    payload['http_envelope'] = 'true'
    url_values = urllib.urlencode(payload)
    full_url = base_url + '?' + url_values
    req = urllib2.Request(full_url)   
    req.add_header('Authorization', 'Bearer ' + access_token)
    rsp = urllib2.urlopen(full_url)
    the_info_page = rsp.read()

    m = ''    
    m += "the_info_page = %s||"%(the_info_page)

    content = BEAUTIFY(m.split('||'))   

    return dict(content=content)     

models

I omit model code in this article, assuming you can store your credentials for further use. If you needd assistance, contact me by a comment.

views/default

connected.html

{{left_sidebar_enabled,right_sidebar_enabled=False,False}}
{{extend 'layout.html'}}

{{if 'message' in globals():}}
<h3>{{=message}}</h3>
{{elif 'content' in globals():}}
{{=content}}

{{pass}}

My WordPress Markdown

WordPress Markdown Links

  1. WordPress.com’s Markdown Extra and Markdown on WordPress.com
  2. WordPress.com’s Writing & Editing Markdown quick reference
  3. WordPress.com’s Slightly Modified Markdown Version is Markdown Extra
  4. Markdown Syntax
  5. WordPress.com’s Posting Source Code
  6. My Posting Source Code on WordPress
  7. WordPress.com’s Writing & Editing Markdown
  8. Write (More) Effortlessly With Markdown by Matt Wiebe
  9. N.B. Can’t upload zip files into free hosted WordPress.com blogs.
  10. Change a Post’s Date

My Markdown

## Source Code i am confused 
re NOT html encodding quotes and angle brackets 
sometimes backticks work 
sometimes shortcodes work
see this post below & 
https://joecodeswell.wordpress.com/2016/12/03/python-code-creates-a-database-from-csv/

both SOMETIMES work & SOMETIMES FAIL
3 backticks(quotes and angle brackets get html encoded)
backtick backtick backtick python
if a < 'B': print("happy")
BLA BLA BLA
backtick backtick backtick


USE A SHORTCODE

if a < 'B': print("happy")
BLA BLA BLA
[/code ]

## Publishing Rules

- I'll use "- " Item     for UNordered lists
- I'll use "1. " Item    for Orderded lists
- I'll use Definition Lists:

Apple
:   Pomaceous fruit of plants of the genus Malus in 
    the family Rosaceae.

Orange
:   The fruit of an evergreen tree of the genus Citrus.

- **In all source code Markdown**, I'll replace "" with "", because "" DISAPPEARS when MD is rendered
- I’ll publish in the Text Editor NOT the Visual Editor
- For Main Headings: Header 2 == ## SPACE Item
- For Links I'll use [Kathleen Battle](http://en.wikipedia.org/wiki/Kathleen_Battle "Kathleen Battle")
- For Anchored Main Headings: ## SPACE Item { # item}    N.B. "}" must be at EOL.
- For Links to Anchors: [Item ](# item)
- For Sub Headings: Bold == **Item**

To add an image
:    I'll place the cursor in the Text Tab and click on the Add Media Button way at the top of the edit page.

For posting code
:    I'll choose from these code types: actionscript3, bash, clojure, coldfusion, cpp, csharp, css, delphi, erlang, fsharp, diff, groovy, html, javascript, java, javafx, matlab (keywords only), objc, perl, php, text, powershell, python, r, ruby, scala, sql, vb, xml .


Code under a Numbered List Item
:    See Example Below:

Get started with PySparkling Steps 

1. Download Spark
  1.1 DONE
2. Point SPARK_HOME to the existing installation of Spark and export variable MASTER.

    backtick backtick backtick bash
    >echo %SPARK_HOME%
    ...\Downloads\ApacheSpark\spark-1.6.2-bin-hadoop2.6

    >echo %MASTER%
    local-cluster[3,2,1024]

    >
    backtick backtick backtick

3. 


Block Quote

> Nice post and great question Joe.

> Spot checking is to discover which algorithms look good on one given dataset. Not across datasets.

> You may need to group algorithms by their expectations then prepare data for each group.

> Most machine learning algorithms expect data to have numeric input values and an integer encoded or one hot encoded output value for classification. This is a good normalized view of a dataset to construct.

> Here’s a tutorial that shows how to spot check 7 machine learning algorithms on one problem in Python, [Spot-Check Regression Machine Learning Algorithms in Python with scikit-learn](http://machinelearningmastery.com/spot-check-regression-machine-learning-algorithms-python-scikit-learn/).

Let’s see how the above renders

Source Code

backticks

if a < 'B': print("happy")
BLA BLA BLA

shortcode

if a echo %SPARK_HOME%
…\Downloads\ApacheSpark\spark-1.6.2-bin-hadoop2.6

&gt;echo %MASTER%
local-cluster[3,2,1024]

&gt;
```
  1. Item Three

Block Quote

Nice post and great question Joe.

Spot checking is to discover which algorithms look good on one given dataset. Not across datasets.

You may need to group algorithms by their expectations then prepare data for each group.

Most machine learning algorithms expect data to have numeric input values and an integer encoded or one hot encoded output value for classification. This is a good normalized view of a dataset to construct.

Here’s a tutorial that shows how to spot check 7 machine learning algorithms on one problem in Python, Spot-Check Regression Machine Learning Algorithms in Python with scikit-learn.

WordPress for Programmers & My New Theme

Overall

WordPress for Programmers & Coders: Advice, Themes & Plugins.

Themes

google:  best free wordpress themes for programmer

webdesignerdepot

Now I use: “Silver is the New Black” – Silver is the New Black. Howdy! This theme, Silver is the New Black, is now retired.

I am going to try these until i get one i like. But first

google how to backup my wordpress.com blog

I am now doing Download your content

I Choose the New Theme

[copied from my notes in MS Word]:

webdesignerdepot

·         OneColumn

·         White Paper

·         WP Jurist

·         Best Theme

None of the above show up for free in wordpress.com

I try

·        TRVL – it’s OK [too dark, nice and wide & big]

·        Truly Minimal – seems better than TRVL – I like it – my pic shows up – Python Notes page might be a bit goofy ala code – kind of OK

·        Ryu – TOO BIG – NO MAYBE

·        Superhero – not bad – goofy black bar follows down NG!– Truly Minimal is better

·        Responsive – Feature-full theme with numerous page layouts, widget areas, custom menu areas, breadcrumb naviagtion, a homepage template, social icons, and responsive CSS. PRETTY GOOD

·        Forever – I am using this in the web2py book – not for here

·        White as Milk – NO GOOD

·        Sapphire – bad paragraph spacing like my present theme

·

between Responsive & Truly Minimal

Responsive – looks confused with my formatting

Truly Minimal – looks less confused with my formatting

I choose Truly Minimal

Result – Better than a jab in the eye with a sharp stick. The pages aren’t compact enough top to bottom.

Posting Source Code on WordPress

backtick backtick backtick python
def example_func():
 """This is an example_func inside
 backtick backtick backtick python
 l_squareBracket /code r_squareBracket
 language can = "python" or "html" or ???
 """
 pass
backtick backtick backtick

See also