Skip to content

Instantly share code, notes, and snippets.

View ankitadhandha's full-sized avatar

Ankita Dhandha ankitadhandha

View GitHub Profile
@ankitadhandha
ankitadhandha / gist:43b7116008f101c622e6db0a12d4242b
Last active June 27, 2018 12:17
stackoverflow AMP autosuggest Answer
To implement autosuggest, AMP examples use endpoints which are developed in node.js.
1. Declare necessary node.js modules:
var express = require('express');
var app = express();
2. Declare JSON object data as:
/** @license
* Copyright 2015 - present The AMP HTML Authors. All Rights Reserved.
*
* 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
"use strict";
var express = require('express');
var router = express.Router();
var Slack = require('slack-node');
var multer = require('multer');
var multipart = multer();
//sending messages to slack channel
router.post('/messages', multipart.fields([]), function(req, res) {
oauth.js:
const GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
module.exports = (passport) => {
passport.serializeUser((user, done) => {
done(null, user);
});
passport.deserializeUser((user, done) => {
done(null, user);
});
var PaywallAccess = require('../../models/amp-access');
router.post('/amp-pingback', function(req, res) {
var readerId = req.query.rid;
if (!readerId) {
res.sendStatus(400);
return;
}
<script type="application/ld+json">
{
"@context":"http://schema.org/",
"@type":"AggregateRating",
"itemReviewed": "#productx",
"ratingValue":"4.9",
"bestRating":"5",
"reviewCount":"20",
"author": {
"@type":"Organization",
<script type="application/ld+json">
{"@context": "https://schema.org", "@type": "CreativeWork", "@id": "https://ontomatica.io/identifier/12000000001000011961", "name": "license", "description": "license document that applies to this content", "inLanguage": {"@id": "https://ontomatica.io/identifier/23010000007976101561"}, "citation": {"@type": "Claim", "@id": "https://ontomatica.io/identifier/12030100001000011961"}}
</script>
<script type="application/ld+json" id="1700000000100002.9161">
{"@context":"http://schema.org/","@type":"Class","@id":"https://ontomatica.io/identifier/17000000001000029161","name":"Ashley Vandergrift","description":"Ashley is the lead data curator. She is responsible for the quality of content in Ontomatica repositories.","mainEntityOfPage":{"@id":"https://ontomatica.io/identifier/17000000001000021962"}}</script>
<script type="application/ld+json" id="1700000000100002.1962">
{"@context":"http://schema.org/","@type":"TextDigitalDocument","@id":"https://ontomatica.io/identifier/170000000
<script type="application/ld+json">
{"@context": "https://schema.org", "@type": "CreativeWork", "@id": "https://ontomatica.io/identifier/12000000001000011961", "name": "license", "description": "license document that applies to this content", "inLanguage": {"@id": "https://ontomatica.io/identifier/23010000007976101561"}, "citation": {"@type": "Claim", "@id": "https://ontomatica.io/identifier/12030100001000011961"}}
</script>
<script type="application/ld+json" id="1700000000100002.9161">
{"@context":"http://schema.org/","@type":"Class","@id":"https://ontomatica.io/identifier/17000000001000029161","name":"Ashley Vandergrift","description":"Ashley is the lead data curator. She is responsible for the quality of content in Ontomatica repositories.","mainEntityOfPage":{"@id":"https://ontomatica.io/identifier/17000000001000021962"}}</script>
<script type="application/ld+json" id="1700000000100002.1962">
{"@context":"http://schema.org/","@type":"TextDigitalDocument","@id":"https://ontomatica.io/identifier/170000000
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Recipe",
"name": "Party Coffee Cake",
"image": "https://www.leannebrown.com/wp-content/uploads/2016/12/up-close-pear-cake.jpg",
"author": {
"@type": "Person",
"name": "Leanne Brown"
},
<script type="application/ld+json">
{"@context": "https://schema.org", "@type": "CreativeWork", "@id": "https://ontomatica.io/identifier/12000000001000011961", "name": "license", "description": "license document that applies to this content", "inLanguage": {"@id": "https://ontomatica.io/identifier/23010000007976101561"}, "citation": {"@type": "Claim", "@id": "https://ontomatica.io/identifier/12030100001000011961"}}
</script>
<script type="application/ld+json" id="1700000000100002.9161">
{"@context":"http://schema.org/","@type":"Class","@id":"https://ontomatica.io/identifier/17000000001000029161","name":"Ashley Vandergrift","description":"Ashley is the lead data curator. She is responsible for the quality of content in Ontomatica repositories.","mainEntityOfPage":{"@id":"https://ontomatica.io/identifier/17000000001000021962"}}</script>
<script type="application/ld+json" id="1700000000100002.1962">
{"@context":"http://schema.org/","@type":"TextDigitalDocument","@id":"https://ontomatica.io/identifier/170000000