Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browsing without login by setting environment variable #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class ApplicationController < ActionController::Base
helper_method :current_user

before_action :require_login
if ENV.has_key? 'DMEMO_ALLOW_ANONYMOUS_TO_READ'
skip_before_action :require_login, only: [:index, :show]
end
before_action :set_sidebar_databases, :set_search_result, only: %w(index show new edit)

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/top_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
class TopController < ApplicationController
def show
@database_memos = DatabaseMemo.all.includes(:data_source, schema_memos: :table_memos).sort_by(&:display_order)
@favorite_tables = TableMemo.where(id: current_user.favorite_tables.pluck(:table_memo_id))
if current_user
@favorite_tables = TableMemo.where(id: current_user.favorite_tables.pluck(:table_memo_id))
else
@favorite_tables = []
end
end
end
9 changes: 5 additions & 4 deletions app/views/shared/_main_sidebar.html.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
%aside.main-sidebar
%section.sidebar
.user-panel
.pull-left.image
= image_tag current_user.image_url, class: "img-rounded"
.pull-left.info
%p= current_user.name
- if current_user
.pull-left.image
= image_tag current_user.image_url, class: "img-rounded"
.pull-left.info
%p= current_user.name

= form_for @search_result, method: :get, html: { class: "sidebar-form" } do |f|
.input-group
Expand Down
30 changes: 18 additions & 12 deletions app/views/shared/_navbar.html.haml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
%nav.navbar.navbar-static-top{ role: "navigation" }
.navbar-custom-menu
%ul.nav.navbar-nav
%li
= link_to setting_path do
%i.fa.fa-gear
Setting
%li
= link_to edit_user_path(current_user) do
%i.fa.fa-user
= current_user.name
%li
= link_to logout_path, method: :delete do
%i.fa.fa-sign-out
Sign-out
- if current_user
%li
= link_to setting_path do
%i.fa.fa-gear
Setting
%li
= link_to edit_user_path(current_user) do
%i.fa.fa-user
= current_user.name
%li
= link_to logout_path, method: :delete do
%i.fa.fa-sign-out
Sign-out
- else
%li
= link_to google_oauth2_path(state: url_for(params.merge(only_path: true))) do
%i.fa.fa-sign-in
Login
5 changes: 3 additions & 2 deletions app/views/table_memos/_column_memo.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
- if column_memo.logs.present?
= link_to column_memo_logs_path(column_memo.id), class: "pull-right colorbox" do
%i.fa.fa-clock-o
= link_to edit_column_memo_path(column_memo), class: "pull-right colorbox" do
%i.fa.fa-edit
- if current_user
= link_to edit_column_memo_path(column_memo), class: "pull-right colorbox" do
%i.fa.fa-edit
.column-description
- if column_memo.description.present?
= column_memo.description_html
Expand Down
13 changes: 7 additions & 6 deletions app/views/table_memos/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
- content_for :header do
%h1.page-header
= @table_memo.name
- favorited_status = @table_memo.favorited_by?(current_user) ? "favorited" : "unfavorited"
%span.favorite-table-block{ class: favorited_status }
= link_to table_memo_favorite_table_path(@table_memo.id), method: :delete, remote: true, class: "unfavorite-table-link" do
%i.fa.fa-star
= link_to table_memo_favorite_table_path(@table_memo.id), method: :post, remote: true, class: "favorite-table-link" do
%i.fa.fa-star-o
- if current_user
- favorited_status = @table_memo.favorited_by?(current_user) ? "favorited" : "unfavorited"
%span.favorite-table-block{ class: favorited_status }
= link_to table_memo_favorite_table_path(@table_memo.id), method: :delete, remote: true, class: "unfavorite-table-link" do
%i.fa.fa-star
= link_to table_memo_favorite_table_path(@table_memo.id), method: :post, remote: true, class: "favorite-table-link" do
%i.fa.fa-star-o
= link_to edit_table_memo_path(@table_memo) do
%i.fa.fa-edit

Expand Down
2 changes: 1 addition & 1 deletion app/views/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
- if user.admin?
%i.fa.fa-check
%td
- if current_user.editable_user?(user.id)
- if current_user and current_user.editable_user?(user.id)
= link_to edit_user_path(user) do
%i.fa.fa-edit
1 change: 0 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Application < Rails::Application

# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true

config.autoload_paths << "#{Rails.root}/lib/autoload"
end
end