Problem/Motivation

We currently are completely dependent on addthis.
The general abstraction of Sharemessage is vendor independent.

This is a lock-in and addthis has multiple disadvantages such as their markup does not validate as HTML5 (causing validation W3C validation / certification issues).
Also, customizing the appearance is very limited.

Proposed resolution

We could integrate with a different sharing gateway service or directly integrate a local sharing script.

One option is this script:
http://sharrre.com/

Remaining tasks

* More research about addthis alternatives (services) and create list / tickets
* More research about alternative scripts

User interface changes

@todo

API changes

@todo

CommentFileSizeAuthor
#37 new_plugin_sharrre_com-2165561-37-interdiff.txt9.21 KBsasanikolic
#37 new_plugin_sharrre_com-2165561-37.patch29.59 KBsasanikolic
#35 new_plugin_sharrre_com-2165561-35-interdiff.txt4.99 KBsasanikolic
#35 new_plugin_sharrre_com-2165561-35.patch29.86 KBsasanikolic
#34 new_plugin_sharrre_com-2165561-34-interdiff.txt10.44 KBsasanikolic
#34 new_plugin_sharrre_com-2165561-34.patch30.37 KBsasanikolic
#31 new_plugin_sharrre_com-2165561-31-interdiff.txt11.23 KBsasanikolic
#31 new_plugin_sharrre_com-2165561-31.patch28.09 KBsasanikolic
#29 new_plugin_sharrre_com-2165561-29-interdiff.txt21.49 KBsasanikolic
#29 new_plugin_sharrre_com-2165561-29.patch22.52 KBsasanikolic
#26 new_plugin_sharrre_com-2165561-26-interdiff.txt9.72 KBsasanikolic
#26 new_plugin_sharrre_com-2165561-26.patch39.71 KBsasanikolic
#22 new_plugin_sharrre_com-2165561-22-interdiff.txt469 bytessasanikolic
#22 new_plugin_sharrre_com-2165561-22.patch36.17 KBsasanikolic
#20 new_plugin_sharrre_com-2165561-20-interdiff.txt2.2 KBsasanikolic
#20 new_plugin_sharrre_com-2165561-20.patch35.71 KBsasanikolic
#16 new_plugin_sharrre_com-2165561-15-combined-interdiff.txt4.96 KBsasanikolic
#16 new_plugin_sharrre_com-2165561-15-combined.patch35.78 KBsasanikolic
#16 open-graph-headers-no-test.patch4.96 KBsasanikolic
#12 new_plugin_sharrre_com-2165561-12-interdiff.txt11.56 KBsasanikolic
#12 new_plugin_sharrre_com-2165561-12.patch30.82 KBsasanikolic
#9 new_plugin_sharrre_com-2165561-9.patch30.58 KBsasanikolic
#9 new_plugin_sharrre_com-2165561-9-interdiff.txt46.61 KBsasanikolic
#7 new_plugin_sharrre_com-2165561-7.patch30.58 KBsasanikolic
#7 new_plugin_sharrre_com-2165561-7-interdiff.txt46.61 KBsasanikolic
#4 new_plugin_sharrre_com-2165561-4.patch44.4 KBsasanikolic

Comments

miro_dietiker’s picture

Now that ShareMessage is short before getting pluggable, i'm excited to see this happen soon! :-)

sasanikolic’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
miro_dietiker’s picture

Title: Alternative sharing service provider / local script like sharrre.com » New plugin: sharrre.com
Component: Code » Plugins
sasanikolic’s picture

Status: Active » Needs review
StatusFileSize
new44.4 KB

Here is the first step.

Things to do next:

  • Review
  • Discuss and check the styling (extend/fix JS)
  • Write tests
  • Clean up the code
  • In the followup - extend sharrre plugin for the option urlCurl -> PHP script for Google Plus, Stumbleupon, Pinterest

Status: Needs review » Needs work

The last submitted patch, 4: new_plugin_sharrre_com-2165561-4.patch, failed testing.

