Skip to content

Instantly share code, notes, and snippets.

@tilgovi
tilgovi / application.coffee
Last active August 29, 2015 14:00
Annotator selector extension pseudocode
selectorExtension = require('./selectorExtension')
CustomAnnotator = Annotator.extend(selectorExtension)
annotator = new CustomAnnotator(...)
// This is our interaction point
position = null;
$(document.body).on('mouseup', function (event) {
});
var annotator = Annotator.create({
onSelection: function (event) {
// We have to trigger this event ourselves.
// Could be as simple as:
@tilgovi
tilgovi / basic.coffee
Last active August 29, 2015 14:01
Idea for bootstrap of a basic (default) Annotator application
Util = require('../src/util')
$ = Util.$
Adder = require('../src/plugin/adder')
Viewer = require('../src/plugin/viewer')
Editor = require('../src/plugin/editor')
TextSelector = require('../src/plugin/textselector')
Highlighter = require('../src/plugin/highlighter')
@tilgovi
tilgovi / gist:f94565b2beb6623a79e9
Created August 26, 2014 09:58
Sketches for forced login, bridge changes
commit 318158cf7ee82797969e5ab2fa559ca6ab4dfa6a
Merge: 0610025 a17f146
Author: Randall Leeds <tilgovi@hypothes.is>
Date: Mon Jul 28 22:29:32 2014 -0700
WIP on master: 0610025 Bump annotator-store version for security fix
diff --cc h/static/scripts/app_directives.coffee
index 7bac3cc,7bac3cc..4e03cca
diff --cc h/static/scripts/controllers.coffee
@tilgovi
tilgovi / reject.py
Created September 6, 2014 01:47
Testing FIN and RST behavior in gunicorn
# Log localhost port 8000 in the background
sudo tcpdump -i lo tcp port 8000 > log.txt &
# Send 5 megabytes upload
head -c5M /dev/urandom | curl -v -XPOST -d@- localhost:8000
# End the tcpdump and cat the log file
fg
^C
cat log.txt
@tilgovi
tilgovi / history.coffee
Created September 27, 2014 00:39
iframe history decorator for history in iframes with angular
angular.module('h.history', [
'h.settings'
],
[
'$provide', 'settings'
($provide, settings) ->
if settings.framed
$provide.decorator '$window', captureHistory
$provide.decorator '$sniffer', forceHistory
])
@tilgovi
tilgovi / index.js
Created October 15, 2014 22:25
annotator-storage-oacg
var Annotator = require('annotator');
function dump(data) {
var result = {};
result['@context'] = 'http://www.w3.org/ns/oa-context-20130208.json';
if (typeof(data.id) !== 'undefined') {
result['@id'] = data.id;
@tilgovi
tilgovi / MyPlugin.js
Created October 15, 2014 23:06
Annotator v1.2.x Plugin Skeleton
function MyPlugin(element, options) {
Annotator.Plugin.call(this, element, options);
// At this point, `this.element` will be a jQuery-wrapped reference to
// the element argument and `this.options` will be a copy of the options
// object (if any) that you define on the prototype with overrides specified
// by the argument to this function. See below for more.
this.options.someObject = {}; // See below.
}
@tilgovi
tilgovi / highlights-metadata.diff
Created March 11, 2015 20:59
Annotator cross frame highlights metadata
diff --git a/h/static/scripts/annotator/monkey.coffee b/h/static/scripts/annotator/monkey.coffee
index da800da..51c8561 100644
--- a/h/static/scripts/annotator/monkey.coffee
+++ b/h/static/scripts/annotator/monkey.coffee
@@ -9,6 +9,12 @@ Util = Annotator.Util
delete Annotator.prototype.events[".annotator-hl mouseover"]
delete Annotator.prototype.events[".annotator-hl mouseout"]
+# Add createHighlight
+Annotator.prototype.createHighlight = ->
@tilgovi
tilgovi / stream-unfiltered.diff
Created April 17, 2015 20:31
Disable the page search on stream results
diff --git a/h/static/scripts/stream-controller.coffee b/h/static/scripts/stream-controller.coffee
index 1a275a1..ccb4575 100644
--- a/h/static/scripts/stream-controller.coffee
+++ b/h/static/scripts/stream-controller.coffee
@@ -5,26 +5,32 @@ module.exports = class StreamController
this.inject = [
'$scope', '$rootScope', '$routeParams',
'auth', 'queryParser', 'searchFilter', 'store',
- 'streamer', 'streamFilter', 'annotationMapper'
+ 'streamer', 'streamFilter', 'threading', 'annotationMapper'