Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rwdaigle/gisted
base: 51420dcb99
...
head fork: rwdaigle/gisted
compare: 37de7a27fb
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
2  app/controllers/application_controller.rb
@@ -1,6 +1,8 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ helper_method :current_user
protected
View
3  app/controllers/sessions_controller.rb
@@ -12,7 +12,8 @@ def logout
def create
user = User.authenticate(request.env['omniauth.auth'])
log_in_user(user.id)
+ log({ns: self.class, fn: __method__, measure: true, at: 'login'}, user)
+ QC.enqueue("GistFetcher.fetch_user", user.id) if !user.fetched?
redirect_to search_gists_path
- log({ns: self, fn: __method__, measure: true, at: 'login'}, user)
end
end
View
19 app/models/gist.rb
@@ -48,16 +48,19 @@ def import(gh_gist)
end
def search(user, q)
- q = q.blank? ? '*' : q
log({ns: self, fn: __method__, query: q, measure: true, at: 'search'}, user)
- log({ns: self, fn: __method__, query: q, measure: true}, user) do
- tire.search do
- query { string q }
- sort { by :gh_created_at, 'desc' }
- filter :term, :user_id => user.id
- highlight :description, :'files.content'
- size 15
+ if(!q.blank?)
+ log({ns: self, fn: __method__, query: q, measure: true}, user) do
+ tire.search do
+ query { string q }
+ sort { by :gh_created_at, 'desc' }
+ filter :term, :user_id => user.id
+ highlight :description, :'files.content'
+ size 15
+ end
end
+ else
+ []
end
end
View
4 app/models/user.rb
@@ -27,6 +27,10 @@ def authenticate(auth)
end
end
+ def fetched?
+ !last_gh_fetch.nil?
+ end
+
def to_log
{ user: gh_username, user_id: id, user_email: gh_email }
end
View
14 app/views/gists/search.html.haml
@@ -1,4 +1,9 @@
-= "Search for \"#{params[:q]}\""
+%p
+ = form_tag(search_gists_path, :method => "get") do
+ = label_tag(:q, "Search your gists:")
+ = text_field_tag(:q, params[:q])
+ = submit_tag("Go")
+ = "(last updated: #{current_user.last_gh_fetch ? current_user.last_gh_fetch.to_formatted_s(:short) : "not yet"})"
%ul
- for result in @results
@@ -12,4 +17,9 @@
%code= highlight
- else
%li
- %p= link_to(result.description, result.url)
+ %p= link_to(result.description, result.url)
+
+:javascript
+ $(function() {
+ $('#q').select();
+ })

No commit comments for this range

Something went wrong with that request. Please try again.