{% set preview = record.get_preview()%}

{% if preview is iterable %}
    <p>{% trans 'No preview available.' %}</p>
{% elseif preview.get_permalink() is none %}
    <p>{% trans 'No permalink available.' %}</p>
{% else %}
    {% set type = record.get_type() %}
    {% set url = preview.get_permalink().get_url() %}
    {% set pageurl = preview.get_permalink().get_page() %}

    {% if url is not empty %}
        <div id="share">
            <div id="tweet" class="well-large">
                <div>
                    <a href="http://www.twitter.com/home/?status={{ pageurl }}" target="_blank">
                        <img src="/skins/icons/twitter.ico" title="share this on twitter" style="vertical-align:middle;padding:0 5px;"/>
                        {% trans %}Send to Twitter{% endtrans %}
                    </a>
                </div>
                <div>
                    <a href="http://www.facebook.com/sharer.php?u={{ pageurl }}" target="_blank">
                        <img src="/skins/icons/facebook.ico" title="share on facebook" style="vertical-align:middle;padding:0 5px;"/>
                        {% trans %}Send to Facebook{% endtrans %}
                    </a>
                </div>
            </div>
            <div id="embed" class="well-large">
                <form action="#">
                    <label>{% trans %}Resource URL{% endtrans %}</label>
                    <input class="input-block-level" readonly="readonly" type="text"  value="{{ url }}" />
                    <label>{% trans %}Detailed view URL{% endtrans %}</label>
                    <input class="input-block-level" readonly="readonly" type="text"  value="{{ pageurl }}" />
                    {% if type == 'image' %}
                        <label>{% trans %}Embed code{% endtrans %}</label>
                        {% spaceless %}
                            <textarea class="input-block-level" rows="4" readonly="true">
                                <a href="{{ pageurl }}"><img src="{{ url|url_encode }}" title="" /></a>
                            </textarea>
                        {% endspaceless %}
                    {% endif %}
                </form>
            </div>
        </div>

        <script language="javascript">
            $(document).ready(function(){
                $('input.ui-state-default').hover(
                    function(){$(this).addClass('ui-state-hover');},
                    function(){$(this).removeClass('ui-state-hover');}
                );
            });
        </script>
    {% else %}
        <div><{% trans 'No URL available' %}</div>
    {% endif %}
{% endif %}

