Skip to content

Instantly share code, notes, and snippets.

View chucknado's full-sized avatar

Charles Nadeau chucknado

View GitHub Profile
@chucknado
chucknado / category_with_sections
Created December 12, 2019 18:13
Show the subsections of each section from the category page
<div class="container-divider"></div>
<div class="container">
<nav class="sub-nav">
{{breadcrumbs}}
{{search submit=false}}
</nav>
<div class="category-container">
<div class="category-content">
<header class="page-header">
@chucknado
chucknado / post_articles.py
Last active March 11, 2020 23:26
Uploads a collection of HTML files to Help Center
from pathlib import Path
from bs4 import BeautifulSoup
import requests
"""
1. Place the HTML files in a folder named 'html_files' in the same folder as this file.
2. Change the settings starting on line 14 to values that are valid for your account.
3. In your command line interface, navigate to the folder containing this file and run `python3 post_articles.py`.
4. In Guide, set the correct sections, authors, and access permissions for the articles.
@chucknado
chucknado / sunshine.py
Last active April 10, 2019 22:35
Python module for Sunshine profiles in "Getting started with Sunshine profiles" article
import requests
credentials = 'your_zendesk_email', 'your_zendesk_password'
zendesk = 'https://your_subdomain.zendesk.com'
def post_profile(profile):
data = {'profile': profile}
url = f'{zendesk}/api/sunshine/profile'
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=data, auth=credentials, headers=headers)
@chucknado
chucknado / sunshine.py
Last active April 10, 2019 19:19
Python module for Sunshine events in "Getting started with Sunshine user events" article
import requests
credentials = 'your_zendesk_email', 'your_zendesk_password'
zendesk = 'https://your_subdomain.zendesk.com'
def track_event(payload):
url = f'{zendesk}/api/sunshine/events'
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=payload, auth=credentials, headers=headers)
@chucknado
chucknado / scripts.js
Last active August 16, 2018 08:57
Sample script for Zendesk API tutorial named "Making cross-origin, browser-side API requests" at https://help.zendesk.com/hc/en-us/articles/115005580188
function init() {
// reset page
document.getElementById('error-msg').style.display = "none";
document.getElementById('details').style.display = "none";
var url = window.location.href;
if (url.indexOf('your_redirect_url') !== -1) {
if (url.indexOf('access_token=') !== -1) {
var access_token = readUrlParam(url, 'access_token');
localStorage.setItem('zauth', access_token);
@chucknado
chucknado / update_articles_in_section.py
Last active February 9, 2017 22:13
Update a property of all the articles in a Zendesk Help Center section
import requests
credentials = 'your_zendesk_email', 'your_zendesk_password'
zendesk = 'https://your_subdomain.zendesk.com'
language = 'some_locale'
section_id = 123456
# Configure the list section articles endpoint
endpoint = zendesk + '/api/v2/help_center/{}/sections/{}/articles.json'.format(language, section_id)
@chucknado
chucknado / iframe.html
Created January 20, 2017 18:34
The iframe of a Zendesk app for the OAuth tutorial at https://support.zendesk.com/hc/en-us/articles/205225558
<html>
<head>
<link href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="main.css" rel="stylesheet">
</head>
<body>
<div id="content"></div>
<script id="start-hdbs" type="text/x-handlebars-template">
@chucknado
chucknado / restore_articles.py
Created January 4, 2017 23:48
A Python script for the REST API tutorial, "Backing up your knowledge base," at https://help.zendesk.com/hc/en-us/articles/229136947
import os
import requests
from bs4 import BeautifulSoup
# Settings
credentials = 'your_zendesk_email', 'your_zendesk_password'
zendesk = 'https://your_instance.zendesk.com'
backup_folder = '20xx-xx-xx'
@chucknado
chucknado / main.js
Last active August 30, 2016 17:49
Client-side script of Bottle app for simple server-side Zendesk app (https://support.zendesk.com/hc/en-us/articles/226176327)
function init() {
var client = ZAFClient.init();
switch (action) {
case 'notifySuccess':
client.invoke('notify', 'Request successful!');
break;
case 'notifyFailure':
client.invoke('notify', msg, 'error');
break;
}
@chucknado
chucknado / app.py
Last active August 30, 2016 17:49
Bottle app for simple server-side Zendesk app (https://support.zendesk.com/hc/en-us/articles/226176327)
from bottle import route, run, template, request, response, static_file
import requests
@route('/sidebar')
def send_iframe_html():
qs = request.query_string
response.set_cookie('my_app_params', qs)
return template('start', qs=qs)