Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Order bookmarks as they come out of the DB

  • Loading branch information...
commit f7ab49f05643927e6c9d0425649a0b7f4aa9ee06 1 parent 97a37ad
@cannikin authored
Showing with 24 additions and 1 deletion.
  1. +1 −1  app.rb
  2. +23 −0 views/sample.erb
View
2  app.rb
@@ -53,7 +53,7 @@
# List bookmarks
get '/:u/bookmarks' do
if @user = User.where(:uuid => params[:u]).first
- bookmarks = Bookmark.where(:user_id => @user.id).collect { |b| bookmark_output(b) }
+ bookmarks = Bookmark.where(:user_id => @user.id).order('created_at').collect { |b| bookmark_output(b) }
callback_wrapper do
bookmarks.to_json
View
23 views/sample.erb
@@ -288,7 +288,30 @@
</div>
<div class="main">
+ <a id="link" title="BookmarkBookmark">BookmarkBookmark</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ <script type="text/javascript">
+ content = "javascript:(function(){";
+ content += " var w = window,";
+ content += " d = window.document,";
+ content += " s = d.createElement('script'),";
+ content += " l = encodeURIComponent(w.location),";
+ content += " lib = ('__proto__' in {} ? 'zepto' : 'jquery'),";
+ content += " u = '//' + location.host + '/bkbk.js?u=9c8ee790-880d-012f-bf7e-60f8472ce36e&lib='+lib;";
+ content += " alert(u);"
+ content += " function load() {";
+ content += " if (d.readyState && d.readyState != 'complete') {";
+ content += " setTimeout(load, 200);";
+ content += " } else {";
+ content += " s.setAttribute('src', u);";
+ content += " s.setAttribute('type', 'text/javascript');";
+ content += " d.body.appendChild(s);";
+ content += " }";
+ content += " }";
+ content += " load();";
+ content += "}())";
+ document.getElementById('link').setAttribute('href', content);
+ </script>
</div>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.