Commits

John Louis del Rosario  committed 96aadef

Add SQL templates

  • Participants
  • Parent commits d1a4e46

Comments (0)

Files changed (7)

 SITENAME = 'r.doqdoq'
 
-SYNTAXES = {'python': 'Python', 'java': 'Java', }
+SYNTAXES = {'python': 'Python', 'java': 'Java', 'sql': 'SQL', }
 
 COLORSCHEMES = {'default': 'Default', 'vs': 'Visual Studio', 'monokai': 'Monokai'}
 

File templates/sql/comments.html

+{% extends "skeleton/base.html" %}
+
+{% block header %}
+{% include session.syntax+"/header.html" %}
+{% endblock %}
+
+{% block body %}
+{% include session.syntax+"/story.html" %}
+{% if story.is_self %}
+<div class="selfpost indent">
+	<span class="k">DECLARE</span> self_text <span class="k">CLOB</span> = <p class="s">{{ story.selftext }}</p>
+</div>
+<br/>
+{% endif %}
+<div class="comments">
+	{% if comments %}
+	{% for comment in comments recursive %}
+	<div class="indent">
+		{% if comment|get_type == "<class 'reddit.comment.Comment'>" %}
+		{# username #}<span class="k">SELECT</span> <span class="s">'{{comment.author}}'</span> as author,
+		{# date #}<span class="s">'{{comment.created_utc|timeago}}'</span> as posted, 
+		{# score #}<span class="m">{{comment.ups - comment.downs}}</span> as score, 
+		{# comment body #}<p class="s">'{{comment.body}}'</p>
+		{# comment replies #}
+		<div class="indent">
+				{% if comment.replies > 0 %}
+					{# recurse the loop passing the child comments <3 #}
+					{{ loop(comment.replies) }}
+				{% endif %}
+		</div>
+		{% else %}
+			<p class="c"><a href="{{story.permalink}}">-- more comments can be found on reddit </a></p>
+		{% endif %}
+	</div>
+	{% endfor %}
+	{% else %}
+		<div class="indent"><p class="c">-- There's nothing here! </p></span>
+	{% endif %}
+</div>
+{% endblock %}
+
+{% block footer %}
+{% include session.syntax+"/footer.html" %}
+{% endblock %}
+

File templates/sql/footer.html

+<p class="c">/* {% include "skeleton/footertext.html" %} */</p>

File templates/sql/header.html

+<p><span class="k">DELIMITER </span>$$</p>
+<p><span class="k">USE </span><a id="toggle-options" href="#" title="toggle options">options$$</a></p> 
+<p><span class="k">USE </span><a href="{{url_for('about')}}" title="about">about$$</a></p>
+<br/>
+<p><span class="k">DECLARE</span> <a href="/">home</a> <span class="k">TINYINT</span>(<span class="m">1</span>)</p>
+{% if session.username %}
+<p><span class="k">DECLARE</span> <a href="{{ url_for('logout') }}">logout</a> <span class="k">VARCHAR</span>(<span class="m">64</span>) = <span class="s">'{{session.username}}'</span></p>
+	<ul>
+	</ul>
+	{% if session.my_reddits %}
+	<br/>
+	<span class="k">SELECT</span> * <span class="k">FROM</span> my_subreddits
+	<br/>
+	<span class="k">WHERE</span> subreddit_name <span class="k">IN</span> (
+	<ul class="my_subreddits">
+	{% for r in session.my_reddits %}
+		<li><a href="{{url_for('subreddit', subreddit=r)}}" class="s">'{{r}}'</a>,</li>
+	{% endfor %}
+	</ul>
+	)
+	{% endif %}
+{% else %}
+<p><span class="k">DECLARE</span> <a href="{{ url_for('login') }}">login</a> <span class="k">VARCHAR</span>(<span class="m"64</span>)</p>
+{% endif %}

File templates/sql/index.html

+{% extends "skeleton/base.html" %}
+
+{% block header %}
+{% include session.syntax+"/header.html" %}
+{% endblock %}
+
+{% block body %}
+<span class="k">CREATE PROCEDURE </span>FrontPage()<br/>
+<span class="k">BEGIN </span>
+<br/>
+<div class="indent">
+{% if stories %}
+	<ul id="stories">
+	{% for story in stories %}
+	<li>
+	{% include session.syntax+"/story.html" %}
+	</li>
+	{% endfor %}
+	</ul>
+{% else %}
+	<p class="c">-- There's nothing here!</p>
+{% endif %}
+<br/><br/><span class="k">DECLARE </span>{% if count > session.num_stories %}<a href="{{ url_for('index') }}{%include "skeleton/before.html"%}">previous</a>{% else %}page{% endif %} = <a href="{{ url_for('index')}}{%include "skeleton/after.html"%}"><span class="s">'next';<span/></a>
+</div>
+<br/><span class="k">END$$ </span>
+
+{% endblock %}
+
+
+{% block footer %}
+{% include session.syntax+"/footer.html" %}
+{% endblock %}

File templates/sql/story.html

+{% if story.title|is_nsfw %}
+<span class="c">-- nsfw</span><br/>
+{% endif %}
+<span class="k">SELECT </span> 
+{# story title #}<a href="{% if story.is_self %}{{url_for('comments', subreddit=story.subreddit, story_id=story.id, story_slug=story.permalink|get_submission_slug)}}{% else %}{{ story.url }}{% endif %}" {% if story.url|is_image and session.preview and not story.title|is_nsfw %}class="imglink"{% endif %}><span class="s">'{{ story.title }}'</span></a> as title,<br/>
+{# story info #}<p class="indent"> <a href="{{ url_for('comments', subreddit=story.subreddit, story_slug=story.permalink|get_submission_slug, story_id=story.id) }}"><span class="m">{{ story.num_comments }}</span> as comments</a>,
+<br/> <span class="m">{{ story.score }}</span> as score,
+<br/> <span class="m">'{{ story.selftext }}'</span> as self_text
+<p/>
+<span class="k">FROM </span> subreddit.<a href="{{ url_for('subreddit', subreddit=story.subreddit) }}">{{ story.subreddit }}</a><br/>
+<span class="k">WHERE </span> poster = <span class="s">'{{ story.author }}'</span>
+<span class="k">  AND </span> site = <span class="s">'{{ story.domain }}'</span>
+<span class="k">  AND </span> posted = <span class="s">'{{story.created_utc|timeago}}'</span>;

File templates/sql/subreddit.html

+{% extends "skeleton/base.html" %}
+
+{% block header %}
+{% include session.syntax+"/header.html" %}
+{% endblock %}
+
+{% block body %}
+
+<span class="k">CREATE PROCEDURE </span>Subreddit(<span class="k">IN </span>{{subreddit.display_name}} <span class="k">VARCHAR(64)</span>)<br/>
+<span class="k">BEGIN </span>
+<br/>
+<div class="indent">
+{% if stories %}
+	<ul>
+	{% for story in stories %}
+	<li>
+	{% include session.syntax+"/story.html" %}
+	</li>
+	{% endfor %}
+	</ul>
+{% else %}
+	<p class="c"># There's nothing here!</p>
+{% endif %}
+
+<br/><br/><span class="k">DECLARE </span>{% if count > session.num_stories %}<a href="{{ url_for('subreddit', subreddit=subreddit.display_name) }}{%include "skeleton/before.html"%}">previous()</a>{% else %}page{% endif %} = <a href="{{ url_for('subreddit', subreddit=subreddit.display_name)}}{%include "skeleton/after.html"%}"><span class="s">'next'<span/></a>
+<div/>
+<br/><span class="k">END$$ </span>
+
+{% endblock %}
+
+
+{% block footer %}
+{% include session.syntax+"/footer.html" %}
+{% endblock %}