Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added patches directory with 2 patches #76

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions patches/baseurl_change_via_reverseproxy/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This script generates patch that once applied will change the base URI
of haste-server from / to whatever you specify (like /haste/). Afterwards
you can add the required configuration to your reverse proxy server and
all should work out of the box.

More information and explanation can be found at
http://www.ctrl-alt-del.cc/2014/11/haste-server-base-url-hackpatch.html


Usage:
./haste-baseurl-patch-generator.pl <prefix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/perl
#
# (c) Tomasz Miklas
# https://github.com/tmiklas/
# License: MIT
#
# More info: http://www.ctrl-alt-del.cc/2014/11/haste-server-base-url-hackpatch.html
#

use strict;
use warnings;

if ($#ARGV < 0) {
print "Usage:\n\t$0 <prefix>\n";
exit;
}

# ensure given directory prefix has the right format:
# /directory - bad
# /directory/ - bad
# directory/ - good
my $prefix = $ARGV[0];
$prefix =~ s/^\///;
$prefix .= "/" if $prefix !~ /\/$/;

# create patch file
open (OUT, ">baseurl.patch");
while (<DATA>) {
s/{{{prefix}}}/$prefix/g;
print OUT $_;
}
close (OUT);

# what's next?
print <<_END__;
Patch file basepath.patch generated - your hastebin will reside in http://<servername>/$prefix
Please change the directory into haste-server and apply the patch:
Install: patch -p0 < baseurl.patch
Uninstall: patch -p0 -R < baseurl.patch
_END__

__DATA__
diff -rupN static-orig/application.js static/application.js
--- static-orig/application.js 2014-11-07 00:28:04.326519263 +0100
+++ static/application.js 2014-11-09 00:02:28.498067362 +0100
@@ -16,7 +16,7 @@ haste_document.prototype.htmlEscape = fu
// Get this document from the server and lock it here
haste_document.prototype.load = function(key, callback, lang) {
var _this = this;
- $.ajax('/documents/' + key, {
+ $.ajax('/{{{prefix}}}documents/' + key.split('/')[-1], {
type: 'get',
dataType: 'json',
success: function(res) {
@@ -58,7 +58,7 @@ haste_document.prototype.save = function
}
this.data = data;
var _this = this;
- $.ajax('/documents', {
+ $.ajax('/{{{prefix}}}documents', {
type: 'post',
data: data,
dataType: 'json',
@@ -148,7 +148,7 @@ haste.prototype.newDocument = function(h
this.$box.hide();
this.doc = new haste_document();
if (!hideHistory) {
- window.history.pushState(null, this.appName, '/');
+ window.history.pushState(null, this.appName, '/{{{prefix}}}');
}
this.setTitle();
this.lightKey();
@@ -242,7 +242,7 @@ haste.prototype.lockDocument = function(
else if (ret) {
_this.$code.html(ret.value);
_this.setTitle(ret.key);
- var file = '/' + ret.key;
+ var file = '/{{{prefix}}}' + ret.key;
if (ret.language) {
file += '.' + _this.lookupExtensionByType(ret.language);
}
@@ -301,7 +301,7 @@ haste.prototype.configureButtons = funct
},
shortcutDescription: 'control + shift + r',
action: function() {
- window.location.href = '/raw/' + _this.doc.key;
+ window.location.href = '/{{{prefix}}}raw/' + _this.doc.key;
}
},
{
diff -rupN static-orig/index.html static/index.html
--- static-orig/index.html 2014-11-07 00:28:04.329519272 +0100
+++ static/index.html 2014-11-09 00:01:50.375948333 +0100
@@ -18,7 +18,7 @@
// Handle pops
var handlePop = function(evt) {
var path = evt.target.location.pathname;
- if (path === '/') { app.newDocument(true); }
+ if (path === '/{{{prefix}}}') { app.newDocument(true); }
else { app.loadDocument(path.substring(1, path.length)); }
};
// Set up the pop state to handle loads, skipping the first load
1 change: 1 addition & 0 deletions patches/make_tab_4_spaces_for_python/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This patch changes the haste's defaults from 1 tab = 2 spaces to 1 tab = 4 spaces, as used with Python scripts.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -rupN static-orig/application.js static/application.js
--- static-orig/application.js 2014-11-07 00:28:04.326519263 +0100
+++ static/application.js 2014-11-09 00:02:28.498067362 +0100
@@ -365,7 +365,7 @@ $(function() {
$('textarea').keydown(function(evt) {
if (evt.keyCode === 9) {
evt.preventDefault();
- var myValue = ' ';
+ var myValue = ' ';
// http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery
// For browsers like Internet Explorer
if (document.selection) {