• Stars
    star
    247
  • Rank 164,117 (Top 4 %)
  • Language
    CSS
  • Created almost 12 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A facebook-like link preview js library using Twitter Bootstrap styling components

Link preview plugin for Twitter Bootstrap

bootstrap-linkpreview.js is a JavaScript library offering a facebook-like preview for URLs. It is very simple to use and weighs just a few kilobytes.

Demo

One limitation: the same origin policy

You may want to try this library locally from a HTML file but you will face this issue:

XMLHttpRequest cannot load *…* Origin : * is not allowed by Access-Control-Allow-Origin.

This is due to the Same origin policy concept. Ajax calls can only be achieved with a URL based on the same domain they are launched on. That’s why you usually want to process link previews on your server. But sometimes you don’t have any other way than doing it on the client’s side.

Anyway don’t panic, this library is working perfectly with some conditions.

Demos

The best way to know how to use this library is to go through the examples in the folder demos. There you find two ways to get around the same origin policy.

php-proxy

This example demonstrates how to use the library from a website. It simply filters every jQuery ajax calls and echoes it on the server. That way the ajax call get the results back. To run the code, simply upload the demo on your server or run a local Apache server.

Thanks to this thread for the php script.

chrome-extension

The advantage with Google Chrome extensions is that it gives a way to bypass the same origin policy. To run it, follow these steps.

How to use bootstrap-linkpreview?

Call the library via javascript:

$('.element').linkpreview()

$('.element') can point to <input>, <textarea> or <a>. Without any parameters, this will load the URL(s) and generate the preview just after the element(s).

Options

There are a few options available for this library, e.g:

$('.element').linkpreview({
	previewContainer: "#preview-container",
	refreshButton: "#refresh-button",
	onSuccess: function(data) {
		console.log("Winner!");
	}
})
Name Type Default Description
url URL $element.val() || $element.attr('href') URL to use instead of the element's content
previewContainer Selector $element.after() Container block receiving the preview of the link
previewContainerClass String row-fluid well Class of the previewContainer
refreshButton Selector Button refreshing the preview
errorMessage String We are sorry we couldn't load the preview. The URL is invalid. Custom error message
preProcess Function Treatment to make before we load the link
onSuccess Function Callback when the data is loaded
onError Function Callback when an error occurred while processing the preview
onComplete Function Callback when a result has been received

Dependencies

All dependencies can be found under the folder deps:

License

Copyright 2013 Ekito - http://www.ekito.fr/

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

docker-cron

An example of running cron job in a docker container
381
star
2

koin-samples

KOIN - a concise and pragmatic dependency injection framework for Kotlin -- #Samples
Shell
213
star
3

MapTracker

Play!ing (2.0) with Twitter Bootstrap, WebSockets, Akka and OpenLayers
CSS
80
star
4

mvvm-coroutines

Android MVVM - Architecture Components with Kotlin Coroutines
Kotlin
60
star
5

spring-boot-gwt

A quickstart spring boot gwt application
Java
49
star
6

Simple-KML

A KML Serializer for Android - THIS PROJECT IS NO LONGER MAINTAINED
HTML
43
star
7

spring-multitenancy

Spring web application Multitenancy example
Java
39
star
8

websocket-latency

Simple latency test on Websocket with Node and Socket.io
JavaScript
11
star
9

reactiveweather-android

Android App for getting the weather... kotlin & reactive style
Kotlin
7
star
10

maven-repo

Maven repository for ekito's binaries
6
star
11

mapMyCost-server

Server side application
JavaScript
5
star
12

talend-cmis-components

Talend Open Studio components for extracting/loading content from/to a CMIS repository
5
star
13

mapMyCost-iOS

iOS Application
Objective-C
4
star
14

ProxiTest

A sample project to show signal strength of multiple BLE devices.
Objective-C
3
star
15

rx-web-playground

OkHttp/Retrofit RxJava playground with a spring boot server
Kotlin
2
star
16

introduction-to-stackview

Swift Playground to illustrate blog post about "Introduction to UIStackView"
Swift
2
star
17

spring-boot

A simple rest service with Spring boot
Java
2
star
18

talend-cmis-plugins

Talend Open Studio plugins for CMIS
Java
2
star
19

UIView-Visible

UIView+Visible cocoa pods ; UIView category that adds a visible property
Ruby
2
star
20

mapMyCost-Android

Android Application
Java
2
star
21

android-kotlin-starterapp

Android Kotlin starter app (retrofit,rxjava ...)
Kotlin
2
star
22

auth0-create-react-app-redux

JavaScript
2
star
23

go-weather-api

Go app for serving geocoding & weather
Go
1
star
24

hackerz_akeru

C++
1
star
25

gradle-doxia-plugin

A gradle plugin that allows for document generation with Apache Doxia.
Groovy
1
star
26

coding-dojo

Java
1
star
27

beyond-kotlin-playground

Beyond Kotlin Talk - Playground
Kotlin
1
star
28

android-injector

Easy to use android dependency injection, to help you quickly organize your singletons, components ...
Java
1
star
29

docker-calibre-server

1
star
30

MapTracker-Android

An Android client for MapTracker
Java
1
star
31

TestBeacon

This is a sample projet used to show iBeacon monitoring and ranging.
Objective-C
1
star
32

jhipster-demo

Jhipster demo application with docker compose
Java
1
star