Skip to content

Instantly share code, notes, and snippets.

View MarkdownField.svelte
<script>
import { getSitecoreContext } from "jss-svelte";
import marked from "marked";
export let field = null;
export let cssClass = "";
let eeElement = null;
const sitecoreContext = getSitecoreContext();
@erzr
erzr / create-default-disconnected-server.js
Created Feb 23, 2020
Disconnected Mode GraphQL for Sitecore JSS Disconnected Server
View create-default-disconnected-server.js
const Express = require('express');
const { join } = require('path');
const { ManifestManager } = require('../node_modules/@sitecore-jss/sitecore-jss-dev-tools/dist/manifest-manager');
const { createDisconnectedDictionaryService } = require('../node_modules/@sitecore-jss/sitecore-jss-dev-tools/dist/disconnected-server/dictionary-service');
const { createDisconnectedLayoutService } = require('../node_modules/@sitecore-jss/sitecore-jss-dev-tools/dist/disconnected-server/layout-service');
const {createGraphQLService} = require('jss-disconnected-graphql');
function createDefaultDisconnectedServer(options) {
let app = options.server;
@erzr
erzr / disconnected-mode-proxy.js
Created Feb 16, 2020
Injecting nonRoute data into Sitecore JSS context using customizeContext
View disconnected-mode-proxy.js
/*
When the app runs in disconnected mode, and Sitecore is not present, we need to give
the app copies of the Sitecore APIs it depends on (layout service, dictionary service, content service)
to talk to so that the app can run using the locally defined disconnected data.
This is accomplished by spinning up a small Express server that mocks the APIs, and then
telling the dev server to proxy requests to the API paths to this express instance.
*/
/* eslint-disable no-console */
@erzr
erzr / ClientSidePlaceholder.js
Last active Dec 1, 2019
ClientSidePlaceholder for Sitecore JSS
View ClientSidePlaceholder.js
import React from 'react';
import { withSitecoreContext, dataApi, Placeholder } from '@sitecore-jss/sitecore-jss-react';
import { dataFetcher } from './dataFetcher';
import config from './temp/config';
class ClientSidePlaceholder extends React.Component {
constructor(props) {
super(props);
this.state = {
@erzr
erzr / gist:8390990
Created Jan 12, 2014
jQuery Event Logging - Added some logging to jQuery 1.8.2 so it was easier to trace event propagation.
View gist:8390990
/*!
* jQuery JavaScript Library v1.8.2
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
@erzr
erzr / MonoTouch.Dialog Currency Element
Last active Dec 21, 2015
Really rough, but works well enough. Almost of an exact port of https://github.com/rodchile/UITextCurrencyField.
View MonoTouch.Dialog Currency Element
// Currency element, port of: https://github.com/rodchile/UITextCurrencyField
public class CurrencyElement : EntryElement
{
public CurrencyElement (string caption, string placeholder, string value)
: base(caption, placeholder, value)
{
}
private static string CleanString(string target)
@erzr
erzr / gist:4480660
Created Jan 8, 2013
Backbone Collection for YQL
View gist:4480660
var YqlCollection = Backbone.Collection.extend({
query: '',
url: 'http://query.yahooapis.com/v1/public/yql',
format: 'json',
timeout: 10000,
dataType: 'jsonp',
fetch: function (options) {
options = options ? _.clone(options) : {};
options.data = options.data ? _.clone(options.data) : {};
if (!options.data.q) {
@erzr
erzr / gist:4254777
Created Dec 11, 2012
Javascript Prototype Pattern with Default Options
View gist:4254777
var Slideshow = (function($) {
function Slideshow(options) {
var defaults = {
timeout: 0.5,
selector: '.content'
};
this.options = $.extend(defaults, options);
};
@erzr
erzr / gist:4115787
Created Nov 20, 2012
Yahoo GeoPlanet (WOEID) Lookup In Python
View gist:4115787
import requests
from django.conf import settings
def get_woeid(text):
if not text:
return
app_id = settings.WOEID_APP_ID
if not app_id:
@erzr
erzr / gist:4028975
Created Nov 7, 2012
Backbone.js and Django-Tastypie Autocomplete
View gist:4028975
var app = app || {};
app.models = app.models || {};
app.collections = app.collections || {};
app.views = app.views || {};
(function($, window) {
(function(models) {
models.Tag = Backbone.Tastypie.Model.extend({
urlRoot: '/api/v1/tag/'