diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92f67fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore all paperclip uploads +/public/system + +.DS_Store \ No newline at end of file diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..913cd13 --- /dev/null +++ b/Capfile @@ -0,0 +1,38 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +require "capistrano/deploy" + +# Load the SCM plugin appropriate to your project: +# +# require "capistrano/scm/hg" +# install_plugin Capistrano::SCM::Hg +# or +# require "capistrano/scm/svn" +# install_plugin Capistrano::SCM::Svn +# or +require "capistrano/scm/git" +install_plugin Capistrano::SCM::Git + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# + +require 'capistrano/rails' +require 'capistrano/passenger' + +require 'capistrano/rbenv' +set :rbenv_type, :user +set :rbenv_ruby, '2.4.0' + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..6bea7fc --- /dev/null +++ b/Gemfile @@ -0,0 +1,44 @@ +source 'https://rubygems.org' + +git_source(:github) do |repo_name| + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") + "https://github.com/#{repo_name}.git" +end + +gem 'rails', '~> 5.0.1' +gem 'puma', '~> 3.0' +gem 'sass-rails', '~> 5.0' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.2' +gem 'jquery-rails' +gem 'jbuilder', '~> 2.5' +gem 'redis', '~> 3.0' + +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +group :development do + gem 'sqlite3' + gem 'meta_request' + gem 'web-console' + gem "awesome_print", require:"ap" +end +group :production do + gem 'pg' +end + +gem 'haml' +gem 'paperclip' +gem 'simple_form' +gem 'bootstrap-sass' +gem 'devise' +gem 'acts_as_votable' +gem 'kaminari' + +gem 'rails_admin' + +gem 'remotipart', '~> 1.2' + +gem 'capistrano', '~> 3.7', '>= 3.7.1' +gem 'capistrano-rails', '~> 1.2' +gem 'capistrano-passenger', '~> 0.2.0' +gem 'capistrano-rbenv', '~> 2.1' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..0226431 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,266 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.0.1) + actionpack (= 5.0.1) + nio4r (~> 1.2) + websocket-driver (~> 0.6.1) + actionmailer (5.0.1) + actionpack (= 5.0.1) + actionview (= 5.0.1) + activejob (= 5.0.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.0.1) + actionview (= 5.0.1) + activesupport (= 5.0.1) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.0.1) + activesupport (= 5.0.1) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (5.0.1) + activesupport (= 5.0.1) + globalid (>= 0.3.6) + activemodel (5.0.1) + activesupport (= 5.0.1) + activerecord (5.0.1) + activemodel (= 5.0.1) + activesupport (= 5.0.1) + arel (~> 7.0) + activesupport (5.0.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) + acts_as_votable (0.10.0) + airbrussh (1.1.2) + sshkit (>= 1.6.1, != 1.7.0) + arel (7.1.4) + autoprefixer-rails (6.6.1) + execjs + awesome_print (1.7.0) + bcrypt (3.1.11-x86-mingw32) + bootstrap-sass (3.3.7) + autoprefixer-rails (>= 5.2.1) + sass (>= 3.3.4) + builder (3.2.2) + callsite (0.0.11) + capistrano (3.7.1) + airbrussh (>= 1.0.0) + capistrano-harrow + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-bundler (1.2.0) + capistrano (~> 3.1) + sshkit (~> 1.2) + capistrano-harrow (0.5.3) + capistrano-passenger (0.2.0) + capistrano (~> 3.0) + capistrano-rails (1.2.2) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-rbenv (2.1.0) + capistrano (~> 3.1) + sshkit (~> 1.3) + climate_control (0.1.0) + cocaine (0.5.8) + climate_control (>= 0.0.3, < 1.0) + coffee-rails (4.2.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.2.x) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.0.4) + debug_inspector (0.0.2) + devise (4.2.0) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0, < 5.1) + responders + warden (~> 1.2.3) + erubis (2.7.0) + execjs (2.7.0) + font-awesome-rails (4.7.0.1) + railties (>= 3.2, < 5.1) + globalid (0.3.7) + activesupport (>= 4.1.0) + haml (4.0.7) + tilt + i18n (0.7.0) + jbuilder (2.6.1) + activesupport (>= 3.0.0, < 5.1) + multi_json (~> 1.2) + jquery-rails (4.2.2) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + jquery-ui-rails (5.0.5) + railties (>= 3.2.16) + kaminari (0.17.0) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.4) + mime-types (>= 1.16, < 4) + meta_request (0.4.0) + callsite (~> 0.0, >= 0.0.11) + rack-contrib (~> 1.1) + railties (>= 3.0.0, < 5.1.0) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mimemagic (0.3.2) + mini_portile2 (2.1.0) + minitest (5.10.1) + multi_json (1.12.1) + nested_form (0.3.2) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (4.0.1) + nio4r (1.2.1) + nokogiri (1.7.0.1-x86-mingw32) + mini_portile2 (~> 2.1.0) + orm_adapter (0.5.0) + paperclip (5.1.0) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) + cocaine (~> 0.5.5) + mime-types + mimemagic (~> 0.3.0) + pg (0.19.0-x86-mingw32) + puma (3.6.2) + rack (2.0.1) + rack-contrib (1.2.0) + rack (>= 0.9.1) + rack-pjax (1.0.0) + nokogiri (~> 1.5) + rack (>= 1.1) + rack-test (0.6.3) + rack (>= 1.0) + rails (5.0.1) + actioncable (= 5.0.1) + actionmailer (= 5.0.1) + actionpack (= 5.0.1) + actionview (= 5.0.1) + activejob (= 5.0.1) + activemodel (= 5.0.1) + activerecord (= 5.0.1) + activesupport (= 5.0.1) + bundler (>= 1.3.0, < 2.0) + railties (= 5.0.1) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.2) + activesupport (>= 4.2.0, < 6.0) + nokogiri (~> 1.6) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + rails_admin (1.1.1) + builder (~> 3.1) + coffee-rails (~> 4.0) + font-awesome-rails (>= 3.0, < 5) + haml (~> 4.0) + jquery-rails (>= 3.0, < 5) + jquery-ui-rails (~> 5.0) + kaminari (~> 0.14) + nested_form (~> 0.3) + rack-pjax (>= 0.7) + rails (>= 4.0, < 6) + remotipart (~> 1.3) + sass-rails (>= 4.0, < 6) + railties (5.0.1) + actionpack (= 5.0.1) + activesupport (= 5.0.1) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (12.0.0) + redis (3.3.2) + remotipart (1.3.1) + responders (2.3.0) + railties (>= 4.2.0, < 5.1) + sass (3.4.23) + sass-rails (5.0.6) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + simple_form (3.4.0) + actionpack (> 4, < 5.1) + activemodel (> 4, < 5.1) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.13-x86-mingw32) + sshkit (1.11.5) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) + thor (0.19.4) + thread_safe (0.3.5) + tilt (2.0.5) + tzinfo (1.2.2) + thread_safe (~> 0.1) + tzinfo-data (1.2016.10) + tzinfo (>= 1.0.0) + uglifier (3.0.4) + execjs (>= 0.3.0, < 3) + warden (1.2.6) + rack (>= 1.0) + web-console (3.4.0) + actionview (>= 5.0) + activemodel (>= 5.0) + debug_inspector + railties (>= 5.0) + websocket-driver (0.6.4) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) + +PLATFORMS + x86-mingw32 + +DEPENDENCIES + acts_as_votable + awesome_print + bootstrap-sass + capistrano (~> 3.7, >= 3.7.1) + capistrano-passenger (~> 0.2.0) + capistrano-rails (~> 1.2) + capistrano-rbenv (~> 2.1) + coffee-rails (~> 4.2) + devise + haml + jbuilder (~> 2.5) + jquery-rails + kaminari + meta_request + paperclip + pg + puma (~> 3.0) + rails (~> 5.0.1) + rails_admin + redis (~> 3.0) + remotipart (~> 1.2) + sass-rails (~> 5.0) + simple_form + sqlite3 + tzinfo-data + uglifier (>= 1.3.0) + web-console + +BUNDLED WITH + 1.13.6 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..e85f913 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/images/background.jpg b/app/assets/images/background.jpg new file mode 100644 index 0000000..e5c0577 Binary files /dev/null and b/app/assets/images/background.jpg differ diff --git a/app/assets/images/bg-green-stripes.png b/app/assets/images/bg-green-stripes.png new file mode 100644 index 0000000..a8303cf Binary files /dev/null and b/app/assets/images/bg-green-stripes.png differ diff --git a/app/assets/images/chaton_bg.jpg b/app/assets/images/chaton_bg.jpg new file mode 100644 index 0000000..735e163 Binary files /dev/null and b/app/assets/images/chaton_bg.jpg differ diff --git a/app/assets/images/default-avatar.jpg b/app/assets/images/default-avatar.jpg new file mode 100644 index 0000000..8329fe9 Binary files /dev/null and b/app/assets/images/default-avatar.jpg differ diff --git a/app/assets/images/default-avatar.png b/app/assets/images/default-avatar.png new file mode 100644 index 0000000..822078a Binary files /dev/null and b/app/assets/images/default-avatar.png differ diff --git a/app/assets/images/stripe-blue.png b/app/assets/images/stripe-blue.png new file mode 100644 index 0000000..1025d2e Binary files /dev/null and b/app/assets/images/stripe-blue.png differ diff --git a/app/assets/images/stripe-gray-bg.png b/app/assets/images/stripe-gray-bg.png new file mode 100644 index 0000000..d944a1d Binary files /dev/null and b/app/assets/images/stripe-gray-bg.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..c2fe244 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,19 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require bootstrap-sprockets +//= require jquery.remotipart +//= require chat +//= require cable +//= require_tree . \ No newline at end of file diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 0000000..71ee1e6 --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the rails generate channel command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/channels/appearances.coffee b/app/assets/javascripts/channels/appearances.coffee new file mode 100644 index 0000000..abd83d4 --- /dev/null +++ b/app/assets/javascripts/channels/appearances.coffee @@ -0,0 +1,9 @@ +$(document).ready -> + App.personal_chat = App.cable.subscriptions.create { + channel: "AppearancesChannel" + }, + connected: -> + disconnected: -> + received: (data) -> + user = $(".user-#{data['user_id']}") + user.toggleClass 'online', data['online'] \ No newline at end of file diff --git a/app/assets/javascripts/channels/rooms.coffee b/app/assets/javascripts/channels/rooms.coffee new file mode 100644 index 0000000..a75b11a --- /dev/null +++ b/app/assets/javascripts/channels/rooms.coffee @@ -0,0 +1,36 @@ +$(document).ready -> + messages = $('#messages') + if $('#messages').length > 0 + messages_to_bottom = -> messages.scrollTop(messages.prop("scrollHeight")) + messages_to_bottom() + + App.global_chat = App.cable.subscriptions.create { + channel: "ChatRoomsChannel" + chat_room_id: messages.data('chat-room-id') + }, + connected: -> + # Called when the subscription is ready for use on the server + + disconnected: -> + # Called when the subscription has been terminated by the server + + received: (data) -> + messages.append data['message'] + messages_to_bottom() + + send_message: (message, chat_room_id) -> + @perform 'send_message', message: message, chat_room_id: chat_room_id + + + $('#new_message').submit (e) -> + $this = $(this) + textarea = $this.find('#message_body') + if $.trim(textarea.val()).length >= 1 + App.global_chat.send_message textarea.val(), messages.data('chat-room-id') + textarea.val('') + e.preventDefault() + return false + $('#message_body').keypress (e) -> + if e && e.keyCode == 13 + e.preventDefault() + $(this).submit() \ No newline at end of file diff --git a/app/assets/javascripts/channels/university_chat.coffee b/app/assets/javascripts/channels/university_chat.coffee new file mode 100644 index 0000000..1fc912e --- /dev/null +++ b/app/assets/javascripts/channels/university_chat.coffee @@ -0,0 +1,35 @@ +$(document).ready -> + university_messages = $('#university_messages') + if $('#university_messages').length > 0 + messages_to_bottom = -> university_messages.scrollTop(university_messages.prop("scrollHeight")) + messages_to_bottom() + + App.university_chat = App.cable.subscriptions.create { + channel: "UniversityChatsChannel" + university_id: university_messages.data('university-id') + }, + connected: -> + # Called when the subscription is ready for use on the server + + disconnected: -> + # Called when the subscription has been terminated by the server + + received: (data) -> + university_messages.append data['message'] + messages_to_bottom() + + send_message: (message, university_id) -> + @perform 'send_message', message: message, university_id: university_id + + $('#new_university_message').submit (e) -> + $this = $(this) + textarea = $this.find('#university_message_body') + if $.trim(textarea.val()).length >= 1 + App.university_chat.send_message textarea.val(), university_messages.data('university-id') + textarea.val('') + e.preventDefault() + return false + $('#new_university_message').keypress (e) -> + if e && e.keyCode == 13 + e.preventDefault() + $(this).submit() \ No newline at end of file diff --git a/app/assets/javascripts/chat.js b/app/assets/javascripts/chat.js new file mode 100644 index 0000000..8e0cfea --- /dev/null +++ b/app/assets/javascripts/chat.js @@ -0,0 +1,387 @@ +var chatboxFocus = new Array(); +var chatBoxes = new Array(); + +var ready = function() { + + chatBox = { + /** + * creates an inline chatbox on the page by calling the + * createChatBox function passing along the unique conversation_id + * + * @param conversation_id + */ + chatWith: function(conversation_id) { + chatBox.createChatBox(conversation_id); + $("#chatbox_" + conversation_id + " .chatboxtextarea").focus(); + }, + + /** + * closes the chatbox by essentially hiding it from the page + * + * @param conversation_id + */ + + close: function(conversation_id) { + $('#chatbox_' + conversation_id).css('display', 'none'); + chatBox.restructure(); + }, + + /** + * Plays a notification sound when a new chat message arrives + */ + + notify: function() { + var audioplayer = $('#chatAudio')[0]; + audioplayer.play(); + }, + + /** + * Handles 'smart layouts' of the chatboxes. Like when new chatboxes are + * added or removed from the view, it restructures them so that they appear + * neatly aligned on the page + */ + + restructure: function() { + align = 0; + for (x in chatBoxes) { + chatbox_id = chatBoxes[x]; + + if ($("#chatbox_" + chatbox_id).css('display') != 'none') { + if (align == 0) { + $("#chatbox_" + chatbox_id).css('right', '20px'); + } else { + width = (align) * (280 + 7) + 20; + $("#chatbox_" + chatbox_id).css('right', width + 'px'); + } + align++; + } + } + + }, + + /** + * Takes in two parameters. It is responsible for fetching the specific conversation's + * html page and appending it to the body of our home page e.g if conversation_id = 1 + * + * $.get("conversations/1, function(data){ + * // rest of the logic here + * }, "html") + * + * @param conversation_id + * @param minimizeChatBox + */ + + createChatBox: function(conversation_id, minimizeChatBox) { + + App.personal_chat = App.cable.subscriptions.create({ + channel: "ConversationNotificationsChannel", + conversation_id : conversation_id + }, { + send_message: function(message, conversation_id) { + return this.perform('send_message', { + message: message, + conversation_id: conversation_id + }); + }, + connected: function() {}, + disconnected: function() {}, + received: function(data) { + if(data['message_user_id']==$('meta[name=user-id]').attr("content")){ + $("#chatbox_" + conversation_id + " .chatboxcontent").append('
<%= t('.greeting', recipient: @resource.email, default: "Welcome #{@resource.email}!") %>
+ +<%= t('.instruction', default: 'You can confirm your account email through the link below:') %>
+ +<%= link_to t('.action', default: 'Confirm my account'), + confirmation_url(@resource, confirmation_token: @token, locale: I18n.locale) %>
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..f757e10 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +<%= t('.greeting', recipient: @resource.email, default: "Hello #{@resource.email}!") %>
+ +<%= t('.instruction', default: 'Someone has requested a link to change your password, and you can do this through the link below.') %>
+ +<%= link_to t('.action', default: 'Change my password'), edit_password_url(@resource, reset_password_token: @token, locale: I18n.locale) %>
+ +<%= t('.instruction_2', default: "If you didn't request this, please ignore this email.") %>
+<%= t('.instruction_3', default: "Your password won't change until you access the link above and create a new one.") %>
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..98e723d --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +<%= t('.greeting', recipient: @resource.email, default: "Hello #{@resource.email}!") %>
+ +<%= t('.message', default: 'Your account has been locked due to an excessive amount of unsuccessful sign in attempts.') %>
+ +<%= t('.instruction', default: 'Click the link below to unlock your account:') %>
+ +<%= link_to t('.action', default: 'Unlock my account'), unlock_url(@resource, unlock_token: @resource.unlock_token, locale: I18n.locale) %>
diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml new file mode 100644 index 0000000..f2336ee --- /dev/null +++ b/app/views/devise/passwords/edit.html.haml @@ -0,0 +1,17 @@ +.registration-bg + .container + .row + .col-md-4.col-md-offset-8 + .log-in.panel + .panel-heading + %h2 Change your password + = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| + = f.input :reset_password_token, as: :hidden + = f.full_error :reset_password_token + = devise_error_messages! + .form-inputs + = f.input :password, label: "New password", required: true, autofocus: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) + = f.input :password_confirmation, label: "Confirm your new password", required: true + .form-actions + = f.button :submit, "Change my password" + = render "devise/shared/links" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml new file mode 100644 index 0000000..8e6f14c --- /dev/null +++ b/app/views/devise/passwords/new.html.haml @@ -0,0 +1,22 @@ +.registration-bg + .container + .row + .col-md-4.col-md-offset-8 + .log-in.panel + .panel-heading + %h2 Forgot your password? + = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| + = f.error_notification + = devise_error_messages! + .panel-body + .form-inputs + = f.input :user_name, required: true, autofocus: true + .form-actions + = f.button :submit, "Send me reset password instructions" + %hr + = render "devise/shared/links" + %br + %hr + %p We will send you a link to reset password. + %p Please check in spam folder if you didn't get any emails from us. + %p If you still don't get email then please contact us. diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml new file mode 100644 index 0000000..ec2deef --- /dev/null +++ b/app/views/devise/registrations/edit.html.haml @@ -0,0 +1,30 @@ +.post-wrapper + .post + .post-body + .container-fluid + %h4 Edit Basic Info + %hr + = simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| + = f.error_notification + .form-inputs + = f.input :email, required: true, autofocus: true + = f.input :user_name, required: true + = f.input :first_name, required: true + = f.input :last_name, required: true + + = f.check_box :is_female, {}, false + = f.label :is_female, "Male" + + = f.check_box :is_female, {}, true + = f.label :is_female, "Female" + + + - if devise_mapping.confirmable? && resource.pending_reconfirmation? + %p + Currently waiting confirmation for: #{resource.unconfirmed_email} + = f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false + = f.input :password_confirmation, required: false + = f.input :current_password, hint: "we need your current password to confirm your changes", required: true + .form-actions + = f.button :submit, "Update" + = link_to "Back", :back, class: 'btn btn-primary' diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml new file mode 100644 index 0000000..c2bcae7 --- /dev/null +++ b/app/views/devise/registrations/new.html.haml @@ -0,0 +1,29 @@ +.registration-bg + .container + .row + .col-md-4.col-md-offset-8 + .log-in.panel + .panel-heading + %h4 Create Your Account + = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| + = f.error_notification + .panel-body + = f.input :email, required: true, autofocus: true, label: false, placeholder: 'Email' + = f.input :user_name, required: true, label: false, placeholder: 'User Name' + = f.input :first_name, required: true, label: false, placeholder: 'First Name' + = f.input :last_name, required: true, label: false, placeholder: 'Last Name' + + = f.input :password, required: true, label: false, placeholder: 'Password' + = f.input :password_confirmation, required: true, label: false, placeholder: 'Confirm Password' + + = f.check_box :is_female, {}, false + = f.label :is_female, "Male" + + = f.check_box :is_female, {}, true + = f.label :is_female, "Female" + + + + = f.button :submit, "Sign up", class: 'btn-info btn-block' + + %p After Registering You will need to confirm your account . Check Your Email Please diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml new file mode 100644 index 0000000..99abcab --- /dev/null +++ b/app/views/devise/sessions/new.html.haml @@ -0,0 +1,24 @@ +.login-bg + .container + .row + .col-md-4.col-md-offset-8 + .log-in.panel + .panel-heading + %h4 Log in + %hr + = simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| + = f.error_notification + .panel-body + = f.input :login, required: true, autofocus: true, label: false, placeholder: 'User Name' + = f.input :password, required: true, label: false, placeholder: 'Password' + = f.input :remember_me, as: :boolean if devise_mapping.rememberable? + = f.button :submit, "Log in", class: 'btn-lg btn-info btn-block' + + -if devise_mapping.recoverable? + = link_to "Forgot your password?", new_password_path(resource_name),class: 'btn btn-danger' + -if devise_mapping.recoverable? + = link_to "Sign up", new_registration_path(resource_name),class: 'btn btn-success' + + %div{style: 'clear:both'} + + %br diff --git a/app/views/devise/shared/_links.html.haml b/app/views/devise/shared/_links.html.haml new file mode 100644 index 0000000..4aa61c8 --- /dev/null +++ b/app/views/devise/shared/_links.html.haml @@ -0,0 +1,18 @@ +- if controller_name != 'sessions' + = link_to "Log in", new_session_path(resource_name),class:'btn btn-primary' + +- if devise_mapping.registerable? && controller_name != 'registrations' + = link_to "Sign up", new_registration_path(resource_name),class:'btn btn-success' + +- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' + = link_to "Forgot your password?", new_password_path(resource_name),class:'btn btn-alert' + +- if devise_mapping.confirmable? && controller_name != 'confirmations' + = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name),class:'btn btn-info' + +- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' + = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name),class:'btn btn-warning' + +- if devise_mapping.omniauthable? + - resource_class.omniauth_providers.each do |provider| + = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider),class:'btn btn-alert' \ No newline at end of file diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml new file mode 100644 index 0000000..b33139d --- /dev/null +++ b/app/views/devise/unlocks/new.html.haml @@ -0,0 +1,16 @@ +.registration-bg + .container + .row + .col-md-4.col-md-offset-8 + .log-in.panel + .panel-heading + %h4 Resend unlock instructions + = simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| + = f.error_notification + .panel-body + = f.full_error :unlock_token + .form-inputs + = f.input :email, required: true, autofocus: true + .form-actions + = f.button :submit, "Resend unlock instructions" + = render "devise/shared/links" diff --git a/app/views/layouts/_chat_box.html.haml b/app/views/layouts/_chat_box.html.haml new file mode 100644 index 0000000..fd092e6 --- /dev/null +++ b/app/views/layouts/_chat_box.html.haml @@ -0,0 +1,14 @@ +.chat_box.list-group + %li.list-group-item + .chat_box_heading Online Chat + %li.list-group-item + .text-center + =link_to "Follow Other User to Chat",all_users_path + - current_user.following.each do |user| + %li.list-group-item + =link_to "#", class: "start-conversation","data-sid" => current_user.id, "data-rip" => user.id do + .chat_avatar + = chat_avatar_select(user) + = user.full_name + .user_online_block + = online_status user \ No newline at end of file diff --git a/app/views/layouts/_follower_suggestion.html.haml b/app/views/layouts/_follower_suggestion.html.haml new file mode 100644 index 0000000..4bd8705 --- /dev/null +++ b/app/views/layouts/_follower_suggestion.html.haml @@ -0,0 +1,22 @@ +.post-wrapper + .post + .suggestion_box_heading + You may want to follow + .sugesstion_box_show_all.pull-right + = link_to "See All >" , all_users_path + .clear + %ul.suggestion_box_main + - ids = currently_logged_in_user.following.pluck(:id) + - if User.where.not(id: ids).where.not(id: currently_logged_in_user.id).limit(5).offset(rand(User.count)).each do|user| + %li + = render 'profiles/follow_and_unfollow_button' , :user => user + .user_info + = chat_avatar_select(user) + .suggestion_box_name + .suggestion_box_user_name + = user.user_name + .suggestion_box_full_name + = user.full_name + .clear + - end.empty? + %li You can check All users if you wanna follow someone :) diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml new file mode 100644 index 0000000..ad7f89a --- /dev/null +++ b/app/views/layouts/_footer.html.haml @@ -0,0 +1,2 @@ +%footer.container-fluid.text-center.copyright-part + %p © Chat Ounce 2017. All rights reserved. Yes, all of them. \ No newline at end of file diff --git a/app/views/layouts/_form_error.html.haml b/app/views/layouts/_form_error.html.haml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml new file mode 100644 index 0000000..cfe05e0 --- /dev/null +++ b/app/views/layouts/_navbar.html.haml @@ -0,0 +1,30 @@ +%nav.navbar.navbar-default + .navbar-header + %button.navbar-toggle.collapsed{"data-target" => "#bs-navbar-collapse-1", "data-toggle" => "collapse", type: "button"} + %span.sr-only Toggle Navigation + %span.icon-bar + %span.icon-bar + = link_to "Chat Ounce", root_path , class: 'navbar-brand' + - if user_signed_in? + = link_to current_user.full_name, profile_path(current_user.user_name), class: 'navigation_box' + = render 'dashboard/search_form' + + .collapse.navbar-collapse#bs-navbar-collapse-1 + %ul.nav.navbar-nav.navbar-right + - if user_signed_in? + %li + = link_to "University", universities_path, class: 'navigation_box' + %li + = render 'notifications/notifications_dropdown' + %li + = render 'notifications/mesages_notifications_dropdown' + %li + = link_to "All Users", all_users_path, class: 'navigation_box' + %li + = link_to "Public Chat Room", chat_rooms_path, class: 'navigation_box' + %li + = link_to edit_profile_path(current_user.user_name), class: 'navigation_box' do + %span{class:'glyphicon glyphicon-cog colorb'} + %li + = link_to destroy_user_session_path, method: :delete, class: 'navigation_box' do + %span{class:'glyphicon glyphicon-off colorr'} \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml new file mode 100644 index 0000000..11700bc --- /dev/null +++ b/app/views/layouts/application.html.haml @@ -0,0 +1,25 @@ +%html + %head + + %title Chat Ounce + + %meta{:charset => "utf-8"} + %meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge"} + %meta{:name => "viewport", :content => "width=device-width, initial-scale=1"} + %meta{:content => user_signed_in? ? current_user.id : "",:name=>'user-id'} + + = stylesheet_link_tag 'application', media: 'all' + + = javascript_include_tag 'application' + + = csrf_meta_tags + + %body + = render 'layouts/navbar' + + -flash.each do |name, msg| + = content_tag :div, msg, class: [:alert, alert_for(name)] + + = yield + + = render 'layouts/footer' \ No newline at end of file diff --git a/app/views/messages/_message.html.haml b/app/views/messages/_message.html.haml new file mode 100644 index 0000000..b3bdf95 --- /dev/null +++ b/app/views/messages/_message.html.haml @@ -0,0 +1,13 @@ +.card + .card-block + .row + .col-md-1 + = post_avatar_select message.user + .col-md-11 + %p.card-text + %span.text-muted + = message.user.user_name + #{time_ago_in_words(message.created_at)} ago says + + %br + = message.body \ No newline at end of file diff --git a/app/views/notifications/_mesages_notifications_dropdown.html.haml b/app/views/notifications/_mesages_notifications_dropdown.html.haml new file mode 100644 index 0000000..3eaf34b --- /dev/null +++ b/app/views/notifications/_mesages_notifications_dropdown.html.haml @@ -0,0 +1,5 @@ +.dropdown.notification-dropdown{data: {behaviour: 'message-notifications'}} + %button.btn.btn-default.navbar__buttons.dropdown-toggle{ type: 'button', id: 'dropdownMenu1', data: { toggle: 'dropdown' }, 'aria-haspopup'=> true, 'aria-expanded'=> true } + %span{class: 'message-notifications-count',data: {behaviour: 'message-notifications-count'}} + %span.glyphicon.glyphicon-envelope.colorb + %ul.dropdown-menu{ 'aria-labelledby'=> 'dropdownMenu1', data: {behaviour: 'message-notifications-item'}} \ No newline at end of file diff --git a/app/views/notifications/_notifications_dropdown.html.haml b/app/views/notifications/_notifications_dropdown.html.haml new file mode 100644 index 0000000..6be9a14 --- /dev/null +++ b/app/views/notifications/_notifications_dropdown.html.haml @@ -0,0 +1,5 @@ +.dropdown.notification-dropdown{data: {behaviour: 'notifications'}} + %button.btn.btn-default.navbar__buttons.dropdown-toggle{ type: 'button', id: 'dropdownMenu1', data: { toggle: 'dropdown' }, 'aria-haspopup'=> true, 'aria-expanded'=> true } + %span{class: 'notifications-count', data: {behaviour: 'notifications-count'}} + %span.glyphicon.glyphicon-bell.colorb + %ul.dropdown-menu{ 'aria-labelledby'=> 'dropdownMenu1',data: {behaviour: 'notifications-item'}} diff --git a/app/views/notifications/conversations/_messaged.html.haml b/app/views/notifications/conversations/_messaged.html.haml new file mode 100644 index 0000000..d77b248 --- /dev/null +++ b/app/views/notifications/conversations/_messaged.html.haml @@ -0,0 +1,3 @@ +%li{class: "#{"notification-unread" if !notification.read_at?}"} + = link_to '#',"data-sid" => notification.notifiable.author_id, "data-rip" => notification.notifiable.receiver_id,class: 'dropdown-item start-conversation' do + = "#{notification.actor.full_name} messaged you at #{time_ago_in_words(notification.created_at)} ago" \ No newline at end of file diff --git a/app/views/notifications/index.json.jbuilder b/app/views/notifications/index.json.jbuilder new file mode 100644 index 0000000..0f12635 --- /dev/null +++ b/app/views/notifications/index.json.jbuilder @@ -0,0 +1,6 @@ +json.array! @notifications do |notification| + json.id notification.id + json.type notification.notifiable_type.underscore.pluralize + json.unread !notification.read_at? + json.template render partial: "notifications/#{notification.notifiable_type.underscore.pluralize}/#{notification.action}",locals: {notification: notification}, formats: [:html] +end \ No newline at end of file diff --git a/app/views/notifications/posts/_commented.html.haml b/app/views/notifications/posts/_commented.html.haml new file mode 100644 index 0000000..331d573 --- /dev/null +++ b/app/views/notifications/posts/_commented.html.haml @@ -0,0 +1,3 @@ +%li{class: "#{"notification-unread" if !notification.read_at?}"} + = link_to [notification.notifiable.postable,notification.notifiable],class: 'dropdown-item' do + = "#{notification.actor.full_name} #{notification.action} on #{notification.notifiable_type.underscore.humanize.downcase}" \ No newline at end of file diff --git a/app/views/notifications/posts/_liked.html.haml b/app/views/notifications/posts/_liked.html.haml new file mode 100644 index 0000000..97438f8 --- /dev/null +++ b/app/views/notifications/posts/_liked.html.haml @@ -0,0 +1,3 @@ +%li{class: "#{"notification-unread" if !notification.read_at?}"} + = link_to [notification.notifiable.postable,notification.notifiable],class: 'dropdown-item' do + = "#{notification.actor.full_name} likes your post" \ No newline at end of file diff --git a/app/views/notifications/universities/_approved.html.haml b/app/views/notifications/universities/_approved.html.haml new file mode 100644 index 0000000..01667d4 --- /dev/null +++ b/app/views/notifications/universities/_approved.html.haml @@ -0,0 +1,3 @@ +%li{class: "#{"notification-unread" if !notification.read_at?}"} + = link_to [notification.notifiable],class: 'dropdown-item' do + = "#{notification.actor.full_name} approved you at #{notification.notifiable.name} university" \ No newline at end of file diff --git a/app/views/notifications/universities/_promoted.html.haml b/app/views/notifications/universities/_promoted.html.haml new file mode 100644 index 0000000..67c7089 --- /dev/null +++ b/app/views/notifications/universities/_promoted.html.haml @@ -0,0 +1,3 @@ +%li{class: "#{"notification-unread" if !notification.read_at?}"} + = link_to [notification.notifiable],class: 'dropdown-item' do + = "#{notification.actor.full_name} promoted you to moderator #{notification.notifiable.name} university" \ No newline at end of file diff --git a/app/views/notifications/users/_followed.html.haml b/app/views/notifications/users/_followed.html.haml new file mode 100644 index 0000000..4823dde --- /dev/null +++ b/app/views/notifications/users/_followed.html.haml @@ -0,0 +1,3 @@ +%li{class: "#{"notification-unread" if !notification.read_at?}"} + = link_to profile_path(notification.notifiable.user_name),class: 'dropdown-item' do + = "#{notification.actor.full_name} is following you at #{time_ago_in_words(notification.created_at)} ago" \ No newline at end of file diff --git a/app/views/personal_messages/_personal_message.html.haml b/app/views/personal_messages/_personal_message.html.haml new file mode 100644 index 0000000..bd81459 --- /dev/null +++ b/app/views/personal_messages/_personal_message.html.haml @@ -0,0 +1,15 @@ +%li{class: personal_message.user_id == personal_message.conversation.author_id ? "self" : "other"} + .avatar + = chat_avatar_select(personal_message.user) + .chatboxmessagecontent + %p= personal_message.body + - if personal_message.attachment.exists? + - if !(personal_message.attachment.content_type =~ /^image/).nil? + = link_to (image_tag (personal_message.attachment.url), class:'img-responsive'),personal_message.attachment.url,target: '_blank' + - else + = link_to personal_message.attachment.instance.attachment_file_name,personal_message.attachment.url + + %time{:datetime => "#{personal_message.created_at}", :title => "#{personal_message.created_at.strftime("%d %b %Y at %I:%M%p")}"} + = personal_message.user.user_name + = personal_message.created_at.strftime("%H:%M %p") + diff --git a/app/views/personal_messages/new.html.haml b/app/views/personal_messages/new.html.haml new file mode 100644 index 0000000..5f8b672 --- /dev/null +++ b/app/views/personal_messages/new.html.haml @@ -0,0 +1,7 @@ +%h1 + New message to #{@receiver.user_name} += form_for @personal_message do |f| + = hidden_field_tag 'receiver_id', @receiver.id + = f.label :body + = f.text_area :body + = f.submit diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml new file mode 100644 index 0000000..577877a --- /dev/null +++ b/app/views/posts/_form.html.haml @@ -0,0 +1,17 @@ +- if post.errors.any? + #error_explanation + %h4 + = pluralize(post.errors.count, "error") + prohibited this post from being saved: + %ul + - post.errors.full_messages.each do |message| + %li= message + += simple_form_for [postable,post], html: { multipart: true } do |f| + = f.input :content, label: false, placeholder: 'Write your feelings...', input_html: { rows: 2 } + %label{class: 'btn btn-default btn-file'} + %span{class: 'glyphicon glyphicon-share'} + Upload + = f.input :attachment, label: false,wrapper: false,input_html: { onChange: 'loadFile(event)' } + = f.button :submit, class: 'btn-success' += form_image_select(post) \ No newline at end of file diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml new file mode 100644 index 0000000..4f9fb7a --- /dev/null +++ b/app/views/posts/_likes.html.haml @@ -0,0 +1,2 @@ +.likes{id: "likes_#{post.id}"} + = display_likes post diff --git a/app/views/posts/_post.html.haml b/app/views/posts/_post.html.haml new file mode 100644 index 0000000..9eb319f --- /dev/null +++ b/app/views/posts/_post.html.haml @@ -0,0 +1,58 @@ +%article.post-wrapper + .post + .post-head + .post-user-thumbnail + = post_avatar_select(post.user) + .post-user-name + = link_to post.user.full_name, profile_path(post.user.user_name) + posted a new status + .time-ago + = time_ago_in_words post.created_at + ago + .clear + .attachment + .attachment-content + = post.content + .clear + .image.center-block + - if post.attachment.exists? + - if !(post.attachment.content_type =~ /^image/).nil? + .attachment-image + = image_tag (URI(request.url) + post.attachment.url), class:'img-responsive post__image' + - else + .attachment-info + File Name : + = post.attachment.instance.attachment_file_name + File Size (KB) : + = post.attachment.instance.attachment_file_size/1000 + + .attachment-files + = link_to "Download","#{URI(request.url) + post.attachment.url}", class: "btn btn-success" + + .view_post_bottom + = count_likers post.votes_for.up.by_type(User) + %span{class:'comment_counter'} + = count_comments post + = render 'posts/post_modifier_link',post: post + .post-bottom + = render 'posts/likes', post: post + + .comments{id: "comments_#{post.id}"} + - if post.comments.any? + = render post.comments.order('created_at asc').first(4), {post: post,postable:postable} + - unless post.comments.count <= 4 + .paginator{id: "#comments-paginator-#{post.id}"} + =link_to "View all #{post.comments.count} comments",[postable,post,:comments], remote: true, class: 'more-comments', id: "more_comments_#{post.id}", data: {post_id: "#{post.id}", type: "html", value: "#{post.comments.count}"} + - else + %p No comments + .comment-like-form.row + .like-button.col-xs-1 + =liked_post post + .comment-form.col-xs-11 + = form_for([postable,post, post.comments.build], remote: true) do |f| + = f.text_field :content, placeholder: 'Add a comment...', + class: "comment_content", + id: "comment_content_#{post.id}", + data: { post_id: "#{post.id}",'postable-type': "#{post.postable_type.underscore.pluralize}",'postable-id': "#{post.postable_id}", + value: "#{post.comments.count}" } + = f.submit 'New Comment', class: 'comment-submit-button' diff --git a/app/views/posts/_post_modifier_link.html.haml b/app/views/posts/_post_modifier_link.html.haml new file mode 100644 index 0000000..c0d2c89 --- /dev/null +++ b/app/views/posts/_post_modifier_link.html.haml @@ -0,0 +1,8 @@ +- if post.postable_type == 'University' + - if moderation_links_and_power(post) + = link_to "Edit Post", [:edit,post.postable,post] + = link_to "Delete Post", [post.postable,post], method: :delete, data: { confirm: "Are you sure you want to delete others post?" } +- else + -if post.user.id == current_user.id || current_user.role.name == 'admin' + = link_to "Edit Post", [:edit,post.postable,post] + = link_to "Delete Post", [post.postable,post], method: :delete, data: { confirm: "Are you sure you want to delete this post?" } \ No newline at end of file diff --git a/app/views/posts/_posts.html.haml b/app/views/posts/_posts.html.haml new file mode 100644 index 0000000..fdf0154 --- /dev/null +++ b/app/views/posts/_posts.html.haml @@ -0,0 +1 @@ += render posts,postable: postable \ No newline at end of file diff --git a/app/views/posts/edit.html.haml b/app/views/posts/edit.html.haml new file mode 100644 index 0000000..5b19678 --- /dev/null +++ b/app/views/posts/edit.html.haml @@ -0,0 +1,6 @@ +.post-wrapper + .post + .form-body + = render 'form',post: @post,postable:@postable + .text-center.edit-links + = link_to "Cancel", root_path,class: 'btn btn-primary' diff --git a/app/views/posts/like.js.erb b/app/views/posts/like.js.erb new file mode 100644 index 0000000..b24e2e8 --- /dev/null +++ b/app/views/posts/like.js.erb @@ -0,0 +1,3 @@ +$("#like_<%= @post.id %>").removeClass('glyphicon-heart-empty').addClass('glyphicon-heart'); +$("#like_<%= @post.id %>").removeAttr('href').attr('href', '<%= @post.postable_type.downcase.pluralize %>/<%= @post.postable.id %>/posts/<%= @post.id %>/unlike'); +$("#likes_<%= @post.id %>").html("<%= j (render partial: 'posts/likes', locals: { post: @post} ) %>"); \ No newline at end of file diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml new file mode 100644 index 0000000..240182a --- /dev/null +++ b/app/views/posts/show.html.haml @@ -0,0 +1 @@ += render 'post', post: @post,postable: @postable \ No newline at end of file diff --git a/app/views/posts/unlike.js.erb b/app/views/posts/unlike.js.erb new file mode 100644 index 0000000..f699fba --- /dev/null +++ b/app/views/posts/unlike.js.erb @@ -0,0 +1,3 @@ +$("#like_<%= @post.id %>").removeClass('glyphicon-heart').addClass('glyphicon-heart-empty'); +$("#like_<%= @post.id %>").removeAttr('href').attr('href', '<%= @post.postable_type.downcase.pluralize %>/<%= @post.postable.id %>/posts/<%= @post.id %>/like'); +$("#likes_<%= @post.id %>").html("<%= j (render partial: 'posts/likes', locals: { post: @post} ) %>"); \ No newline at end of file diff --git a/app/views/profiles/_follow_and_unfollow_button.html.haml b/app/views/profiles/_follow_and_unfollow_button.html.haml new file mode 100644 index 0000000..af65647 --- /dev/null +++ b/app/views/profiles/_follow_and_unfollow_button.html.haml @@ -0,0 +1,4 @@ +- if current_user_is_following(current_user.id, user.id) + = link_to 'Following', unfollow_user_path(user.user_name), remote: true, class: 'btn btn-success unfollow-button flat__buttons', id: "button-#{user.id}", method: :post +- else + = link_to 'Follow', follow_user_path(user.user_name), remote: true, class: 'btn btn-default follow-button flat__buttons', id: "button-#{user.id}", method: :post \ No newline at end of file diff --git a/app/views/profiles/edit.html.haml b/app/views/profiles/edit.html.haml new file mode 100644 index 0000000..d82d68e --- /dev/null +++ b/app/views/profiles/edit.html.haml @@ -0,0 +1,25 @@ +.post-wrapper + .post + .post-body + .image-wrap + = simple_form_for @user, url: {action: "update"}, html: { multipart: true } do |f| + .row + .col-md-12 + .form-group.text-center + %h4 Change your profile image: + .img-circle.avatar-image + = profile_avatar_select(@user) + %h4 Update your bio: + %label{class: 'btn btn-default btn-file'} + %span{class: 'glyphicon glyphicon-share'} + Upload + = f.input :avatar, label: false,wrapper: false,input_html: { onChange: 'loadFile(event)' } + + %div{style: 'clear:both'} + .col-md-12 + .form-group.text-center + %h4 Update your bio: + = f.input :bio, label: false, input_html: { rows: 4 } + .form-group.text-center + = f.button :submit, 'Update Profile', class: 'btn btn-success' + = link_to 'Edit Basic Info',edit_user_registration_path , class: "btn btn-primary" \ No newline at end of file diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml new file mode 100644 index 0000000..c25927b --- /dev/null +++ b/app/views/profiles/show.html.haml @@ -0,0 +1,26 @@ +.post-wrapper + .row.profile-header + .col-sm-6 + .img-circle + = profile_avatar_select(@user) + .col-sm-6 + .user-name-and-follow + %h3.profile-user-name + = @user.user_name + %p.profile-bio + = @user.bio + .user-statistics + %p + = pluralize @user.posts.count, 'post' + %div + - if @user == current_user + = link_to 'Edit Profile', edit_profile_path(@user.user_name), + class: 'btn edit-button flat__buttons' + = link_to 'Edit Basic Info', edit_user_registration_path, + class: 'btn edit-button flat__buttons' + - else + = render 'follow_and_unfollow_button',user: @user + + +-@posts.each do |post| + = render 'posts/post', {post: post,postable:post.user} diff --git a/app/views/profiles/show_all_users.html.haml b/app/views/profiles/show_all_users.html.haml new file mode 100644 index 0000000..89f6a3d --- /dev/null +++ b/app/views/profiles/show_all_users.html.haml @@ -0,0 +1,17 @@ +.post-wrapper + .user_listings + -@users.where.not(id: current_user.id).each do |user| + .user + .user_head + + = link_to 'Message', '#' ,class: 'start-conversation btn btn-danger follow-button flat__buttons',"data-sid" => current_user.id, "data-rip" => user.id + = render 'follow_and_unfollow_button' , :user => user + .user_avatar + = post_avatar_select(user) + .user_username + = link_to user.user_name , profile_path(user.user_name) + .user_fullname + = user.full_name + .clear + .user_bio + = user.bio \ No newline at end of file diff --git a/app/views/relationships/follow_user.js.erb b/app/views/relationships/follow_user.js.erb new file mode 100644 index 0000000..de87c8d --- /dev/null +++ b/app/views/relationships/follow_user.js.erb @@ -0,0 +1,3 @@ +$('#button-<%= @user.id %>').attr('class', 'btn btn-success unfollow-button flat__buttons') + .text('Following') + .attr('href', "/<%= @user.user_name %>/unfollow_user") \ No newline at end of file diff --git a/app/views/relationships/unfollow_user.js.erb b/app/views/relationships/unfollow_user.js.erb new file mode 100644 index 0000000..075ee39 --- /dev/null +++ b/app/views/relationships/unfollow_user.js.erb @@ -0,0 +1,3 @@ +$('#button-<%= @user.id %>').text('Follow') + .attr('class', 'btn btn-default follow-button flat__buttons') + .attr('href', "/<%= @user.user_name %>/follow_user") \ No newline at end of file diff --git a/app/views/universities/_common_links.html.haml b/app/views/universities/_common_links.html.haml new file mode 100644 index 0000000..8fd36f4 --- /dev/null +++ b/app/views/universities/_common_links.html.haml @@ -0,0 +1,6 @@ +.btn-group.post-wrapper + = link_to 'Discussion',university_path(@university),class: 'btn btn-primary' + = link_to 'Members',members_university_path(@university),class: 'btn btn-success' + = link_to 'Group Chat',chat_university_path(@university),class: 'btn btn-info' + - if current_user.role.name == 'admin' + = link_to 'Edit University',edit_university_path(@university),class: 'btn btn-warning' \ No newline at end of file diff --git a/app/views/universities/_form.html.haml b/app/views/universities/_form.html.haml new file mode 100644 index 0000000..109ea07 --- /dev/null +++ b/app/views/universities/_form.html.haml @@ -0,0 +1,15 @@ +- if university.errors.any? + #error_explanation + %h4 + = pluralize(university.errors.count, "error") + prohibited this university from being saved: + %ul + - university.errors.full_messages.each do |message| + %li= message + += simple_form_for university, html: { multipart: true } do |f| + = f.input :thumbnail_image, inline_label: 'Thummnail Image' + = f.input :timeline_image, inline_label: 'Timeline Image' + = f.input :name, label: false, placeholder: 'University Name' ,:autofocus => true + = f.input :description, label: false, placeholder: 'University Description' + = f.button :submit, class: 'btn-success btn-block' diff --git a/app/views/universities/_join_and_unjoin_button.html.haml b/app/views/universities/_join_and_unjoin_button.html.haml new file mode 100644 index 0000000..5cdcc4f --- /dev/null +++ b/app/views/universities/_join_and_unjoin_button.html.haml @@ -0,0 +1,4 @@ +- if current_user_is_joined(user.id, university.id) + = link_to 'Leave This University',unjoin_university_path(university,user), remote: true,class: 'btn btn-danger flat_button',id: "join_university_#{university.id}",method: :post +- else + = link_to 'Join This University',join_university_path(university,user), remote: true,class: 'btn btn-success flat_button',id: "join_university_#{university.id}",method: :post \ No newline at end of file diff --git a/app/views/universities/_join_university.html.haml b/app/views/universities/_join_university.html.haml new file mode 100644 index 0000000..ab644e7 --- /dev/null +++ b/app/views/universities/_join_university.html.haml @@ -0,0 +1,12 @@ +.mt20.bgwhite.sb1.padding20.mb20 + %p Please Join the group and wait for admin and wait for moderators to approve + %p After joining only you are able to: + %ul + %li See Posts + %li Create Interative Posts + %li Share Images + %li Share Files + %li Chat With University Members + %li Comments on each other posts + %li See the member of this university + %p By joining this University you agree with our terms and conditions \ No newline at end of file diff --git a/app/views/universities/_members_common_links.html.haml b/app/views/universities/_members_common_links.html.haml new file mode 100644 index 0000000..637574d --- /dev/null +++ b/app/views/universities/_members_common_links.html.haml @@ -0,0 +1,15 @@ +%div{class: "padding20 bglgray sb1 dib w250 text-center" ,id: "user_box_#{member.user.id}"} + = profile_avatar_select(member.user) + %h6= link_to member.user.full_name,profile_path(member.user.user_name) + - if(current_user.is_univerisity_moderator(@university.id)) + - if(type == 'pending') + = link_to 'Approve',approve_university_path(university.id,member.user.id),class: 'btn btn-success',id:"approve_user_#{member.user.id}",remote: true,method: :post + - if( (type == 'pending' or type =='moderators' or type =='members' or type =='banned') && moderation_power(member.user,university)) + = link_to 'Delete',delete_university_path(university.id,member.user.id),class: 'btn btn-danger',id:"delete_user_#{member.user.id}",remote: true,method: :post + - if( (type == 'pending' or type =='moderators' or type =='members') && moderation_power(member.user,university) ) + = link_to 'Ban',ban_university_path(university.id,member.user.id),class: 'btn btn-warning',id:"ban_user_#{member.user.id}",remote: true,method: :post + - if(current_user.is_university_admin(@university.id)) + -if(type == 'moderators') + = link_to 'Demote',demote_moderator_university_path(university.id,member.user.id),class: 'btn btn-info',id:"demote_user_#{member.user.id}",remote: true,method: :post + -if(type == 'members') + = link_to 'Promote',make_moderator_university_path(university.id,member.user.id),class: 'btn btn-info',id:"promote_user_#{member.user.id}",remote: true,method: :post \ No newline at end of file diff --git a/app/views/universities/_messages.html.haml b/app/views/universities/_messages.html.haml new file mode 100644 index 0000000..b3bdf95 --- /dev/null +++ b/app/views/universities/_messages.html.haml @@ -0,0 +1,13 @@ +.card + .card-block + .row + .col-md-1 + = post_avatar_select message.user + .col-md-11 + %p.card-text + %span.text-muted + = message.user.user_name + #{time_ago_in_words(message.created_at)} ago says + + %br + = message.body \ No newline at end of file diff --git a/app/views/universities/approve.js.erb b/app/views/universities/approve.js.erb new file mode 100644 index 0000000..01bb1d5 --- /dev/null +++ b/app/views/universities/approve.js.erb @@ -0,0 +1 @@ +$('#approve_user_<%= @user_id %>').attr('class', 'btn btn-success') .text('Approved') .attr('href', "#").attr("disabled", true) \ No newline at end of file diff --git a/app/views/universities/ban.js.erb b/app/views/universities/ban.js.erb new file mode 100644 index 0000000..3556ff6 --- /dev/null +++ b/app/views/universities/ban.js.erb @@ -0,0 +1 @@ +$('#ban_user_<%= @user_id %>').attr('class', 'btn btn-success') .text('Banned') .attr('href', "#").attr("disabled", true) \ No newline at end of file diff --git a/app/views/universities/chat.html.haml b/app/views/universities/chat.html.haml new file mode 100644 index 0000000..af1309c --- /dev/null +++ b/app/views/universities/chat.html.haml @@ -0,0 +1,12 @@ +.bgwhite.sb1.mt20.mwidth960.mauto.padding20 + = render 'common_links' + %hr + - if current_user.is_university_approved(@university.id) + #university_messages{'data-university-id': @university.id } + - @university.university_message.order(created_at: :asc).reverse_order().limit(150).each do |message| + = render 'messages',message: message + + = form_for @university_message, url: '#' do |f| + .form-group + = f.text_area :body, class: 'form-control' + = f.submit "Send Messages", class: 'btn btn-primary ' \ No newline at end of file diff --git a/app/views/universities/delete.js.erb b/app/views/universities/delete.js.erb new file mode 100644 index 0000000..baa7ce5 --- /dev/null +++ b/app/views/universities/delete.js.erb @@ -0,0 +1 @@ +$('#user_box_<%= @user_id %>').remove(); \ No newline at end of file diff --git a/app/views/universities/demote_moderator.js.erb b/app/views/universities/demote_moderator.js.erb new file mode 100644 index 0000000..5822b25 --- /dev/null +++ b/app/views/universities/demote_moderator.js.erb @@ -0,0 +1 @@ +$('#demote_user_<%= @user_id %>').attr('class', 'btn btn-success') .text('Demoted') .attr('href', "#").attr("disabled", true) \ No newline at end of file diff --git a/app/views/universities/edit.html.haml b/app/views/universities/edit.html.haml new file mode 100644 index 0000000..697b04e --- /dev/null +++ b/app/views/universities/edit.html.haml @@ -0,0 +1,7 @@ +.post-wrapper + .post + .padding20 + %h4 Editing University + = render 'form', university: @university + = link_to 'Show', @university,class: 'btn btn-success' + = link_to 'Back', universities_path,class: 'btn btn-primary' diff --git a/app/views/universities/index.html.haml b/app/views/universities/index.html.haml new file mode 100644 index 0000000..eb05d58 --- /dev/null +++ b/app/views/universities/index.html.haml @@ -0,0 +1,15 @@ +.university-index-wrapper + %h2 Universities + -if current_user.role.name == 'admin' + = link_to 'New University', new_university_path,class:'btn btn-primary' + .div{style: 'clear:both'} + %br + - @universities.each do|university| + .university-index-box + .university-card + =link_to university_path(university) do + .university-card-thumbnail + = image_tag university.thumbnail_image.url(:original) + .university-card-details + .university-card-title + = university.name diff --git a/app/views/universities/join.js.erb b/app/views/universities/join.js.erb new file mode 100644 index 0000000..0cc9d02 --- /dev/null +++ b/app/views/universities/join.js.erb @@ -0,0 +1,3 @@ +$('#join_university_<%= @university_id %>').attr('class', 'btn btn-danger flat__buttons') + .text('Leave This University') + .attr('href', "/universities/<%= @university_id %>/unjoin/<%= @user_id %>") diff --git a/app/views/universities/make_moderator.js.erb b/app/views/universities/make_moderator.js.erb new file mode 100644 index 0000000..23a96ad --- /dev/null +++ b/app/views/universities/make_moderator.js.erb @@ -0,0 +1 @@ +$('#promote_user_<%= @user_id %>').attr('class', 'btn btn-success') .text('Promoted') .attr('href', "#").attr("disabled", true) \ No newline at end of file diff --git a/app/views/universities/members.html.haml b/app/views/universities/members.html.haml new file mode 100644 index 0000000..d391274 --- /dev/null +++ b/app/views/universities/members.html.haml @@ -0,0 +1,28 @@ +.bgwhite.sb1.mt20.mwidth960.mauto.padding20 + = render 'common_links' + %hr + - if current_user.is_university_approved(@university.id) + %h4 Moderators + -@members.each do |member| + -if(member.role_id == @moderator_role_id) + = render 'members_common_links',university: @university , member: member,type: 'moderators' + %hr + %h4 Members + -@members.each do |member| + -if(member.role_id == @approved_role_id) + = render 'members_common_links',university: @university , member: member,type: 'members' + %hr + - if current_user.is_university_approved(@university.id) + - if(current_user.is_univerisity_moderator(@university.id)) + %h4 Pending To Be Approved + -@members.each do |member| + -if(member.role_id == @pending_role_id) + = render 'members_common_links',university: @university , member: member,type: 'pending' + %hr + %h4 Banned Users + -@members.each do |member| + -if(member.role_id == @banned_role_id) + = render 'members_common_links',university: @university , member: member,type: 'banned' + %hr + - else + = render 'join_university' \ No newline at end of file diff --git a/app/views/universities/new.html.haml b/app/views/universities/new.html.haml new file mode 100644 index 0000000..bf19d9c --- /dev/null +++ b/app/views/universities/new.html.haml @@ -0,0 +1,6 @@ +.post-wrapper + .post + .padding20 + %h4 Creating New University: + = render 'form', university: @university + = link_to 'Back', universities_path,class: 'btn btn-primary' diff --git a/app/views/universities/show.html.haml b/app/views/universities/show.html.haml new file mode 100644 index 0000000..d790b0c --- /dev/null +++ b/app/views/universities/show.html.haml @@ -0,0 +1,27 @@ +.university-show-wrapper + .university-timeline + = link_to (image_tag @university.timeline_image.url(:original), class: 'university_timeline_image' ),universities_path(@university) + .container-fluid + .row + .col-sm-8 + = render 'common_links' + - if current_user.is_university_approved(@university.id) + %main#posts + .post-wrapper + .post + .padding20 + = render 'posts/form',{post: @post,postable: @university} + = render 'posts/posts',{posts: @posts,postable: @university} + #paginator.text-center + = link_to_next_page @posts, 'Load More', remote: true, id: 'load_more' + - else + = render 'join_university' + .col-sm-4 + .post-wrapper + = render 'join_and_unjoin_button',university:@university,user:current_user + - if current_user.is_university_approved(@university.id) + .post-wrapper + .post + .post-head + %h4 Description + = @university.description diff --git a/app/views/universities/show.js.erb b/app/views/universities/show.js.erb new file mode 100644 index 0000000..21dcb5f --- /dev/null +++ b/app/views/universities/show.js.erb @@ -0,0 +1,3 @@ +$('#posts').append("<%= escape_javascript(render 'posts/posts',posts:@posts,postable: @university)%>"); +$('#paginator').html("<%= escape_javascript(link_to_next_page(@posts, 'LOAD MORE', remote: true, id: 'load_more'))%>"); +if (!$('#load_more').length) { $('#paginator').remove(); } \ No newline at end of file diff --git a/app/views/universities/unjoin.js.erb b/app/views/universities/unjoin.js.erb new file mode 100644 index 0000000..71a00ab --- /dev/null +++ b/app/views/universities/unjoin.js.erb @@ -0,0 +1,3 @@ +$('#join_university_<%= @university_id %>').attr('class', 'btn btn-success flat__buttons') + .text('Join This University') + .attr('href', "/universities/<%= @university_id %>/join/<%= @user_id %>") diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml new file mode 100644 index 0000000..918d614 --- /dev/null +++ b/app/views/users/show.html.haml @@ -0,0 +1,14 @@ +.container + .row + .col-sm-8 + %main#posts + .post-wrapper + .post + .padding20 + = render 'posts/form',{post: @post,postable: current_user} + = render 'posts/posts',{posts: @posts,postable: current_user} + #paginator.text-center + = link_to_next_page @posts, 'LOAD MORE', remote: true, id: 'load_more' + + .col-sm-4 + = render 'layouts/chat_box',followed_user: @followed_user \ No newline at end of file diff --git a/bin/bundle b/bin/bundle new file mode 100644 index 0000000..e3c2f62 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby.exe +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100644 index 0000000..bec72ac --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby.exe +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100644 index 0000000..f6ed5a2 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby.exe +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100644 index 0000000..929edb7 --- /dev/null +++ b/bin/setup @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby.exe +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/update b/bin/update new file mode 100644 index 0000000..deb1df2 --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby.exe +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000..7e671a2 --- /dev/null +++ b/config/application.rb @@ -0,0 +1,15 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Kubh + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + end +end diff --git a/config/application.yml b/config/application.yml new file mode 100644 index 0000000..631fb58 --- /dev/null +++ b/config/application.yml @@ -0,0 +1,9 @@ +PORT: 80 + +production: + GMAIL_DOMAIN: gmail.com + GMAIL_USERNAME: remeahali@gmail.com + GMAIL_PASSWORD: bloggeris7 + SENDGRID_API_KEY: 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 + SECRET_KEY_BASE: 120b5ece87eb593ab6f1412f6dedf33bc7e60ed24b80ef296e0a4b33520e525a0c2809c2b04960d90155ddc1bbf3f7645d134a9253847f10cde44cf203ba2b5g + PORT: 80 \ No newline at end of file diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000..30f5120 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000..0bbde6f --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,9 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000..220b1a0 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,15 @@ +development: + adapter: sqlite3 + pool: 5 + timeout: 5000 + database: db/development.sqlite3 + +production: + adapter: postgresql + user: chatounce_admin + password: pgsql77 + pool: 5 + timeout: 5000 + host: localhost + min_messages: WARNING + database: chat_ounce \ No newline at end of file diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..e70b410 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,10 @@ +# config valid only for current version of Capistrano +lock "3.7.1" + +set :application, "chat_ounce" +set :repo_url, "git@bitbucket.org:bloggervista/chat-ounce.git" + +set :deploy_to, '/home/shirshak/chat_ounce' + +append :linked_files, "config/database.yml", "config/secrets.yml" +append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "vendor/bundle", "public/system", "public/uploads" \ No newline at end of file diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..3758804 --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,62 @@ +server '127.0.0.1', user: 'shirshak', roles: %w{app db web} +# server-based syntax +# ====================== +# Defines a single server with a list of roles and multiple properties. +# You can define all roles on a single server, or split them: + +# server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value +# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value +# server "db.example.com", user: "deploy", roles: %w{db} + + + +# role-based syntax +# ================== + +# Defines a role with one or multiple servers. The primary server in each +# group is considered to be the first unless any hosts have the primary +# property set. Specify the username and a domain or IP for the server. +# Don't use `:all`, it's a meta role. + +# role :app, %w{deploy@example.com}, my_property: :my_value +# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value +# role :db, %w{deploy@example.com} + + + +# Configuration +# ============= +# You can set any configuration variable like in config/deploy.rb +# These variables are then only loaded and set in this stage. +# For available Capistrano configuration variables see the documentation page. +# http://capistranorb.com/documentation/getting-started/configuration/ +# Feel free to add new variables to customise your setup. + + + +# Custom SSH Options +# ================== +# You may pass any option but keep in mind that net/ssh understands a +# limited set of options, consult the Net::SSH documentation. +# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start +# +# Global options +# -------------- +# set :ssh_options, { +# keys: %w(/home/rlisowski/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(password) +# } +# +# The server-based syntax can be used to override options: +# ------------------------------------ +# server "example.com", +# user: "user_name", +# roles: %w{web app}, +# ssh_options: { +# user: "user_name", # overrides user setting above +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(publickey password) +# # password: "please use keys" +# } diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000..7121427 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,55 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = true + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000..b73629e --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,88 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + config.public_file_server.enabled = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "chat_ounce_#{Rails.env}" + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000..30587ef --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=3600' + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..51639b6 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..01ef3e6 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 0000000..22a91d1 --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,274 @@ +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + # Devise will use the `secret_key_base` as its `secret_key` + # by default. You can change it below and use your own secret key. + config.secret_key = 'fc26fc8e83b27809ccd908bd9d0e3826e012b0b678a7a29f0e03d9bceed2b2c530fe3943356e8392ac6cdee3d1ab280a45705b151854d837727ce97b935d9b76' + + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class + # with default "from" parameter. + config.mailer_sender = 'admin@chatounce.com' + + # Configure the class responsible to send e-mails. + config.mailer = 'Devise::Mailer' + + # Configure the parent class responsible to send e-mails. + config.parent_mailer = 'ActionMailer::Base' + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [:email] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [:email] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [:email] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:database]` will + # enable it only for database authentication. The supported strategies are: + # :database = Support basic authentication with authentication key + password + # config.http_authenticatable = false + + # If 401 status code should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. 'Application' by default. + # config.http_authentication_realm = 'Application' + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # particular strategies by setting this option. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing skip: :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true + + # When false, Devise will not attempt to reload routes on eager load. + # This can reduce the time taken to boot the app but if your application + # requires the Devise mappings to be loaded during boot time the application + # won't boot properly. + # config.reload_routes = true + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 11. If + # using other algorithms, it sets how many times you want the password to be hashed. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. Note that, for bcrypt (the default + # algorithm), the cost increases exponentially with the number of stretches (e.g. + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). + config.stretches = Rails.env.test? ? 1 : 11 + + # Set up a pepper to generate the hashed password. + # config.pepper = '0fa4db07a697113efe4c1e406abf0699f12fc6dc211cf7f2dc73cf37465067da1b8407c7937d28eacc7f78b1ed1861bc300f2ce4dd336c9815703a7d688435ba' + + # Send a notification email when the user's password is changed + config.send_password_change_notification = false + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming their account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming their account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming their account. + config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed, new email is stored in + # unconfirmed_email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + config.confirmation_keys = [:email] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + config.remember_for = 2.weeks + + # Invalidates all the remember me tokens when the user signs out. + config.expire_all_remember_me_on_sign_out = true + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # Options to be passed to the created cookie. For instance, you can set + # secure: true in order to force SSL only cookies. + # config.rememberable_options = {} + + # ==> Configuration for :validatable + # Range for password length. + config.password_length = 6..128 + + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + config.unlock_keys = [:email] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + config.maximum_attempts = 10 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + config.unlock_in = 1.hour + + # Warn on the last attempt before the account is locked. + config.last_attempt_warning = true + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + config.reset_password_keys = [:email] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # When set to false, does not sign a user in automatically after their password is + # reset. Defaults to true, so a user is signed in automatically after a reset. + config.sign_in_after_reset_password = true + + # ==> Configuration for :encryptable + # Allow you to use another hashing or encryption algorithm besides bcrypt (default). + # You can use :sha1, :sha512 or algorithms from others authentication tools as + # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 + # for default behavior) and :restful_authentication_sha1 (then you should set + # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt + #config.encryptor = :sha512 + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ['*/*', :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(scope: :user).unshift :some_external_strategy + # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using OmniAuth, Devise cannot automatically set OmniAuth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' +end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb new file mode 100644 index 0000000..ed1fe79 --- /dev/null +++ b/config/initializers/kaminari_config.rb @@ -0,0 +1,10 @@ +Kaminari.configure do |config| + config.default_per_page = 10 + # config.max_per_page = nil + # config.window = 4 + # config.outer_window = 0 + # config.left = 0 + # config.right = 0 + # config.page_method_name = :page + # config.param_name = :page +end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb new file mode 100644 index 0000000..671abb6 --- /dev/null +++ b/config/initializers/new_framework_defaults.rb @@ -0,0 +1,24 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.0 upgrade. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Enable per-form CSRF tokens. Previous versions had false. +Rails.application.config.action_controller.per_form_csrf_tokens = true + +# Enable origin-checking CSRF mitigation. Previous versions had false. +Rails.application.config.action_controller.forgery_protection_origin_check = true + +# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. +# Previous versions had false. +ActiveSupport.to_time_preserves_timezone = true + +# Require `belongs_to` associations by default. Previous versions had false. +Rails.application.config.active_record.belongs_to_required_by_default = true + +# Do not halt callback chains when a callback returns false. Previous versions had true. +ActiveSupport.halt_callback_chains_on_return_false = false + +# Configure SSL options to enable HSTS with subdomains. Previous versions had false. +Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb new file mode 100644 index 0000000..99e6dc6 --- /dev/null +++ b/config/initializers/rails_admin.rb @@ -0,0 +1,44 @@ +RailsAdmin.config do |config| + + config.authorize_with do + redirect_to main_app.root_path unless current_user.role.name == 'admin' + end + ### Popular gems integration + + ## == Devise == + # config.authenticate_with do + # warden.authenticate! scope: :user + # end + # config.current_user_method(&:current_user) + + ## == Cancan == + # config.authorize_with :cancan + + ## == Pundit == + # config.authorize_with :pundit + + ## == PaperTrail == + # config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0 + + ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration + + ## == Gravatar integration == + ## To disable Gravatar integration in Navigation Bar set to false + # config.show_gravatar true + + config.actions do + dashboard # mandatory + index # mandatory + new + export + bulk_delete + show + edit + delete + show_in_app + + ## With an audit adapter, you can add: + # history_index + # history_show + end +end diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 0000000..1ccfcc4 --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_chat_ounce_session' diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb new file mode 100644 index 0000000..d5492e5 --- /dev/null +++ b/config/initializers/simple_form.rb @@ -0,0 +1,166 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + # Wrappers are used by the form builder to generate a + # complete input. You can remove any component from the + # wrapper, change the order or even add your own to the + # stack. The options given below are used to wrap the + # whole input. + config.wrappers :default, class: :input, + hint_class: :field_with_hint, error_class: :field_with_errors do |b| + ## Extensions enabled by default + # Any of these extensions can be disabled for a + # given input by passing: `f.input EXTENSION_NAME => false`. + # You can make any of these extensions optional by + # renaming `b.use` to `b.optional`. + + # Determines whether to use HTML5 (:email, :url, ...) + # and required attributes + b.use :html5 + + # Calculates placeholders automatically from I18n + # You can also pass a string as f.input placeholder: "Placeholder" + b.use :placeholder + + ## Optional extensions + # They are disabled unless you pass `f.input EXTENSION_NAME => true` + # to the input. If so, they will retrieve the values from the model + # if any exists. If you want to enable any of those + # extensions by default, you can change `b.optional` to `b.use`. + + # Calculates maxlength from length validations for string inputs + b.optional :maxlength + + # Calculates pattern from format validations for string inputs + b.optional :pattern + + # Calculates min and max from length validations for numeric inputs + b.optional :min_max + + # Calculates readonly automatically from readonly attributes + b.optional :readonly + + ## Inputs + b.use :label_input + b.use :hint, wrap_with: { tag: :span, class: :hint } + b.use :error, wrap_with: { tag: :span, class: :error } + + ## full_messages_for + # If you want to display the full error message for the attribute, you can + # use the component :full_error, like: + # + # b.use :full_error, wrap_with: { tag: :span, class: :error } + end + + # The default wrapper to be used by the FormBuilder. + config.default_wrapper = :default + + # Define the way to render check boxes / radio buttons with labels. + # Defaults to :nested for bootstrap config. + # inline: input + label + # nested: label > input + config.boolean_style = :nested + + # Default class for buttons + config.button_class = 'btn' + + # Method used to tidy up errors. Specify any Rails Array method. + # :first lists the first message for each field. + # Use :to_sentence to list all errors for each field. + # config.error_method = :first + + # Default tag used for error notification helper. + config.error_notification_tag = :div + + # CSS class to add for error notification helper. + config.error_notification_class = 'error_notification' + + # ID to add for error notification helper. + # config.error_notification_id = nil + + # Series of attempts to detect a default label method for collection. + # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] + + # Series of attempts to detect a default value method for collection. + # config.collection_value_methods = [ :id, :to_s ] + + # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. + # config.collection_wrapper_tag = nil + + # You can define the class to use on all collection wrappers. Defaulting to none. + # config.collection_wrapper_class = nil + + # You can wrap each item in a collection of radio/check boxes with a tag, + # defaulting to :span. Please note that when using :boolean_style = :nested, + # SimpleForm will force this option to be a label. + # config.item_wrapper_tag = :span + + # You can define a class to use in all item wrappers. Defaulting to none. + # config.item_wrapper_class = nil + + # How the label text should be generated altogether with the required text. + # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } + + # You can define the class to use on all labels. Default is nil. + # config.label_class = nil + + # You can define the default class to be used on forms. Can be overriden + # with `html: { :class }`. Defaulting to none. + # config.default_form_class = nil + + # You can define which elements should obtain additional classes + # config.generate_additional_classes_for = [:wrapper, :label, :input] + + # Whether attributes are required by default (or not). Default is true. + # config.required_by_default = true + + # Tell browsers whether to use the native HTML5 validations (novalidate form option). + # These validations are enabled in SimpleForm's internal config but disabled by default + # in this configuration, which is recommended due to some quirks from different browsers. + # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, + # change this configuration to true. + config.browser_validations = false + + # Collection of methods to detect if a file type was given. + # config.file_methods = [ :mounted_as, :file?, :public_filename ] + + # Custom mappings for input types. This should be a hash containing a regexp + # to match as key, and the input type that will be used when the field name + # matches the regexp as value. + # config.input_mappings = { /count/ => :integer } + + # Custom wrappers for input types. This should be a hash containing an input + # type as key and the wrapper that will be used for all inputs with specified type. + # config.wrapper_mappings = { string: :prepend } + + # Namespaces where SimpleForm should look for custom input classes that + # override default inputs. + # config.custom_inputs_namespaces << "CustomInputs" + + # Default priority for time_zone inputs. + # config.time_zone_priority = nil + + # Default priority for country inputs. + # config.country_priority = nil + + # When false, do not use translations for labels. + # config.translate_labels = true + + # Automatically discover new inputs in Rails' autoload path. + # config.inputs_discovery = true + + # Cache SimpleForm inputs discovery + # config.cache_discovery = !Rails.env.development? + + # Default class for inputs + # config.input_class = nil + + # Define the default class of the input wrapper of the boolean input. + config.boolean_label_class = 'checkbox' + + # Defines if the default input wrapper class should be included in radio + # collection wrappers. + # config.include_default_input_wrapper_class = true + + # Defines which i18n scope will be used in Simple Form. + # config.i18n_scope = 'simple_form' +end diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb new file mode 100644 index 0000000..ea4a63d --- /dev/null +++ b/config/initializers/simple_form_bootstrap.rb @@ -0,0 +1,136 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + config.error_notification_class = 'alert alert-danger' + config.button_class = 'btn btn-default' + config.boolean_label_class = nil + + config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :pattern + b.optional :min_max + b.optional :readonly + b.use :label, class: 'control-label' + + b.use :input, class: 'form-control' + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :readonly + b.use :label, class: 'control-label' + + b.use :input + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + + b.wrapper tag: 'div', class: 'checkbox' do |ba| + ba.use :label_input + end + + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + b.use :label, class: 'control-label' + b.use :input + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :pattern + b.optional :min_max + b.optional :readonly + b.use :label, class: 'col-sm-3 control-label' + + b.wrapper tag: 'div', class: 'col-sm-9' do |ba| + ba.use :input, class: 'form-control' + ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :readonly + b.use :label, class: 'col-sm-3 control-label' + + b.wrapper tag: 'div', class: 'col-sm-9' do |ba| + ba.use :input + ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + + b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| + wr.wrapper tag: 'div', class: 'checkbox' do |ba| + ba.use :label_input, class: 'col-sm-9' + end + + wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } + wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + + b.use :label, class: 'col-sm-3 control-label' + + b.wrapper tag: 'div', class: 'col-sm-9' do |ba| + ba.use :input + ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :pattern + b.optional :min_max + b.optional :readonly + b.use :label, class: 'sr-only' + + b.use :input, class: 'form-control' + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + # Wrappers for forms and inputs using the Bootstrap toolkit. + # Check the Bootstrap docs (http://getbootstrap.com) + # to learn about the different styles for forms and inputs, + # buttons and other elements. + config.default_wrapper = :vertical_form + config.wrapper_mappings = { + check_boxes: :vertical_radio_and_checkboxes, + radio_buttons: :vertical_radio_and_checkboxes, + file: :vertical_file_input, + boolean: :vertical_boolean, + } +end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..bbfc396 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 0000000..6641f9d --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,62 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + devise: + confirmations: + confirmed: "Your email address has been successfully confirmed." + send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." + failure: + already_authenticated: "You are already logged in." + inactive: "Your account is not activated yet." + invalid: "Invalid %{authentication_keys} or password." + locked: "Your account is locked." + last_attempt: "You have one more attempt before your account is locked." + not_found_in_database: "Invalid %{authentication_keys} or password." + timeout: "Your session expired. Please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your email address before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock instructions" + password_change: + subject: "Password Changed" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." + send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." + updated: "Your password has been changed successfully. You are now signed in." + updated_not_active: "Your password has been changed successfully." + registrations: + destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address." + updated: "Your account has been updated successfully." + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + already_signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." + errors: + messages: + already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" + expired: "has expired, please request a new one" + not_found: "not found" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000..c7f311f --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,47 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum, this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted this block will be run, if you are using `preload_app!` +# option you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..282433d --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,104 @@ +Rails.application.routes.draw do + mount RailsAdmin::Engine => '/admin', as: 'rails_admin' + #---------------------------------------------------- + # Index + #---------------------------------------------------- + root 'dashboard#index' + #---------------------------------------------------- + # Follow And Unfollow User + #---------------------------------------------------- + get 'relationships/follow_user' + get 'relationships/unfollow_user' + post ':user_name/follow_user', to: 'relationships#follow_user', as: :follow_user , :user_name => /[a-zA-Z0-9_\.]*/ + post ':user_name/unfollow_user', to: 'relationships#unfollow_user', as: :unfollow_user ,:user_name => /[a-zA-Z0-9_\.]*/ + + #---------------------------------------------------- + # Notifications + #---------------------------------------------------- + resources :notifications do + collection do + post :mark_notifications_as_read + post :mark_messages_notification_as_read + end + end + #---------------------------------------------------- + # Making Devise to support preety url + #---------------------------------------------------- + devise_scope :user do + get "/register" => "devise/registrations#new", as: "new_user_registration" + end + devise_for :users, skip: [:sessions] + as :user do + get 'login', to: 'devise/sessions#new', as: :new_user_session + post 'login', to: 'devise/sessions#create', as: :user_session + delete 'logout', to: 'devise/sessions#destroy', as: :destroy_user_session + end + + #---------------------------------------------------- + # Concerns for Post , Comments and Likes + #---------------------------------------------------- + concern :postable do + resources :posts ,except:[:new] do + resources :comments,only:[:index,:create,:destroy] + member do + get 'like' + get 'unlike' + end + end + end + + #---------------------------------------------------- + # Post witch concerns of post comment likes + #---------------------------------------------------- + resources :users,only: [:show] ,concerns: :postable + #---------------------------------------------------- + # University + #---------------------------------------------------- + resources :universities,concerns: :postable do + member do + get 'members',:as=>'members' + + post 'join/:user_id', :to => "universities#join", :as => 'join' + post 'unjoin/:user_id', :to => "universities#unjoin", :as => 'unjoin' + + post 'approve/:user_id', :to => "universities#approve", :as => 'approve' + post 'ban/:user_id', :to => "universities#ban", :as => 'ban' + post 'delete/:user_id', :to => "universities#delete", :as => 'delete' + + post 'make_moderator/:user_id', :to => "universities#make_moderator", :as => 'make_moderator' + post 'demote_moderator/:user_id', :to => "universities#demote_moderator", :as => 'demote_moderator' + + get 'chat', :to => "universities#chat", :as => 'chat' + end + end + #---------------------------------------------------- + # Showing All Users + #---------------------------------------------------- + get 'all-users', to: 'profiles#show_all_users' + + #---------------------------------------------------- + # Profile + #---------------------------------------------------- + get 'profiles/show' + get '@:user_name', to: 'profiles#show', as: :profile ,:user_name => /[a-zA-Z0-9_\.]*/ + get '@:user_name/edit', to: 'profiles#edit', as: :edit_profile , :user_name => /[a-zA-Z0-9_\.]*/ + patch '@:user_name/edit', to: 'profiles#update', as: :update_profile ,:user_name => /[a-zA-Z0-9_\.]*/ + + #---------------------------------------------------- + # Chat Message + #---------------------------------------------------- + resources :chat_rooms, only: [:new, :create, :show, :index] + + #---------------------------------------------------- + # Search + #---------------------------------------------------- + get 'search' , to: 'dashboard#search' + #---------------------------------------------------- + # Personal Message + #---------------------------------------------------- + resources :personal_messages, only: [:new, :create] + resources :conversations, only: [:index, :show] + post 'conversations_api', to: 'personal_messages#api' + + mount ActionCable.server => '/cable' +end \ No newline at end of file diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 0000000..67eee2e --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,6 @@ +development: + secret_key_base: 3bcfc5638e4ccbaa0a617cd2804724e656b11938fcf515e67bc79d7a1df02a74815e53647b310a28899f6498d3c5bc36735be67120925a97188755699e43153e +test: + secret_key_base: 110b5ece87eb593ab6f1412f6dedf33bc7e60ed24b80ef296e0a4b33520e525a0c2809c2b04960d90155ddc1bbf3f7645d134a9253847f10cde44cf203ba2b5f +production: + secret_key_base: 110b5ecf87eb593ab6f1412f6dedf33bc7e60ed24b80ef296e0a4b33520e525a0c2809c2b04960d90155ddc1bbf3f7645d134a9253847f10cde44cf203ba2b5g diff --git a/db/migrate/20150617010614_create_posts.rb b/db/migrate/20150617010614_create_posts.rb new file mode 100644 index 0000000..23230ab --- /dev/null +++ b/db/migrate/20150617010614_create_posts.rb @@ -0,0 +1,9 @@ +class CreatePosts < ActiveRecord::Migration + def change + create_table :posts do |t| + t.text :content + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20150617013037_add_attachment_image_to_posts.rb b/db/migrate/20150617013037_add_attachment_image_to_posts.rb new file mode 100644 index 0000000..af7844e --- /dev/null +++ b/db/migrate/20150617013037_add_attachment_image_to_posts.rb @@ -0,0 +1,11 @@ +class AddAttachmentImageToPosts < ActiveRecord::Migration + def self.up + change_table :posts do |t| + t.attachment :attachment + end + end + + def self.down + remove_attachment :posts, :attachment + end +end diff --git a/db/migrate/20150711011916_devise_create_users.rb b/db/migrate/20150711011916_devise_create_users.rb new file mode 100644 index 0000000..5144934 --- /dev/null +++ b/db/migrate/20150711011916_devise_create_users.rb @@ -0,0 +1,43 @@ +class DeviseCreateUsers < ActiveRecord::Migration + def change + create_table(:users) do |t| + ## Database authenticatable + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" + t.boolean :admin + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, default: 0, null: false + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## Confirmable + t.string :confirmation_token + t.datetime :confirmed_at + t.datetime :confirmation_sent_at + t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts + t.string :unlock_token # Only if unlock strategy is :email or :both + t.datetime :locked_at + + + t.timestamps null: false + end + + add_index :users, :email, unique: true + add_index :users, :reset_password_token, unique: true + add_index :users, :confirmation_token, unique: true + add_index :users, :unlock_token, unique: true + end +end diff --git a/db/migrate/20150711011919_add_first_name_last_name_user_name_to_user.rb b/db/migrate/20150711011919_add_first_name_last_name_user_name_to_user.rb new file mode 100644 index 0000000..093f277 --- /dev/null +++ b/db/migrate/20150711011919_add_first_name_last_name_user_name_to_user.rb @@ -0,0 +1,7 @@ +class AddFirstNameLastNameUserNameToUser < ActiveRecord::Migration + def change + add_column :users, :first_name, :string + add_column :users, :last_name, :string + add_column :users, :user_name, :string + end +end diff --git a/db/migrate/20150711072447_add_user_id_to_posts.rb b/db/migrate/20150711072447_add_user_id_to_posts.rb new file mode 100644 index 0000000..1bea36e --- /dev/null +++ b/db/migrate/20150711072447_add_user_id_to_posts.rb @@ -0,0 +1,6 @@ +class AddUserIdToPosts < ActiveRecord::Migration + def change + add_reference :posts, :user, index: true + add_foreign_key :posts, :users + end +end diff --git a/db/migrate/20150713011155_create_comments.rb b/db/migrate/20150713011155_create_comments.rb new file mode 100644 index 0000000..677de33 --- /dev/null +++ b/db/migrate/20150713011155_create_comments.rb @@ -0,0 +1,13 @@ +class CreateComments < ActiveRecord::Migration + def change + create_table :comments do |t| + t.references :user, index: true + t.references :post, index: true + t.text :content + + t.timestamps null: false + end + add_foreign_key :comments, :users + add_foreign_key :comments, :posts + end +end diff --git a/db/migrate/20151016102706_add_attachment_avatar_to_users.rb b/db/migrate/20151016102706_add_attachment_avatar_to_users.rb new file mode 100644 index 0000000..1d87ba8 --- /dev/null +++ b/db/migrate/20151016102706_add_attachment_avatar_to_users.rb @@ -0,0 +1,11 @@ +class AddAttachmentAvatarToUsers < ActiveRecord::Migration + def self.up + change_table :users do |t| + t.attachment :avatar + end + end + + def self.down + remove_attachment :users, :avatar + end +end diff --git a/db/migrate/20151016103736_add_bio_to_users.rb b/db/migrate/20151016103736_add_bio_to_users.rb new file mode 100644 index 0000000..7198e99 --- /dev/null +++ b/db/migrate/20151016103736_add_bio_to_users.rb @@ -0,0 +1,5 @@ +class AddBioToUsers < ActiveRecord::Migration + def change + add_column :users, :bio, :text + end +end diff --git a/db/migrate/20151029095601_acts_as_votable_migration.rb b/db/migrate/20151029095601_acts_as_votable_migration.rb new file mode 100644 index 0000000..5f381af --- /dev/null +++ b/db/migrate/20151029095601_acts_as_votable_migration.rb @@ -0,0 +1,27 @@ +class ActsAsVotableMigration < ActiveRecord::Migration + def self.up + create_table :votes do |t| + + t.references :votable, :polymorphic => true + t.references :voter, :polymorphic => true + + t.boolean :vote_flag + t.string :vote_scope + t.integer :vote_weight + + t.timestamps + end + + if ActiveRecord::VERSION::MAJOR < 4 + add_index :votes, [:votable_id, :votable_type] + add_index :votes, [:voter_id, :voter_type] + end + + add_index :votes, [:voter_id, :voter_type, :vote_scope] + add_index :votes, [:votable_id, :votable_type, :vote_scope] + end + + def self.down + drop_table :votes + end +end diff --git a/db/migrate/20160629131918_add_index_to_user.rb b/db/migrate/20160629131918_add_index_to_user.rb new file mode 100644 index 0000000..eab9ba5 --- /dev/null +++ b/db/migrate/20160629131918_add_index_to_user.rb @@ -0,0 +1,5 @@ +class AddIndexToUser < ActiveRecord::Migration + def change + add_index :users, :user_name,unique: true + end +end diff --git a/db/migrate/20160630205627_create_follow_join_table.rb b/db/migrate/20160630205627_create_follow_join_table.rb new file mode 100644 index 0000000..b40c8d3 --- /dev/null +++ b/db/migrate/20160630205627_create_follow_join_table.rb @@ -0,0 +1,14 @@ +class CreateFollowJoinTable < ActiveRecord::Migration + def change + create_table 'follows' do |t| + t.integer 'following_id', :null => false + t.integer 'follower_id', :null => false + + t.timestamps null: false + end + + add_index :follows, :following_id + add_index :follows, :follower_id + add_index :follows, [:following_id, :follower_id], unique: true + end +end \ No newline at end of file diff --git a/db/migrate/20170108121402_add_gender_to_users.rb b/db/migrate/20170108121402_add_gender_to_users.rb new file mode 100644 index 0000000..75a0990 --- /dev/null +++ b/db/migrate/20170108121402_add_gender_to_users.rb @@ -0,0 +1,5 @@ +class AddGenderToUsers < ActiveRecord::Migration[5.0] + def change + add_column :users, :is_female, :boolean, default: false + end +end diff --git a/db/migrate/20170109015355_create_chat_rooms.rb b/db/migrate/20170109015355_create_chat_rooms.rb new file mode 100644 index 0000000..cfcfb81 --- /dev/null +++ b/db/migrate/20170109015355_create_chat_rooms.rb @@ -0,0 +1,10 @@ +class CreateChatRooms < ActiveRecord::Migration[5.0] + def change + create_table :chat_rooms do |t| + t.string :title + t.references :user, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20170109021542_create_messages.rb b/db/migrate/20170109021542_create_messages.rb new file mode 100644 index 0000000..f25e343 --- /dev/null +++ b/db/migrate/20170109021542_create_messages.rb @@ -0,0 +1,11 @@ +class CreateMessages < ActiveRecord::Migration[5.0] + def change + create_table :messages do |t| + t.text :body + t.references :user, foreign_key: true + t.references :chat_room, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20170109033234_create_conversations.rb b/db/migrate/20170109033234_create_conversations.rb new file mode 100644 index 0000000..37f7581 --- /dev/null +++ b/db/migrate/20170109033234_create_conversations.rb @@ -0,0 +1,13 @@ +class CreateConversations < ActiveRecord::Migration[5.0] + def change + create_table :conversations do |t| + t.integer :author_id + t.integer :receiver_id + + t.timestamps + end + add_index :conversations, :author_id + add_index :conversations, :receiver_id + add_index :conversations, [:author_id, :receiver_id], unique: true + end +end diff --git a/db/migrate/20170109033246_create_personal_messages.rb b/db/migrate/20170109033246_create_personal_messages.rb new file mode 100644 index 0000000..27a49bd --- /dev/null +++ b/db/migrate/20170109033246_create_personal_messages.rb @@ -0,0 +1,11 @@ +class CreatePersonalMessages < ActiveRecord::Migration[5.0] + def change + create_table :personal_messages do |t| + t.text :body + t.belongs_to :conversation, foreign_key: true + t.belongs_to :user, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20170111190236_create_universities.rb b/db/migrate/20170111190236_create_universities.rb new file mode 100644 index 0000000..a6547c9 --- /dev/null +++ b/db/migrate/20170111190236_create_universities.rb @@ -0,0 +1,10 @@ +class CreateUniversities < ActiveRecord::Migration[5.0] + def change + create_table :universities do |t| + t.string :name + t.text :description + + t.timestamps + end + end +end diff --git a/db/migrate/20170111190314_add_attachment_thumbnail_image_to_universities.rb b/db/migrate/20170111190314_add_attachment_thumbnail_image_to_universities.rb new file mode 100644 index 0000000..89c4ac2 --- /dev/null +++ b/db/migrate/20170111190314_add_attachment_thumbnail_image_to_universities.rb @@ -0,0 +1,11 @@ +class AddAttachmentThumbnailImageToUniversities < ActiveRecord::Migration + def self.up + change_table :universities do |t| + t.attachment :thumbnail_image + end + end + + def self.down + remove_attachment :universities, :thumbnail_image + end +end diff --git a/db/migrate/20170111190347_add_attachment_timeline_image_to_universities.rb b/db/migrate/20170111190347_add_attachment_timeline_image_to_universities.rb new file mode 100644 index 0000000..9f10803 --- /dev/null +++ b/db/migrate/20170111190347_add_attachment_timeline_image_to_universities.rb @@ -0,0 +1,11 @@ +class AddAttachmentTimelineImageToUniversities < ActiveRecord::Migration + def self.up + change_table :universities do |t| + t.attachment :timeline_image + end + end + + def self.down + remove_attachment :universities, :timeline_image + end +end diff --git a/db/migrate/20170112103924_create_roles.rb b/db/migrate/20170112103924_create_roles.rb new file mode 100644 index 0000000..10bcf07 --- /dev/null +++ b/db/migrate/20170112103924_create_roles.rb @@ -0,0 +1,9 @@ +class CreateRoles < ActiveRecord::Migration[5.0] + def change + create_table :roles do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20170112104003_add_role_id_to_user.rb b/db/migrate/20170112104003_add_role_id_to_user.rb new file mode 100644 index 0000000..06e891d --- /dev/null +++ b/db/migrate/20170112104003_add_role_id_to_user.rb @@ -0,0 +1,5 @@ +class AddRoleIdToUser < ActiveRecord::Migration[5.0] + def change + add_reference :users, :role, foreign_key: true + end +end diff --git a/db/migrate/20170112120211_add_columns_to_post.rb b/db/migrate/20170112120211_add_columns_to_post.rb new file mode 100644 index 0000000..5ae4320 --- /dev/null +++ b/db/migrate/20170112120211_add_columns_to_post.rb @@ -0,0 +1,10 @@ +class AddColumnsToPost < ActiveRecord::Migration[5.0] + def up + add_column :posts, :postable_type, :string + add_column :posts, :postable_id, :integer + end + def down + remove_column :posts, :postable_type, :string + remove_column :posts, :postable_id, :integer + end +end diff --git a/db/migrate/20170112120249_remove_admin_from_user.rb b/db/migrate/20170112120249_remove_admin_from_user.rb new file mode 100644 index 0000000..2db07a9 --- /dev/null +++ b/db/migrate/20170112120249_remove_admin_from_user.rb @@ -0,0 +1,9 @@ +class RemoveAdminFromUser < ActiveRecord::Migration[5.0] + def up + remove_column :users, :admin + end + + def down + add_column :users, :admin, :boolean + end +end diff --git a/db/migrate/20170112174749_add_indexing_to_posts.rb b/db/migrate/20170112174749_add_indexing_to_posts.rb new file mode 100644 index 0000000..b71c5e6 --- /dev/null +++ b/db/migrate/20170112174749_add_indexing_to_posts.rb @@ -0,0 +1,5 @@ +class AddIndexingToPosts < ActiveRecord::Migration[5.0] + def change + add_index :posts,[:postable_id,:postable_type] + end +end diff --git a/db/migrate/20170114064428_create_university_memberships.rb b/db/migrate/20170114064428_create_university_memberships.rb new file mode 100644 index 0000000..cabed00 --- /dev/null +++ b/db/migrate/20170114064428_create_university_memberships.rb @@ -0,0 +1,14 @@ +class CreateUniversityMemberships < ActiveRecord::Migration[5.0] + def change + create_table :university_memberships do |t| + t.integer "user_id" + t.integer "university_id" + t.integer "role_id" + t.timestamps + end + add_index :university_memberships, :user_id + add_index :university_memberships, :university_id + add_index :university_memberships, :role_id + add_index :university_memberships, [:user_id, :university_id], unique: true + end +end \ No newline at end of file diff --git a/db/migrate/20170115053259_add_attachment_attachment_to_personal_messages.rb b/db/migrate/20170115053259_add_attachment_attachment_to_personal_messages.rb new file mode 100644 index 0000000..112a3a3 --- /dev/null +++ b/db/migrate/20170115053259_add_attachment_attachment_to_personal_messages.rb @@ -0,0 +1,11 @@ +class AddAttachmentAttachmentToPersonalMessages < ActiveRecord::Migration + def self.up + change_table :personal_messages do |t| + t.attachment :attachment + end + end + + def self.down + remove_attachment :personal_messages, :attachment + end +end diff --git a/db/migrate/20170115070355_create_notifications.rb b/db/migrate/20170115070355_create_notifications.rb new file mode 100644 index 0000000..9407cd8 --- /dev/null +++ b/db/migrate/20170115070355_create_notifications.rb @@ -0,0 +1,14 @@ +class CreateNotifications < ActiveRecord::Migration[5.0] + def change + create_table :notifications do |t| + t.integer :recipient_id + t.integer :actor_id + t.datetime :read_at + t.string :action + t.integer :notifiable_id + t.string :notifiable_type + + t.timestamps + end + end +end diff --git a/db/migrate/20170116043801_create_university_messages.rb b/db/migrate/20170116043801_create_university_messages.rb new file mode 100644 index 0000000..3e2cf3b --- /dev/null +++ b/db/migrate/20170116043801_create_university_messages.rb @@ -0,0 +1,11 @@ +class CreateUniversityMessages < ActiveRecord::Migration[5.0] + def change + create_table :university_messages do |t| + t.text :body + t.references :user, foreign_key: true + t.references :university, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..85cb50b --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,198 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20170116043801) do + + create_table "chat_rooms", force: :cascade do |t| + t.string "title" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_chat_rooms_on_user_id" + end + + create_table "comments", force: :cascade do |t| + t.integer "user_id" + t.integer "post_id" + t.text "content" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["post_id"], name: "index_comments_on_post_id" + t.index ["user_id"], name: "index_comments_on_user_id" + end + + create_table "conversations", force: :cascade do |t| + t.integer "author_id" + t.integer "receiver_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["author_id", "receiver_id"], name: "index_conversations_on_author_id_and_receiver_id", unique: true + t.index ["author_id"], name: "index_conversations_on_author_id" + t.index ["receiver_id"], name: "index_conversations_on_receiver_id" + end + + create_table "follows", force: :cascade do |t| + t.integer "following_id", null: false + t.integer "follower_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["follower_id"], name: "index_follows_on_follower_id" + t.index ["following_id", "follower_id"], name: "index_follows_on_following_id_and_follower_id", unique: true + t.index ["following_id"], name: "index_follows_on_following_id" + end + + create_table "messages", force: :cascade do |t| + t.text "body" + t.integer "user_id" + t.integer "chat_room_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["chat_room_id"], name: "index_messages_on_chat_room_id" + t.index ["user_id"], name: "index_messages_on_user_id" + end + + create_table "notifications", force: :cascade do |t| + t.integer "recipient_id" + t.integer "actor_id" + t.datetime "read_at" + t.string "action" + t.integer "notifiable_id" + t.string "notifiable_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "personal_messages", force: :cascade do |t| + t.text "body" + t.integer "conversation_id" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "attachment_file_name" + t.string "attachment_content_type" + t.integer "attachment_file_size" + t.datetime "attachment_updated_at" + t.index ["conversation_id"], name: "index_personal_messages_on_conversation_id" + t.index ["user_id"], name: "index_personal_messages_on_user_id" + end + + create_table "posts", force: :cascade do |t| + t.text "content" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "attachment_file_name" + t.string "attachment_content_type" + t.integer "attachment_file_size" + t.datetime "attachment_updated_at" + t.integer "user_id" + t.string "postable_type" + t.integer "postable_id" + t.index ["postable_id", "postable_type"], name: "index_posts_on_postable_id_and_postable_type" + t.index ["user_id"], name: "index_posts_on_user_id" + end + + create_table "roles", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "universities", force: :cascade do |t| + t.string "name" + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "thumbnail_image_file_name" + t.string "thumbnail_image_content_type" + t.integer "thumbnail_image_file_size" + t.datetime "thumbnail_image_updated_at" + t.string "timeline_image_file_name" + t.string "timeline_image_content_type" + t.integer "timeline_image_file_size" + t.datetime "timeline_image_updated_at" + end + + create_table "university_memberships", force: :cascade do |t| + t.integer "user_id" + t.integer "university_id" + t.integer "role_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["role_id"], name: "index_university_memberships_on_role_id" + t.index ["university_id"], name: "index_university_memberships_on_university_id" + t.index ["user_id", "university_id"], name: "index_university_memberships_on_user_id_and_university_id", unique: true + t.index ["user_id"], name: "index_university_memberships_on_user_id" + end + + create_table "university_messages", force: :cascade do |t| + t.text "body" + t.integer "user_id" + t.integer "university_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["university_id"], name: "index_university_messages_on_university_id" + t.index ["user_id"], name: "index_university_messages_on_user_id" + end + + create_table "users", force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", default: 0, null: false + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" + t.string "unconfirmed_email" + t.integer "failed_attempts", default: 0, null: false + t.string "unlock_token" + t.datetime "locked_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "first_name" + t.string "last_name" + t.string "user_name" + t.string "avatar_file_name" + t.string "avatar_content_type" + t.integer "avatar_file_size" + t.datetime "avatar_updated_at" + t.text "bio" + t.boolean "is_female", default: false + t.integer "role_id" + t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + t.index ["role_id"], name: "index_users_on_role_id" + t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true + t.index ["user_name"], name: "index_users_on_user_name", unique: true + end + + create_table "votes", force: :cascade do |t| + t.string "votable_type" + t.integer "votable_id" + t.string "voter_type" + t.integer "voter_id" + t.boolean "vote_flag" + t.string "vote_scope" + t.integer "vote_weight" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["votable_id", "votable_type", "vote_scope"], name: "index_votes_on_votable_id_and_votable_type_and_vote_scope" + t.index ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000..a915402 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,15 @@ +['registered', 'banned', 'moderator', 'admin','group_approved','group_pending_approval'].each do |role| + Role.find_or_create_by({name: role}) +end + +admin_user = {email: 'admin@admin.com', + password_confirmation: 'admin123', + password: 'admin123', + first_name: "Admin", + last_name: "Admin", + user_name: "Administrator", + bio: "Admin is the super user", + is_female: false + } +a = Role.where(name: 'admin').first.users.build(admin_user) +a.save! diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + +You may have mistyped the address or the page may have moved.
+If you are the application owner check the logs for more information.
+Maybe you tried to change something you didn't have access to.
+If you are the application owner check the logs for more information.
+If you are the application owner check the logs for more information.
+