Skip to content

Instantly share code, notes, and snippets.

View jbdietrich's full-sized avatar

James Dietrich jbdietrich

View GitHub Profile
"""
Remote authentication stub for Flask
This is meant as a template for your own customization.
You can identify the user anyway you like,
integrate it into your intranet, web app or similar.
"""
from flask import Flask, request, redirect
import time
</script>
<script type="text/javascript">
$j('#suggestions_for_new_topic div.related-topics-header h3').text("Custom Text Here");
<script type="text/javascript">
$j('#_getButton').bind('click', function () {
var current_agent = "{{current_user.email}}";
search_url = "/api/v2/search.json?query=type%3Aticket%20status%3Csolved%20assignee%3A" + current_agent;
$j.get(search_url, function(data) {
alert(data.count + ' tickets assigned to you. First ticket URL is '+ data.results[0].url);
});
});
</script>
{% for comment in ticket.comments %}
Attachments:
{% for attachment in comment.attachments %}
<a href="{{attachment.url}}">{{attachment.filename}}</a>
{% endfor %}
{% endfor %}
</script>
<script type="text/javascript">
var entriesRegex = /^\/entries\//;
if (window.location.pathname.match(entriesRegex)) {
$j(".content_green").css("display", "block");
}
{% if content contains "font-family:'Lucida Sans Unicode','Lucida Grande','Tahoma',Verdana,sans-serif;" %}
{{content | replace: "font-family:'Lucida Sans Unicode','Lucida Grande','Tahoma',Verdana,sans-serif;", "font-family: Arial;" }}
{% else %}
{{content}}
{% endif %}
{% if content contains "1px dotted #c5c5c5" %}
{{content | replace: "1px dotted #c5c5c5", "none" | replace: "'Lucida Sans Unicode','Lucida Grande','Tahoma',Verdana,sans-serif", "Arial, Helvetica, sans-serif" }}
{% else %}
{{content}}
{% endif %}
{% if content contains "1px dotted #c5c5c5" %}
{{content | replace: "1px dotted #c5c5c5", "none" | replace : "15px", "0px" | replace: "13px", "0px"}}
{% else %}
{{content}}
{% endif %}
@jbdietrich
jbdietrich / python_flask_jwt.py
Last active December 8, 2019 18:58
A naive implementation of Zendesk's JWT-based Remote Auth for Flask
# This example relies on you having installed PyJWT, `sudo easy_install PyJWT` - you can
# read more about this in the GitHub repository https://github.com/progrium/pyjwt
from flask import Flask, request, redirect
import time
import uuid
import jwt
# insert token here
app.config['SHARED_KEY'] = ''
events: {
'click .your_button': function(data){
data.target.ownerDocument.defaultView.open();
}
}