Skip to content

Commit

Permalink
Merge pull request #20 from jamesronan/jamesronan/issue17/raw_view_bu…
Browse files Browse the repository at this point in the history
…tton

Added "Raw Mosh" button
  • Loading branch information
jamesronan committed May 14, 2014
2 parents 2e0819e + 1da79cf commit 80303db
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 162 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
SpinalTapCodeMosh
=================

Yet another code-pastebin app powered by Dancer using the power of Backbone
Yet another code-pastebin app; Powered by Dancer using the power of Backbone
for the UI.

Still has some bugs and missing features I want to add, but it's currently a
working RC that I'll use and see what really needs fixing / adding.

This has no affiliation with the band or any orthopedic procedures. Is so named
due to the components that power it.
due to the components that power it, and it's intended use.

Prereqs
-------
Expand Down
10 changes: 8 additions & 2 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,24 @@ form span#channels span {
#moshpit {
position: relative;
margin: 20px 0px 0px 0px;
width: 825px;
}

#moshpit h3 {
position: absolute;
top: 0px;
right: 75px;
right: 22px;
margin: 0px;
font-size: 14px;
text-align: right;
color: rgba(100,100,100,0.6);
}

#moshpit button#get-raw {
position: absolute;
top: -50px;
right: 22px;
margin: 0px 0px 0px 0px !important;
}
#moshpit section h4 {
display: inline;
float: left;
Expand Down
8 changes: 7 additions & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
'brush: ' + this.model.attributes.syntax + ';'
);
}
// Attach a listen to the Raw Mosh button
var moshId = this.model.id;
this.$el.find('button#get-raw').click(function(e) {
e.preventDefault();
window.open('/mosh/raw/'+moshId, '_blank');
});

