Skip to content

Instantly share code, notes, and snippets.

Avatar

Charles Nadeau chucknado

View GitHub Profile
@chucknado
chucknado / category_with_sections
Created Dec 12, 2019
Show the subsections of each section from the category page
View category_with_sections
<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 Mar 11, 2020
Uploads a collection of HTML files to Help Center
View post_articles.py
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 Apr 10, 2019
Python module for Sunshine profiles in "Getting started with Sunshine profiles" article
View sunshine.py
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 Apr 10, 2019
Python module for Sunshine events in "Getting started with Sunshine user events" article
View sunshine.py
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 Aug 16, 2018
Sample script for Zendesk API tutorial named "Making cross-origin, browser-side API requests" at https://help.zendesk.com/hc/en-us/articles/115005580188
View scripts.js
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 Feb 9, 2017
Update a property of all the articles in a Zendesk Help Center section
View update_articles_in_section.py
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 Jan 20, 2017
The iframe of a Zendesk app for the OAuth tutorial at https://support.zendesk.com/hc/en-us/articles/205225558
View iframe.html
<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 Jan 4, 2017
A Python script for the REST API tutorial, "Backing up your knowledge base," at https://help.zendesk.com/hc/en-us/articles/229136947
View restore_articles.py
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 Aug 30, 2016
Client-side script of Bottle app for simple server-side Zendesk app (https://support.zendesk.com/hc/en-us/articles/226176327)
View main.js
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 Aug 30, 2016
Bottle app for simple server-side Zendesk app (https://support.zendesk.com/hc/en-us/articles/226176327)
View app.py
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)