ReadSpeaker recommend self-hosting their Javascript library if on HTTPS. Attempting to serve it via their servers results in a mismatched certificate error due to their CDN. This patch forces you to self-host if on HTTPS.

Also, for HTTP, the region the embed is served from is hardcoded to be 'eu'. This patch adds a region selector that lets you choose from ReadSpeakers North American, European or Asia-Pacific servers.

Unfortunately, this patch requires the changes from #2308749: Move block settings variables to admin settings page.

Comments

killua99’s picture

Status: Needs review » Needs work

Need to see this patch in live.

I'll test it asap

killua99’s picture

Category: Bug report » Task
+++ b/open_readspeaker.module
@@ -51,6 +54,22 @@ function open_readspeaker_theme($existing, $type, $theme, $path) {
+    'version callback' => '_open_readspeaker_shortcircuit_version',

@@ -123,15 +167,24 @@ function theme_open_readspeaker_ui() {
+function _open_readspeaker_shortcircuit_version() {
+  return TRUE;
+}

You're calling this function because you want me to add the real logic about version?

  1. +++ b/open_readspeaker.module
    @@ -85,17 +104,33 @@ function open_readspeaker_block_view($delta = '') {
    +  if ($use_https) {
    +    $library = libraries_detect('readspeaker');
    

    What happen when is FALSE?

  2. +++ b/open_readspeaker.module
    @@ -111,11 +146,20 @@ function theme_open_readspeaker_ui() {
    +    $embed_url = str_replace(array(
    ...
    +      variable_get('open_readspeaker_region', OPEN_READSPEAKER_DEFAULT_REGION),
    ...
    +      variable_get('open_readspeaker_customparam', ''),
    

    I like more use preg_replace but is ok. And why you don't declare those variables?

  3. +++ b/open_readspeaker.module
    @@ -123,15 +167,24 @@ function theme_open_readspeaker_ui() {
    +  $output .= '<a rel="nofollow" class="rsbtn_play" title="' . t('Listen to this page using ReadSpeaker') . '" accesskey="L" href="' . $protocol . '://app.readspeaker.com/cgi-bin/rsent?customerid=' . $accountid . '&amp;lang=' . $open_readspeaker_i18n . '&amp;readid=' . $read_id . '&amp;url=' . urlencode($request_path) . '">';
    

    Maybe could be a better idea use the l function instead the HTML markup I'm thinking about that.

This need some small fix. You can work this patch without the "block settings patch" I still don't see the real point to move those settings. When I create this module for the web page that implement this like this way keep with other permission those settings, away for the Site Builder.

torpy’s picture

Hey, answers below:

1. I'm using a short-circuit version callback because we can't depend on a particular ReadSpeaker library version. At the moment, the Libraries API doesn't let you specify external libraries without an explicit version or callback.
2. I'm not sure what you mean? The variables are set on the admin form.
3. Good point. It might be better to pull this out into a template too.

crystaldawn’s picture

There are two things you need to change in your implementation:
To get SSL working for this module we had to do the following to the module itself:

1. In the script link to the ReadSpeaker.js file, you should change "f1.eu" to "f1-eu".

This is how the link looks like today:

This is how the link should look like:

2. In the listen button, you should change "app.eu" to "app-eu".

This is how the link in the listen button starts today:
"href="https://app.eu.readspeaker.com...."

This is how the link should look like:
"href="https://app-eu.readspeaker.com...."

eduardo morales alberti’s picture

Rerroll patch with the changes that say @crystaldaw.

eduardo morales alberti’s picture

Status: Needs work » Needs review

Update status.

eduardo morales alberti’s picture

eduardo morales alberti’s picture

StatusFileSize
new5.7 KB
new5.57 KB

Rerroll patch, we do not need local library when is https.

leandro713’s picture

StatusFileSize
new6.19 KB

implement a protocol relative url

leandro713’s picture

StatusFileSize
new3.01 KB

i attach interdiff for #9