miro_dietiker’s picture

  1. +++ b/config/install/sharemessage.sharrre.yml
    @@ -0,0 +1,5 @@
    +services: {  }
    

    We should enable some default services.

  2. +++ b/config/schema/sharemessage.schema.yml
    @@ -67,9 +89,6 @@ sharemessage.sharemessage.*:
    -    enforce_usage:
    

    Didn't properly rebase?

  3. +++ b/css/sharemessage.sharrre.css
    @@ -0,0 +1,50 @@
    diff --git a/js/jquery.sharrre.js b/js/jquery.sharrre.js
    

    Is there no minified version?

  4. +++ b/src/Form/AddthisSettingsForm.php
    @@ -125,7 +125,6 @@ class AddthisSettingsForm extends ConfigFormBase {
    -      ->set('message_enforcement', $form_state->getValue('message_enforcement'))
    

    Anothr revert?

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new46.61 KB
new30.58 KB

Rename settings, added the min js, fixed tests (rebasing) etc.

More things to do:
- clear cache after saving plugin settings ( ->invalidateTags(['rendered']))
- define the default styling and custom styling
- fix the default styling

Status: Needs review » Needs work

The last submitted patch, 7: new_plugin_sharrre_com-2165561-7.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new46.61 KB
new30.58 KB

Hmm, strange, tests are passing for me locally. I will retry uploading the new patch again.

Status: Needs review » Needs work

The last submitted patch, 9: new_plugin_sharrre_com-2165561-9.patch, failed testing.

miro_dietiker’s picture

  1. +++ b/config/install/sharemessage.sharrre.yml
    @@ -0,0 +1,8 @@
    +shorterTotal: true
    
    +++ b/config/schema/sharemessage.schema.yml
    @@ -33,6 +33,28 @@ sharemessage.addthis:
    +    shorterTotal:
    
    +++ b/sharemessage.module
    @@ -127,5 +127,16 @@ function sharemessage_theme() {
    +        'shorterTotal' => TRUE,
    
    +++ b/src/Form/SharrreSettingsForm.php
    @@ -0,0 +1,109 @@
    +      ->set('shorterTotal', $form_state->getValue('shorterTotal'))
    +      ->set('enableHover', $form_state->getValue('enableHover'))
    +      ->set('enableCounter', $form_state->getValue('enableCounter'))
    +      ->set('enableTracking', $form_state->getValue('enableTracking'))
    
    +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,159 @@
    +    $form['shorterTotal'] = array(
    ...
    +      '#default_value' => $this->getSetting('shorterTotal'),
    

    I think the config values are supposed to be lowercase underscore separated? (and so are the form keys.)

  2. +++ b/css/sharemessage.sharrre.css
    @@ -0,0 +1,46 @@
    +.sharrre .box{
    ...
    +.sharrre .button{
    +    float:left;
    
    +++ b/js/sharrre.js
    @@ -0,0 +1,42 @@
    +          googlePlus: {size: 'tall', annotation:'bubble'},
    

    Codestyle (spaces) and lines below.

  3. +++ b/js/sharrre.js
    @@ -0,0 +1,42 @@
    +  Drupal.behaviors.sharrre = {
    

    Prefix it with sharemessage_?

  4. +++ b/js/sharrre.js
    @@ -0,0 +1,42 @@
    +      $('#sharemessage').sharrre({
    

    Oops... This is telling mit that things don't work when A sharrre and an addthis thing is present at the same time!

    Can you please extend the sharemessage_demo with placing a second message for Sharrre?

    I also realise that the demo does not cover images configuration...

  5. +++ b/src/Form/SharrreSettingsForm.php
    @@ -0,0 +1,109 @@
    +    $addthis_config = $this->config('sharemessage.sharrre');
    
    +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,159 @@
    + * AddThis plugin.
    ...
    +class Sharrre extends SharePluginBase implements  SharePluginInterface {
    

    Sharrre and not AddThis. And there are other similar locations.

  6. +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,159 @@
    +   * Gets the default AddThis settings.
    

    This does not return the "default" settings. It still contains the overrides. Only use the term "default" in an API if it is the global default.

  7. +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,159 @@
    + *   description = @Translation("Sharrre plugin for ShareMessage module."),
    

    This text is totally meaningless. If anything, then link to the provider and or describe what it is! Same applies for the existing AddThis description... ;-)

  8. +++ b/src/Form/SharrreSettingsForm.php
    @@ -0,0 +1,109 @@
    +      '#title' => t('Format number like 1.2k or 5M'),
    

    And what if unchecked?

  9. Followup: You introduce similarly to addthis the concept of global defaults with overrides... If this is the usual pattern, then we should make ShareMessage back this. Unsure. I'm not sure if default settings make sense here.
  10. Followup: I realise if we override, all settings are empty. Instead we should initialise it with the global settings if no override is defined.

Still no idea why the test fails!

sasanikolic’s picture

Did lots of renaming, CSS changes and other changes for the comments below.

Also, I opened a few issues related to this / followups.

Status: Needs review » Needs work

The last submitted patch, 12: new_plugin_sharrre_com-2165561-12.patch, failed testing.

miro_dietiker’s picture

Is it possible that the AddThis plugin tries to connect to addthis to load the services definition and that fails with a timeout because the testbot does not allow external connections. As a result no services are available and none are output.

The module has a switch to use the local file for the definition. Then things should pass - or at least chances exist.

miro_dietiker’s picture

Issue tags: +Needs tests

And we are missing sharrre specific tests. :-)

sasanikolic’s picture

On @miro_dietiker's suggestion, I'm posting a combined patch with open graph headers only patch and a OG no-test patch.

The last submitted patch, 16: open-graph-headers-no-test.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 16: new_plugin_sharrre_com-2165561-15-combined.patch, failed testing.

miro_dietiker’s picture

+++ b/src/Plugin/sharemessage/OGHeaders.php
@@ -0,0 +1,71 @@
+  public function calculateDependencies(){
...
+  public function getConfiguration(){

Codestyle :-)

+++ b/src/Tests/ShareMessageSettingsTest.php
@@ -124,4 +124,30 @@ class ShareMessageSettingsTest extends ShareMessageTestBase {
+    $this->assertRaw('<meta property="og:url" content="http://d8.dev/sharemessage-test/sharemessage_test_og_label" />');

Fix location - either determine the URL of the bot correctly by API or use assertPattern()

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new35.71 KB
new2.2 KB

Fixed the link in the test, the inheritdoc for getSetting and codestyle in OGHeaders.

Status: Needs review » Needs work

The last submitted patch, 20: new_plugin_sharrre_com-2165561-20.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new36.17 KB
new469 bytes

Testing the testbot with the option "Use local service definitions file" enabled.

Status: Needs review » Needs work

The last submitted patch, 22: new_plugin_sharrre_com-2165561-22.patch, failed testing.

berdir’s picture

  1. +++ b/config/install/sharemessage.addthis.yml
    @@ -3,7 +3,7 @@ additional_services: true
    -local_services_definition: false
    +local_services_definition: true
     shared_video_width: 360
    

    This can not be related, this setting is just what's shown in the settings form.

  2. +++ b/css/sharemessage.sharrre.css
    diff --git a/js/jquery.sharrre.min.js b/js/jquery.sharrre.min.js
    new file mode 100755
    
    new file mode 100755
    index 0000000..377659a
    
    index 0000000..377659a
    --- /dev/null
    
    --- /dev/null
    +++ b/js/jquery.sharrre.min.js
    

    I know it's annoying but we can't add this, we need to rely on libraries module and make users download it.

  3. +++ b/src/Form/SharrreSettingsForm.php
    @@ -0,0 +1,109 @@
    +
    +    // If the profile id changes then we need to rebuild the library cache.
    +    Cache::invalidateTags(['library_info']);
    

    there is no such thing here.

  4. +++ b/src/Plugin/sharemessage/OGHeaders.php
    @@ -0,0 +1,71 @@
    +/**
    + * Sharrre plugin.
    + *
    + * @SharePlugin(
    + *   id = "ogheaders",
    

    lies!

  5. +++ b/src/Plugin/sharemessage/OGHeaders.php
    @@ -0,0 +1,71 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    +    return $form;
    +  }
    +
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function calculateDependencies() {
    +  }
    +
    

    All of those methods should have default implementations in the base class, so remove the empty methods. add them if necessary.

  6. +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,159 @@
    +      '#cache' => [
    +        'tags' => $this->shareMessage->getCacheTags(),
    +      ],
    

    remove this.

  7. +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,159 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getSetting($key) {
    +    $override = $this->shareMessage->getSetting('override_default_settings');
    +    if (isset($override)) {
    +      return $this->shareMessage->getSetting($key);
    +    }
    +  }
    

    doesn't need to be public.

  8. +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,159 @@
    +        'googlePlus' => t('Google+'),
    +        'facebook' => t('Facebook'),
    +        'twitter' => t('Twitter'),
    +        'digg' => t('Digg'),
    +        'delicious' => t('Delicious'),
    +        'stumbleupon' => t('StumpleUpon'),
    +        'linkedin' => t('Linkedin'),
    +        'pinterest' => t('Pinterest'),
    

    Use $this->t() everyhwere in here.

berdir’s picture

Can reproduce those test fails.

The reason is simple enough. The new og headers plugin or probably before sharrre is the default plugin now. So we no longer use addthis but ogheaders.. obviously nothing works anymore then ;)

We should make sure that the default is addthis for now. Possibly just as a fallback default value in the form, instead of the first, pick addthis. Or we could introduce a weight on the plugins and sort them by that.

Also, the list builder should show the plugin in the list now in a new column.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new39.71 KB
new9.72 KB

Some of the these changes broke the og tags plugin and the tabs of sharrre plugin is now not displayed.
Have to check tomorrow to see what exactly is happening, but a review would be welcome.

miro_dietiker’s picture

Status: Needs review » Needs work

Yeah, time to get this in... :-)

Now you also provided here the OG plugin.. I thought we stay with the sharrre plugin and add the OG plugin in a separate issue #2600094: New plugin: open graph headers only
Why are we mixing now?

+++ b/sharemessage.module
@@ -30,6 +51,22 @@ function sharemessage_library_info_alter(&$libraries, $extension) {
+  $info = libraries_detect('sharrre');
+  // Self hosted library, use files from library definition.
+  if (!empty($info['files']['js'])) {

We should be describe a bit clearer about what is happening here.

The last submitted patch, 26: new_plugin_sharrre_com-2165561-26.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new22.52 KB
new21.49 KB

Removed OG headers plugin patch and its changes, removed the min js, extended a comment, fixed local test warnings - min js version.

Status: Needs review » Needs work

The last submitted patch, 29: new_plugin_sharrre_com-2165561-29.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new28.09 KB
new11.23 KB

Extended the test, made the library also external and some other changes.

Status: Needs review » Needs work

The last submitted patch, 31: new_plugin_sharrre_com-2165561-31.patch, failed testing.

miro_dietiker’s picture

+++ b/src/Tests/ShareMessageSettingsTest.php
@@ -81,12 +81,46 @@ class ShareMessageSettingsTest extends ShareMessageTestBase {
-  function testShareMessageDeleteCancel() {
+  function dtestShareMessageDeleteCancel() {

Hmm... skipped?!

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new30.37 KB
new10.44 KB

Uncommented the test, removed the library dependency, made a new validation function for Sharrre settings form, ...
Hopefully now the tests will be green.

sasanikolic’s picture

Changed some comments and switched some things around.

miro_dietiker’s picture

Status: Needs review » Needs work

Yeah we are almost there! ;-)

  1. +++ b/js/sharrre.js
    @@ -0,0 +1,42 @@
    +          pinterest: {media: 'http://sharrre.com/img/example1.png', description: $('#shareme').data('text'), layout: 'vertical'}
    

    Example initialisation? ;-)

  2. +++ b/src/Form/ShareMessageForm.php
    @@ -235,6 +248,33 @@ class ShareMessageForm extends EntityForm {
    +    if ($form_state->getValue('plugin') == 'sharrre') {
    

    That's not allowed here.
    Plugins need to check stuff on their own.

  3. +++ b/src/Plugin/sharemessage/Addthis.php
    @@ -44,6 +44,9 @@ class Addthis extends SharePluginBase implements  SharePluginInterface {
    +        'tags' => $this->shareMessage->getCacheTags(),
    

    Thought we moved this into the builder?

  4. +++ b/src/Plugin/sharemessage/Sharrre.php
    @@ -0,0 +1,218 @@
    +    static::isConfigured($form, TRUE);
    

    Then let's name it checkConfiguration()

  5. +++ b/src/Tests/ShareMessageSettingsTest.php
    @@ -81,6 +81,40 @@ class ShareMessageSettingsTest extends ShareMessageTestBase {
    +    $this->drupalGet('admin/config/services/sharemessage/sharrre-settings');
    

    You want to have a test that checks the error message when configuration is missing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new29.59 KB
new9.21 KB

Fixes for #36, rebased correctly, extended the plugin base and moved the validation into the plugin.

miro_dietiker’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Yay! Looks fine now.
And fine to cover more in followups...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.