Commit 4d51c024 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff
Browse files

Add OpenGraph video support

closes #7043
parent 0514545f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
## Features
* Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045)
* The "subscribe" indicator on a post now gets toggled when you like or rehsare a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
* Add OpenGraph video support [#7043](https://github.com/diaspora/diaspora/pull/7043)

# 0.6.0.0

+0 −12
Original line number Diff line number Diff line
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later

(function(){
  app.helpers.openGraph = {
    html : function (open_graph_cache) {
      if (!open_graph_cache) { return ""; }
      return '<img src="' + open_graph_cache.image + '" />';
    },
  };
})();
// @license-end
+10 −0
Original line number Diff line number Diff line
@@ -151,6 +151,10 @@ app.views.OEmbed = app.views.Base.extend({
app.views.OpenGraph = app.views.Base.extend({
  templateName : "opengraph",

  events: {
    "click .video-overlay": "loadVideo"
  },

  initialize: function() {
    this.truncateDescription();
  },
@@ -161,6 +165,12 @@ app.views.OpenGraph = app.views.Base.extend({
      var ogdesc = this.model.get('open_graph_cache');
      ogdesc.description = app.helpers.truncate(ogdesc.description, 250);
    }
  },

  loadVideo: function() {
    this.$(".opengraph-container").html(
      "<iframe src='" + this.$(".video-overlay").attr("data-video-url") + "' frameBorder=0 width='100%'></iframe>"
    );
  }
});

+28 −7
Original line number Diff line number Diff line
@@ -10,20 +10,41 @@
  overflow: hidden;
  a {
    color: #000;
    img {
      margin: 5px 5px 5px 0px;
      float: left;
      max-width: 150px;
      padding-right: 5px;
    }
    .og-title {
      margin-bottom: 5px;
      font-weight: bold;
    }
  }
  a:hover {
    color: $blue;
  }

  .thumb {
    float: left;
    margin: 5px;
    margin-left: 0;
    max-width: 150px;
    padding-right: 5px;

    .video-overlay {
      cursor: pointer;
      height: 145px;
      width: 145px;
    }

    .overlay {
      background-color: rgba($black, .2);
      background-image: image-url('buttons/playbtn.png');
      background-position: center;
      background-repeat: no-repeat;
      background-size: 60px 60px;
      display: inline-block;
      height: 145px;
      position: relative;
      top: -145px;
      width: 145px;
    }
  }

  .og-description {
    color: $text-grey;
  }
+10 −2
Original line number Diff line number Diff line
{{#unless o_embed_cache}}
  {{#if open_graph_cache}}
    <div class="opengraph-container">
      <a href="{{open_graph_cache.url}}" target="_blank">
      <div class="thumb">
        {{#if open_graph_cache.video_url }}
          <div class="video-overlay" data-video-url="{{open_graph_cache.video_url}}">
            <img src="{{open_graph_cache.image}}" />
            <div class="overlay"></div>
          </div>
        {{else}}
          <img src="{{open_graph_cache.image}}" />
        {{/if}}
      </div>
      <a href="{{open_graph_cache.url}}" target="_blank">
        <p class="og-title">{{open_graph_cache.title}}</p>
      </a>
      <p class="og-description">{{open_graph_cache.description}}</p>
    </div>
  {{/if}}
{{/unless}}
Loading