1 class NotesController < ApplicationController
6 before_action :check_api_readable
7 before_action :authorize_web
8 before_action :require_oauth
12 before_action :lookup_user, :only => [:index]
13 before_action :set_locale
14 around_action :web_timeout
17 # Display a list of notes by a specified user
19 param! :page, Integer, :min => 1
21 @params = params.permit(:display_name)
22 @title = t ".title", :user => @user.display_name
23 @page = (params[:page] || 1).to_i
26 @notes = @notes.visible unless current_user&.moderator?
27 @notes = @notes.order("updated_at DESC, id").distinct.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author)
29 render :layout => "site"
35 if current_user&.moderator?
36 @note = Note.find(params[:id])
37 @note_comments = @note.comments.unscope(:where => :visible)
39 @note = Note.visible.find(params[:id])
40 @note_comments = @note.comments
42 rescue ActiveRecord::RecordNotFound
43 render :template => "browse/not_found", :status => :not_found