turboamper

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 8 Imported by: 0

README

turboamper

turboamper is a simple library that makes easy to create AMP representation for some social network embed materials. It is planned to support Facebook, Vkontakte, Twitter, Instagram, Youtube and some custom iframes.

Download and install

As usual, go get github.com/RGRU/turboamper

Turboamper supports modules since it was written with go-1.13, so you can add the package to your go.mod file:

require github.com/RGRU/turboamper version

Documentation

Overview

Package turboamper provides support for making some HTML structured texts validateable by Yandex Turbo and Google AMP services.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AMP

func AMP(htmlText []byte) ([]byte, string, error)

AMP gives you amp-representation of html and its type If it cannot recognize your html, it returns simple error.

func FbToAMP

func FbToAMP(htmlText []byte) ([]byte, error)

FbToAMP convertes given facebook embeddable html to AMP

Example
html := `<iframe src="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fstcnk%2Fposts%2F3384458724928901&width=500" width="500" height="498" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>`
amp, err := FbToAMP([]byte(html))
if err != nil {
	fmt.Printf("ERROR: %s", err)
}
fmt.Printf("AMPfied: %s", amp)
Output:

func FbToTurbo

func FbToTurbo(htmlText []byte) ([]byte, error)

FbToTurbo validates Facebook html for Yandex Turbo

func IframeToAMP

func IframeToAMP(htmlText []byte) ([]byte, error)

IframeToAMP convertes some custom iframe embeddable html to AMP Tested on Russia Today

func IframeToTurbo

func IframeToTurbo(htmlText []byte) ([]byte, error)

IframeToTurbo convertes some custom iframe embeddable html to Yandex Turbo

func InstaToAMP

func InstaToAMP(htmlText []byte) ([]byte, error)

InstaToAMP convertes given instagram embeddable html to AMP

func InstaToTurbo

func InstaToTurbo(htmlText []byte) ([]byte, error)

InstaToTurbo validates given instagram embeddable html for Yandex Turbo

func PlaybuzzToAMP

func PlaybuzzToAMP(htmlText []byte) ([]byte, error)

PlaybuzzToAMP convert playbuzz code

func Turbo

func Turbo(htmlText []byte) ([]byte, string, error)

Turbo gives you YandexTurbo-representation of html and its type If it cannot recognize your html, it returns simple error.

func TwitToAMP

func TwitToAMP(htmlText []byte) ([]byte, error)

TwitToAMP convertes given twitter embeddable html to AMP

func TwitToTurbo

func TwitToTurbo(htmlText []byte) ([]byte, error)

TwitToTurbo convertes given twitter embeddable html for Yandex Turbo

func VkToAMP

func VkToAMP(htmlText []byte) ([]byte, error)

VkToAMP convertes given vkontakte widget post to AMP What is that? Look https://vk.com/dev/widget_post

Example
html := `<div id="vk_post_-165546713_21078"></div>
<script type="text/javascript" src="https://vk.com/js/api/openapi.js?162"></script>
<script type="text/javascript">
  (function() {
    VK.Widgets.Post( "vk_post_-165546713_21078", -165546713, 21078, 'UDKmSYMw9-_LHr7Lcgz8oAVE3Xg', {width: 600});
  }());
</script>`
amp, err := VkToAMP([]byte(html))
if err != nil {
	fmt.Printf("ERROR: %s", err)
}
fmt.Printf("AMPfied: %s", amp)
Output:

func VkToTurbo

func VkToTurbo(htmlText []byte) ([]byte, error)

VkToTurbo validates given vkontakte widget post for Yandex Turbo What is that? Look https://vk.com/dev/widget_post

func YoutubeToAMP

func YoutubeToAMP(htmlText []byte) ([]byte, error)

YoutubeToAMP convertes given youtube embeddable html to AMP

func YoutubeToTurbo

func YoutubeToTurbo(htmlText []byte) ([]byte, error)

YoutubeToTurbo convertes Youtube embeddable html to Yandex Turbo

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL