Contest stuff embed stuff etc

master
Nick Sergeant 2012-02-20 13:45:04 -05:00
parent cd9be7c447
commit 92d0baea1d
9 changed files with 276 additions and 121 deletions

View File

@ -887,6 +887,9 @@ section.main {
background: transparent url("https://snipt.s3.amazonaws.com/images/upgrade-icon.png") 2px center no-repeat; }
section.main aside.main nav.footer ul li.groups {
background: transparent url("https://snipt.s3.amazonaws.com/images/groups-icon.png") 2px center no-repeat; }
section.main div.rochester-made {
margin: 50px 0 30px 0;
text-align: center; }
section.main-edit div.inner {
float: none;
@ -1152,7 +1155,8 @@ article.snipt {
box-shadow: 0 0 20px #85D2DD; }
article.snipt.selected div.container:after {
display: none; }
article.snipt div.copy-modal textarea {
article.snipt div.modal textarea {
font: normal 12px/16px Consolas, Menlo, "Courier New", monospace;
height: 200px;
margin: 0;
width: 520px; }
@ -1192,29 +1196,30 @@ div#keyboard-shortcuts {
div#keyboard-shortcuts table {
margin-bottom: 0; }
div#disqus_thread {
margin-bottom: 0;
margin-left: 15px;
width: 825px; }
div#disqus_thread #dsq-content {
margin-top: -38px; }
div#disqus_thread #dsq-content #dsq-global-toolbar {
margin-bottom: 18px;
margin-top: 0; }
div#disqus_thread #dsq-content #dsq-sort-by {
display: none; }
div#disqus_thread #dsq-content .dsq-comment-text {
color: #666; }
div#disqus_thread #dsq-content h3 {
display: none; }
div#disqus_thread #dsq-content .dsq-textarea-wrapper {
overflow: hidden; }
div#disqus_thread #dsq-footer {
display: none; }
body.detail div.right-y {
display: none; }
body.detail section.main div.inner {
width: 100%; }
body.detail section.main div.inner section.snipts div#disqus_thread {
margin-bottom: 0;
margin-left: 15px;
width: 825px; }
body.detail section.main div.inner section.snipts div#disqus_thread #dsq-content {
margin-top: -38px; }
body.detail section.main div.inner section.snipts div#disqus_thread #dsq-content #dsq-global-toolbar {
margin-bottom: 18px;
margin-top: 0; }
body.detail section.main div.inner section.snipts div#disqus_thread #dsq-content #dsq-sort-by {
display: none; }
body.detail section.main div.inner section.snipts div#disqus_thread #dsq-content .dsq-comment-text {
color: #666; }
body.detail section.main div.inner section.snipts div#disqus_thread #dsq-content h3 {
display: none; }
body.detail section.main div.inner section.snipts div#disqus_thread #dsq-content .dsq-textarea-wrapper {
overflow: hidden; }
body.detail section.main div.inner section.snipts div#disqus_thread #dsq-footer {
display: none; }
body.detail section.main div.inner section.snipts article.snipt {
margin-bottom: 0; }
body.detail section.main div.inner section.snipts article.snipt div.container {
@ -1228,6 +1233,8 @@ body.detail section.main div.inner {
height: 23px; }
body.detail section.main div.inner section.snipts article.snipt aside {
margin-right: 0; }
body.detail div.rochester-made {
width: 840px; }
body.static .static-box {
background: rgba(255, 255, 255, 0.65);
@ -1256,6 +1263,17 @@ body.static .static-box {
body.static .static-box div.alert-info a {
color: #3A87AD;
text-decoration: underline; }
body.static .static-box ul {
margin-bottom: 15px;
margin-top: 15px; }
body.static .static-box ul li {
font-size: 13px;
line-height: 18px;
margin: 5px 0; }
body.static .static-box h3 {
margin-bottom: 20px; }
body.static .static-box p {
margin: 15px 0; }
body.static aside.main {
padding-top: 20px; }
body.static div.alert-alone {
@ -1268,6 +1286,11 @@ body.static form.form-horizontal fieldset {
padding-top: 27px; }
body.static form.form-horizontal fieldset legend {
margin: 0; }
body.static div#disqus_thread {
margin-left: 20px;
width: 709px; }
body.static div#disqus_thread div#dsq-content {
margin-top: 23px; }
.autumn { background-color: #FFF; color: #000; }
.autumn .hll { background-color: #ffffcc }
.autumn .c { color: #aaaaaa; font-style: italic } /* Comment */

View File

@ -943,7 +943,7 @@ jQuery(function($) {
this.$search_form = $('form.search', this.$el);
this.$search_query = $('input#search-query', this.$el);
this.$snipts = $('section#snipts article.snipt', this.$el);
this.$copyModals = $('div.copy-modal', this.$snipts);
this.$modals = $('div.modal', this.$snipts);
this.keyboardShortcuts();
this.inFieldLabels();
@ -953,7 +953,7 @@ jQuery(function($) {
SniptList = new SniptListView({ 'snipts': this.$snipts });
$('body').click(function() {
if (window.$selected) {
if (window.$selected && !$('div.modal-body:visible', window.site.$modals).length) {
window.$selected.trigger('deselect');
}
});
@ -974,6 +974,7 @@ jQuery(function($) {
$(this).parent().parent().modal('hide');
return false;
});
},
events: {
'showKeyboardShortcuts': 'showKeyboardShortcuts'
@ -1045,7 +1046,7 @@ jQuery(function($) {
events: {
'click a.copy': 'copyFromClick',
'click a.edit': 'edit',
'click a.embed': 'embed',
'click a.embed': 'embedFromClick',
'click a.expand': 'expand',
'click .container': 'selectFromClick',
'copyRaw': 'copy',
@ -1054,6 +1055,7 @@ jQuery(function($) {
'deselect': 'deselect',
'edit': 'edit',
'embed': 'embed',
'embedClose': 'embedClose',
'expand': 'expand',
'next': 'next',
'prev': 'prev',
@ -1062,19 +1064,9 @@ jQuery(function($) {
copy: function() {
if (!this.$copyModal.is(':visible')) {
var cmd;
if (navigator.platform == 'MacPPC' ||
navigator.platform == 'MacIntel') {
cmd = 'Cmd';
}
else {
cmd = 'Ctrl';
}
this.$copyModalBody.append('<textarea class="raw"></textarea>');
$textarea = $('textarea.raw', this.$copyModalBody).val(this.$raw.text());
$textarea = $('textarea.raw', this.$copyModalBody).val(this.model.get('code'));
this.$copyModalType.text(cmd);
this.$copyModal.modal('show');
$textarea.select();
}
@ -1087,10 +1079,8 @@ jQuery(function($) {
return false;
},
deselect: function() {
if (!this.$copyModal.is(':visible')) {
this.$el.removeClass('selected');
window.$selected = false;
}
this.$el.removeClass('selected');
window.$selected = false;
},
detail: function() {
window.location = this.model.get('get_absolute_url');
@ -1105,7 +1095,19 @@ jQuery(function($) {
return false;
},
embed: function() {
alert('TODO');
if (!this.$embedModal.is(':visible')) {
this.$embedModalBody.append('<textarea class="raw"></textarea>');
$textarea = $('textarea.raw', this.$embedModalBody).val('<script type="text/javascript">' + this.model.get('embed_url') + '</script>');
this.$embedModal.modal('show');
$textarea.select();
}
},
embedClose: function() {
$('textarea', this.$embedModal).remove();
},
embedFromClick: function() {
this.embed();
return false;
},
expand: function() {
@ -1118,30 +1120,37 @@ jQuery(function($) {
this.$el = $(this.el);
this.$aside = $('aside', this.$el);
this.$container = $('div.container', this.$el);
this.$copyModal = $('div.copy-modal', this.$el);
this.$copyModalBody = $('div.modal-body', this.$copyModal);
this.$copyModalClose = $('a.close', this.$copyModal);
this.$copyModalType = $('h4 span', this.$copyModal);
this.$embedModal = $('div.embed-modal', this.$el);
this.$embedModalBody = $('div.modal-body', this.$embedModal);
this.$h1 = $('header h1 a', this.$el);
this.$raw = $('div.raw', this.$el);
this.$tags = $('section.tags ul', this.$aside);
this.$copyModal.on('hidden', function(e) {
$(this).parent().trigger('copyClose');
});
this.$embedModal.on('hidden', function(e) {
$(this).parent().trigger('embedClose');
});
},
next: function() {
window.site.$copyModals.modal('hide');
nextSnipt = this.$el.next('article.snipt');
if (nextSnipt.length) {
return nextSnipt.trigger('selectSnipt');
if (!$('div.modal-body:visible', window.site.$modals).length) {
nextSnipt = this.$el.next('article.snipt');
if (nextSnipt.length) {
return nextSnipt.trigger('selectSnipt');
}
}
},
prev: function() {
window.site.$copyModals.modal('hide');
prevSnipt = this.$el.prev('article.snipt');
if (prevSnipt.length) {
return prevSnipt.trigger('selectSnipt');
if (!$('div.modal-body:visible', window.site.$modals).length) {
prevSnipt = this.$el.prev('article.snipt');
if (prevSnipt.length) {
return prevSnipt.trigger('selectSnipt');
}
}
},
remove: function() {
@ -1208,6 +1217,16 @@ jQuery(function($) {
this.$el = $(this.el);
this.keyboardShortcuts();
var cmd;
if (navigator.platform == 'MacPPC' ||
navigator.platform == 'MacIntel') {
cmd = 'Cmd';
}
else {
cmd = 'Ctrl';
}
$('span.cmd-ctrl').text(cmd);
},
addExistingSnipt: function() {
@ -1295,9 +1314,13 @@ jQuery(function($) {
if ($('section#main-edit:visible').length) {
$('section#main-edit').hide();
$('section#main').show();
$('html, body').animate({
scrollTop: $selected.offset().top - 50
}, 0);
if (SniptList.$snipts.index($selected) === 0) {
window.scrollTo(0, 0);
} else {
$('html, body').animate({
scrollTop: $selected.offset().top - 50
}, 0);
}
} else {
if ($selected) {
$selected.trigger('deselect');
@ -1339,8 +1362,9 @@ jQuery(function($) {
}
}
});
$document.bind('keydown', 'v', function() {
$document.bind('keydown', 'v', function(e) {
if ($selected) {
e.preventDefault();
$selected.trigger('embed');
}
});

View File

@ -408,7 +408,7 @@ section.main {
}
}
div.rochester-made {
margin: 100px 0 80px 0;
margin: 50px 0 30px 0;
text-align: center;
}
}
@ -762,8 +762,9 @@ article.snipt {
}
}
}
div.copy-modal {
div.modal {
textarea {
font: normal 12px/16px $Consolas;
height: 200px;
margin: 0;
width: 520px;
@ -826,6 +827,35 @@ div#keyboard-shortcuts {
margin-bottom: 0;
}
}
div#disqus_thread {
margin-bottom: 0;
margin-left: 15px;
width: 825px;
#dsq-content {
margin-top: -38px;
#dsq-global-toolbar {
margin-bottom: 18px;
margin-top: 0;
}
#dsq-sort-by {
display: none;
}
.dsq-comment-text {
color: #666;
}
h3 {
display: none;
}
.dsq-textarea-wrapper {
overflow: hidden;
}
}
#dsq-footer {
display: none;
}
}
// Pages
body.detail {
@ -837,35 +867,6 @@ body.detail {
width: 100%;
section.snipts {
div#disqus_thread {
margin-bottom: 0;
margin-left: 15px;
width: 825px;
#dsq-content {
margin-top: -38px;
#dsq-global-toolbar {
margin-bottom: 18px;
margin-top: 0;
}
#dsq-sort-by {
display: none;
}
.dsq-comment-text {
color: #666;
}
h3 {
display: none;
}
.dsq-textarea-wrapper {
overflow: hidden;
}
}
#dsq-footer {
display: none;
}
}
article.snipt {
margin-bottom: 0;
@ -930,6 +931,22 @@ body.static {
text-decoration: underline;
}
}
ul {
margin-bottom: 15px;
margin-top: 15px;
li {
font-size: 13px;
line-height: 18px;
margin: 5px 0;
}
}
h3 {
margin-bottom: 20px;
}
p {
margin: 15px 0;
}
}
aside.main {
padding-top: 20px;
@ -952,4 +969,12 @@ body.static {
}
}
}
div#disqus_thread {
margin-left: 20px;
width: 709px;
div#dsq-content {
margin-top: 23px;
}
}
}

View File

@ -12,7 +12,7 @@
this.$search_form = $('form.search', this.$el);
this.$search_query = $('input#search-query', this.$el);
this.$snipts = $('section#snipts article.snipt', this.$el);
this.$copyModals = $('div.copy-modal', this.$snipts);
this.$modals = $('div.modal', this.$snipts);
this.keyboardShortcuts();
this.inFieldLabels();
@ -22,7 +22,7 @@
SniptList = new SniptListView({ 'snipts': this.$snipts });
$('body').click(function() {
if (window.$selected) {
if (window.$selected && !$('div.modal-body:visible', window.site.$modals).length) {
window.$selected.trigger('deselect');
}
});
@ -43,6 +43,7 @@
$(this).parent().parent().modal('hide');
return false;
});
},
events: {
'showKeyboardShortcuts': 'showKeyboardShortcuts'

View File

@ -20,7 +20,7 @@
events: {
'click a.copy': 'copyFromClick',
'click a.edit': 'edit',
'click a.embed': 'embed',
'click a.embed': 'embedFromClick',
'click a.expand': 'expand',
'click .container': 'selectFromClick',
'copyRaw': 'copy',
@ -29,6 +29,7 @@
'deselect': 'deselect',
'edit': 'edit',
'embed': 'embed',
'embedClose': 'embedClose',
'expand': 'expand',
'next': 'next',
'prev': 'prev',
@ -37,19 +38,9 @@
copy: function() {
if (!this.$copyModal.is(':visible')) {
var cmd;
if (navigator.platform == 'MacPPC' ||
navigator.platform == 'MacIntel') {
cmd = 'Cmd';
}
else {
cmd = 'Ctrl';
}
this.$copyModalBody.append('<textarea class="raw"></textarea>');
$textarea = $('textarea.raw', this.$copyModalBody).val(this.$raw.text());
$textarea = $('textarea.raw', this.$copyModalBody).val(this.model.get('code'));
this.$copyModalType.text(cmd);
this.$copyModal.modal('show');
$textarea.select();
}
@ -62,10 +53,8 @@
return false;
},
deselect: function() {
if (!this.$copyModal.is(':visible')) {
this.$el.removeClass('selected');
window.$selected = false;
}
this.$el.removeClass('selected');
window.$selected = false;
},
detail: function() {
window.location = this.model.get('get_absolute_url');
@ -80,7 +69,19 @@
return false;
},
embed: function() {
alert('TODO');
if (!this.$embedModal.is(':visible')) {
this.$embedModalBody.append('<textarea class="raw"></textarea>');
$textarea = $('textarea.raw', this.$embedModalBody).val('<script type="text/javascript">' + this.model.get('embed_url') + '</script>');
this.$embedModal.modal('show');
$textarea.select();
}
},
embedClose: function() {
$('textarea', this.$embedModal).remove();
},
embedFromClick: function() {
this.embed();
return false;
},
expand: function() {
@ -93,30 +94,37 @@
this.$el = $(this.el);
this.$aside = $('aside', this.$el);
this.$container = $('div.container', this.$el);
this.$copyModal = $('div.copy-modal', this.$el);
this.$copyModalBody = $('div.modal-body', this.$copyModal);
this.$copyModalClose = $('a.close', this.$copyModal);
this.$copyModalType = $('h4 span', this.$copyModal);
this.$embedModal = $('div.embed-modal', this.$el);
this.$embedModalBody = $('div.modal-body', this.$embedModal);
this.$h1 = $('header h1 a', this.$el);
this.$raw = $('div.raw', this.$el);
this.$tags = $('section.tags ul', this.$aside);
this.$copyModal.on('hidden', function(e) {
$(this).parent().trigger('copyClose');
});
this.$embedModal.on('hidden', function(e) {
$(this).parent().trigger('embedClose');
});
},
next: function() {
window.site.$copyModals.modal('hide');
nextSnipt = this.$el.next('article.snipt');
if (nextSnipt.length) {
return nextSnipt.trigger('selectSnipt');
if (!$('div.modal-body:visible', window.site.$modals).length) {
nextSnipt = this.$el.next('article.snipt');
if (nextSnipt.length) {
return nextSnipt.trigger('selectSnipt');
}
}
},
prev: function() {
window.site.$copyModals.modal('hide');
prevSnipt = this.$el.prev('article.snipt');
if (prevSnipt.length) {
return prevSnipt.trigger('selectSnipt');
if (!$('div.modal-body:visible', window.site.$modals).length) {
prevSnipt = this.$el.prev('article.snipt');
if (prevSnipt.length) {
return prevSnipt.trigger('selectSnipt');
}
}
},
remove: function() {
@ -183,6 +191,16 @@
this.$el = $(this.el);
this.keyboardShortcuts();
var cmd;
if (navigator.platform == 'MacPPC' ||
navigator.platform == 'MacIntel') {
cmd = 'Cmd';
}
else {
cmd = 'Ctrl';
}
$('span.cmd-ctrl').text(cmd);
},
addExistingSnipt: function() {
@ -318,8 +336,9 @@
}
}
});
$document.bind('keydown', 'v', function() {
$document.bind('keydown', 'v', function(e) {
if ($selected) {
e.preventDefault();
$selected.trigger('embed');
}
});

View File

@ -63,7 +63,7 @@
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Copy snipt <span>&ldquo;{{ snipt.title }}&rdquo;</span></h3>
<h4>(Text is selected. <span></span>+c to copy.)</h4>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+c to copy.)</h4>
</div>
<div class="modal-body"></div>
</div>
@ -71,10 +71,9 @@
<div class="modal-header">
<a href="#" class="close">×</a>
<h3>Embed snipt <span>&ldquo;{{ snipt.title }}&rdquo;</span></h3>
<h4>(Text is selected. <span class="cmd-ctrl"></span>+c to copy.)</h4>
</div>
<div class="modal-body">
<textarea><script type="text/javascript">{{ snipt.get_embed_url }}</script></textarea>
</div>
<div class="modal-body"></div>
</div>
<div class="hide embed-url">{{ snipt.get_embed_url }}</div>
<div class="hide key">{{ snipt.key }}</div>

View File

@ -0,0 +1,61 @@
{% extends "base.html" %}
{% block page-title %}API - {{ block.super }}{% endblock %}
{% block body-class %}{{ block.super }} api static{% endblock %}
{% block sub-header %}{% endblock %}
{% block content %}
<div class="static-box">
<h3>Snipt API Contest</h3>
<p>Build an app that uses the new Snipt API and be entered to win two conference passes to <a href="http://aneventapart.com">An Event Apart</a> of your choosing (worth $1,800+). Public voting determines the winner.
<h4>Rules</h4>
<ul>
<li>App must be complete by <strong>Sunday, April 1st, 2012 at 11pm EST</strong>.</li>
<li>The app must be open-source (either Bitbucket, GitHub, or your sharing tool of choice).</li>
<li>The app must use some part of the public or private Snipt APIs.</li>
<li>App can be for desktop, mobile, CLI, etc. Anything goes.</li>
</ul>
<h4>API</h4>
<p>The API is finished on our end, but we need to get the site up on Snipt.net first so you can use real endpoint URLs, API keys, etc. The authentication mechanism is API-key (no OAuth). Data formats available are JSON, JSONP, XML, YAML.</p>
<p>The private APIs, once launched, will give you complete read/write access to a user's snipts.</p>
<p>Some sample public endpoints:</p>
<ul>
<li><a href="http://beta.snipt.net/api/public/?format=json">http://beta.snipt.net/api/public/?format=json</a></li>
<li><a href="http://beta.snipt.net/api/public/snipt/?format=json">http://beta.snipt.net/api/public/snipt/?format=json</a></li>
<li><a href="http://beta.snipt.net/api/public/snipt/30532/?format=json">http://beta.snipt.net/api/public/snipt/30532/?format=json</a></li>
<li><a href="http://beta.snipt.net/api/public/tag/?format=json">http://beta.snipt.net/api/public/tag/?format=json</a></li>
<li><a href="http://beta.snipt.net/api/public/snipt/?tag=20&amp;format=json">http://beta.snipt.net/api/public/snipt/?tag=20&amp;format=json</a></li>
<li><a href="http://beta.snipt.net/api/public/user/3/?format=json">http://beta.snipt.net/api/public/user/3/?format=json</a></li>
</ul>
<p>We will be launching the new Snipt sometime before March 1st, 2012. This will give you at least one full month to build the app.</p>
<h4>Teams</h4>
<ul>
<li>Feel free to partner up on this project, if you'd like. There are no restrictions on the number of team members participating, but there are only two tickets for prizes (see below).</li>
<li>One entry = one application (regardless of the number of team members)</li>
</ul>
<h4>Prize</h4>
<ul>
<li>Once your app is complete and submitted, it will appear in our app showcase. From there, anyone can vote for your app to win after <strong>Monday April 2nd at 11am EST</strong>, . The app with the most votes by <strong>Monday, April 9th at 11am EST</strong> will be the winner (one full week of voting).</li>
<li>The winner will receive two tickets to <a href="http://aneventapart.com">An Event Apart</a> of your choosing (event must not be sold-out). The ticket includes access to the 2-day conference but *not* the workshop.</li>
</ul>
<h4>Questions?</h4>
<p>Leave a comment below and we'll respond on this page.</p>
</div>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'snipt-net';
{% if debug %}
var disqus_developer = 1;
{% endif %}
var disqus_url = 'http://snipt.net{{ request.path }}';
var disqus_title = 'Snipt API Contest';
var disqus_identifier = 9948337532;
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
{% endblock %}

View File

@ -7,6 +7,8 @@
{% block content %}
<div class="static-box">
This is where the API documentation will be.
<div class="alert alert-info alert-alone">
This is where the API documentation will eventually live.
</div>
</div>
{% endblock %}

View File

@ -29,6 +29,7 @@ urlpatterns = patterns('',
url(r'^500/$', direct_to_template, {'template': '500.html'}),
url(r'^api/$', direct_to_template, {'template': 'api.html'}),
url(r'^api/contest/$', direct_to_template, {'template': 'api-contest.html'}),
url(r'^api/', include(public_api.urls)),
url(r'^api/', include(private_api.urls)),