return this;
},
setLineHighlight: function() {
Expand Down Expand Up @@ -85,7 +92,6 @@
} else {
anchorLines.push(line);
}
console.log(anchorLines);
this.updateAnchor(anchorLines);
},
getAnchorHashLineNumbers: function() {
Expand Down
20 changes: 20 additions & 0 deletions lib/SpinalTapCodeMosh.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ get '/mosh/recent' => sub {
return [ @moshes ];
};

# Add a route allowing people to see the content of moshes in it's raw form.
get '/mosh/raw/:id' => sub {
my $mosh = database->quick_select(
'moshes',
{
id => params->{id}
}
);

if (!$mosh) {
status HTTP_NOT_FOUND;
return {};
}

# If we have a mosh, we need to set the content type to text/plain, then
# dump the mosh out.
header 'content-type' => 'text/plain';
return $mosh->{data};
};

get '/mosh/:id' => sub {
set 'serializer' => 'JSON';
my $mosh = database->quick_select(
Expand Down
16 changes: 12 additions & 4 deletions public/assets/all-q0XQ2QNb.js → public/assets/all-6XL7WvJA.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

148 changes: 0 additions & 148 deletions views/index.tt
Original file line number Diff line number Diff line change
@@ -1,148 +0,0 @@

<!--
Credit goes to the Ruby on Rails team for this page
has been heavily based on the default Rails page that is
built with a scaffolded application.

Thanks a lot to them for their work.

See Ruby on Rails if you want a kickass framework in Ruby:
http://www.rubyonrails.org/
-->

<div id="page">
<div id="sidebar">
<ul id="sidebar-items">
<li>
<h3>Join the community</h3>
<ul class="links">

<li><a href="http://perldancer.org/">PerlDancer</a></li>
<li><a href="http://twitter.com/PerlDancer/">Official Twitter</a></li>
<li><a href="https://github.com/sukria/Dancer/">GitHub Community</a></li>
</ul>
</li>

<li>
<h3>Browse the documentation</h3>

<ul class="links">
<li><a
href="http://search.cpan.org/dist/Dancer/lib/Dancer/Introduction.pod">Introduction</a></li>
<li><a href="http://search.cpan.org/dist/Dancer/lib/Dancer/Cookbook.pod">Cookbook</a></li>
<li><a href="http://search.cpan.org/dist/Dancer/lib/Dancer/Deployment.pod">Deployment Guide</a></li>
<li><a
href="http://search.cpan.org/dist/Dancer/lib/Dancer/Tutorial.pod"
title="a tutorial to build a small blog engine with Dancer">Tutorial</a></li>
</ul>
</li>

<li>
<h3>Your application's environment</h3>

<ul>
<li>Location: <code>/home/jamesr/Desktop/SpinalTapCodeMosh</code></li>
<li>Template engine: <code><% settings.template %></code></li>
<li>Logger: <code><% settings.logger %></code></li>
<li>Environment: <code><% settings.environment %></code></li>
</ul>

</li>
</ul>

</div>

<div id="content">
<div id="header">
<h1>Perl is dancing</h1>
<h2>You&rsquo;ve joined the dance floor!</h2>
</div>

<div id="getting-started">
<h1>Getting started</h1>
<h2>Here&rsquo;s how to get dancing:</h2>

<h3><a href="#" id="about_env_link">About your application's environment</a></h3>

<div id="about-content" style="display: none;">
<table>
<tbody>
<tr>
<td>Perl version</td>
<td><tt><% perl_version %></tt></td>
</tr>
<tr>
<td>Dancer version</td>
<td><tt><% dancer_version %></tt></td>
</tr>
<tr>
<td>Backend</td>
<td><tt><% settings.apphandler %></tt></td>
</tr>
<tr>
<td>Appdir</td>
<td><tt>/home/jamesr/Desktop/SpinalTapCodeMosh</tt></td>
</tr>
<tr>
<td>Template engine</td>
<td><tt><% settings.template %></tt></td>
</tr>
<tr>
<td>Logger engine</td>
<td><tt><% settings.logger %></tt></td>
</tr>
<tr>
<td>Running environment</td>
<td><tt><% settings.environment %></tt></td>
</tr>
</tbody>
</table>
</div>

<script type="text/javascript">
$('#about_env_link').click(function() {
$('#about-content').slideToggle('fast', function() {
// ok
});
return( false );
});
</script>


<ol>
<li>
<h2>Tune your application</h2>

<p>
Your application is configured via a global configuration file,
<tt>config.yml</tt> and an "environment" configuration file,
<tt>environments/development.yml</tt>. Edit those files if you
want to change the settings of your application.
</p>
</li>

<li>
<h2>Add your own routes</h2>

<p>
The default route that displays this page can be removed,
it's just here to help you get started. The template used to
generate this content is located in
<code>views/index.tt</code>.
You can add some routes to <tt>lib/SpinalTapCodeMosh.pm</tt>.
</p>
</li>

<li>
<h2>Enjoy web development again</h2>

<p>
Once you've made your changes, restart your standalone server
(bin/app.pl) and you're ready to test your web application.
</p>
</li>

</ol>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion views/minified-css.tt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<link rel="stylesheet" type="text/css" href="/assets/all-dMl1UxD9.css">
<link rel="stylesheet" type="text/css" href="/assets/all-u5WhD3h1.css">
2 changes: 1 addition & 1 deletion views/minified-js.tt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<script type="text/javascript" src="/assets/all-q0XQ2QNb.js"></script>
<script type="text/javascript" src="/assets/all-6XL7WvJA.js"></script>
1 change: 1 addition & 0 deletions views/mustache-templates.tt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<h3>Mosh {{id}}<br>{{created}}</h3>
<section><h4>Title:</h4>{{subject}}</section>
<section><h4>Posted by:</h4>{{poster}}</section>
<button id="get-raw" class="btn">Raw Mosh</button>
<div class="mosh">
<pre>{{data}}</pre>
{{#syntax}}
Expand Down

0 comments on commit 80303db

Please sign in to comment.