diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js index f0db0fd21..8ad8851f3 100644 --- a/app/assets/javascripts/common.js +++ b/app/assets/javascripts/common.js @@ -1,15 +1,10 @@ -$(document).ready(function() { - // $("#hide-upgrade-account-link").click(function() { - // $("#upgrade-account").hide(); - // Cookie.put('hide-upgrade-account', '1', 7); - // }); - +$(function() { // Table striping - $("table.striped tbody tr:even").addClass("even"); - $("table.striped tbody tr:odd").addClass("odd"); + $(".striped tbody tr:even").addClass("even"); + $(".striped tbody tr:odd").addClass("odd"); + // More link if ($("#site-map-link").length > 0) { - // More link $("#site-map-link").click(function(e) { $("#more-links").toggle(); e.preventDefault(); @@ -27,6 +22,19 @@ $(document).ready(function() { }); } + // Account notices + $("#hide-sign-up-notice").click(function(e) { + $("#sign-up-notice").hide(); + Danbooru.Cookie.put("hide_sign_up_notice", "1", 7); + e.preventDefault(); + }); + + $("#hide-upgrade-account-notice").click(function(e) { + $("#upgrade-account-notice").hide(); + Danbooru.Cookie.put('hide_upgrade_account_notice', '1', 7); + e.preventDefault(); + }); + // Ajax links $("a[data-remote=true]").click(function(e) { Danbooru.ajax_start(e.target); @@ -38,7 +46,6 @@ $(document).ready(function() { // TOS link if (!location.href.match(/terms_of_service/) && Danbooru.Cookie.get("tos") !== "1") { - // Setting location.pathname in Safari doesn't work, so manually extract the domain. var domain = location.href.match(/^(http:\/\/[^\/]+)/)[0]; location.href = domain + "/static/terms_of_service?url=" + location.href; } diff --git a/app/assets/stylesheets/common/main_layout.css.scss b/app/assets/stylesheets/common/main_layout.css.scss index f64c44d55..2f6de2dc5 100644 --- a/app/assets/stylesheets/common/main_layout.css.scss +++ b/app/assets/stylesheets/common/main_layout.css.scss @@ -8,6 +8,22 @@ div#page { overflow: visible; margin: 0 30px; + div#upgrade-account-notice, div#sign-up-notice { + margin: 1em 0; + padding: 1em; + text-align: center; + position: relative; + + h1 { + font-size: $h2_size; + font-weight: bold; + } + + p { + margin: 0; + } + } + aside#sidebar { width: 20%; float: left; diff --git a/app/assets/stylesheets/specific/users.css.scss b/app/assets/stylesheets/specific/users.css.scss index 4a60f4763..6daeedca2 100644 --- a/app/assets/stylesheets/specific/users.css.scss +++ b/app/assets/stylesheets/specific/users.css.scss @@ -20,34 +20,17 @@ div#c-users { max-width: 50em; p { + font-size: 1.2em; margin-bottom: 1em; + line-height: 1.4em; } - li { - margin-left: 1em; - list-style-type: disc; + input[type=submit] { + padding: 5px 20px; + font-size: 20pt; + font-weight: bold; } - - div#account-comparison { - padding: 0 1em; - margin: 1em 0; - - h1 { - font-size: $h3_size; - } - - li { - font-size: 0.8em; - line-height: 1.5em; - } - - section { - width: 15em; - float: left; - padding-right: 1em; - } - } - + footer.nav-links { font-size: 1.4545em; font-weight: bold; @@ -59,4 +42,55 @@ div#c-users { margin-bottom: 2em; } } + + div#a-upgrade-information { + max-width: 55em; + font-size: 1.2em; + + form { + input { + font-size: 20pt; + } + + input[type=submit] { + padding: 5px 20px; + font-weight: bold; + } + } + + div#feature-comparison { + overflow: hidden; + margin-bottom: 1em; + + div.column { + width: 15em; + float: left; + border: 1px solid #666; + @include border-radius(4px); + padding: 0.25em 0.5em; + margin: 0.5em; + + h1 { + font-size: $h3_size; + } + + li { + margin-left: 1.5em; + list-style-type: disc; + } + + &#basic-account { + background: rgb(240, 255, 240); + } + + &#privileged-account { + background: rgb(255, 255, 240); + } + + &#contributor-account { + background: rgb(240, 240, 240); + } + } + } + } } \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c0cf98459..ce56d8519 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base after_filter :reset_current_user before_filter :initialize_cookies before_filter :set_title + before_filter :set_started_at_session layout "default" rescue_from User::PrivilegeError, :with => :access_denied @@ -40,6 +41,12 @@ protected CurrentUser.ip_addr = nil end + def set_started_at_session + if session[:started_at].blank? + session[:started_at] = Time.now + end + end + %w(member banned privileged contributor janitor moderator admin).each do |level| define_method("#{level}_only") do if CurrentUser.user.__send__("is_#{level}?") diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 37af29878..bc69f0274 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -17,7 +17,6 @@ <%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %> <%= stylesheet_link_tag "application", :media => "screen" %> - <%#= stylesheet_link_tag "mobile", :media => "only screen and (max-device-width:480px)" %> <%= javascript_include_tag "application" %> <%= Danbooru.config.custom_html_header_content %> <%= yield :html_header %> @@ -36,6 +35,14 @@
+ <% if CurrentUser.is_anonymous? && session[:started_at] && session[:started_at] < 1.minute.ago && cookies[:hide_sign_up_notice].blank? %> + <%= render "users/sign_up_notice" %> + <% end %> + + <% if !CurrentUser.is_anonymous? && !CurrentUser.is_privileged? && cookies[:hide_upgrade_account_notice].blank? && params[:action] != "upgrade_information" %> + <%= render "users/upgrade_notice" %> + <% end %> + <%- if flash[:notice] -%>
<%= flash[:notice] %>
<%- else -%> diff --git a/app/views/users/_secondary_links.html.erb b/app/views/users/_secondary_links.html.erb index ff7ead9ca..5b47a5d97 100644 --- a/app/views/users/_secondary_links.html.erb +++ b/app/views/users/_secondary_links.html.erb @@ -1,6 +1,9 @@ <% content_for(:secondary_links) do %>
  • <%= link_to "Listing", users_path %>
  • + <% if CurrentUser.is_anonymous? %> +
  • <%= link_to "Sign up", new_user_path %>
  • + <% end %> <% if @user && !CurrentUser.is_anonymous? %>
  • |
  • <% if @user.id == CurrentUser.id %> @@ -10,6 +13,9 @@ <% else %>
  • <%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %>
  • <% end %> + <% if !CurrentUser.is_privileged? %> +
  • <%= link_to "Upgrade", upgrade_information_users_path %>
  • + <% end %>
  • |
  • <%= link_to "Sign out", session_path, :method => :delete %>
  • <% end %> diff --git a/app/views/users/_sign_up_notice.html.erb b/app/views/users/_sign_up_notice.html.erb new file mode 100644 index 000000000..da6abbd11 --- /dev/null +++ b/app/views/users/_sign_up_notice.html.erb @@ -0,0 +1,4 @@ +
    +

    Like the site? <%= link_to "Sign up for a free basic account!", new_user_path %>

    +

    <%= link_to "No thanks", "#", :id => "hide-sign-up-notice" %>

    +
    diff --git a/app/views/users/_upgrade_notice.html.erb b/app/views/users/_upgrade_notice.html.erb new file mode 100644 index 000000000..cabb96a41 --- /dev/null +++ b/app/views/users/_upgrade_notice.html.erb @@ -0,0 +1,4 @@ +
    +

    <%= link_to "Upgrade your account for only $10!", upgrade_information_users_path %>

    +

    <%= link_to "No thanks", "#", :id => "hide-upgrade-account-notice" %>

    +
    diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 781e4109a..8bb5317e5 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,80 +1,23 @@
    -

    Sign up

    +

    Sign Up

    - <% if @user.errors.empty? %> -
    -

    <%= Danbooru.config.app_name %> is ad-sponsored and does not require an account to view. But in order to start uploading, editing, or creating content on this site, you will need to register. Make sure you read and agree to the <%= link_to "terms of service", terms_of_service_path %> before registering. This site is open to web crawlers, therefore any name you choose will be public!

    - -

    Registration for a basic account is free but comes with some limitations.

    - -
    -
    -

    Basic

    -
      -
    • Free
    • -
    • Uploads limited
    • -
    • Search up to 2 tags at once
    • -
    • Some hidden posts
    • -
    • Ads visible
    • -
    • Create and edit posts, favorites, forum posts, comments, wiki pages, pools, artists, and dmails
    • -
    -
    - -
    -

    Privileged

    -
      -
    • One time $20 fee
    • -
    • Uploads limited
    • -
    • Search up to 6 tags at once
    • -
    • No hidden posts
    • -
    • No ads
    • -
    • Tag subscriptions
    • -
    -
    - -
    -

    Contributor

    -
      -
    • Invitation only
    • -
    • No upload limits
    • -
    -
    - -
    -
    -
    - -
    -

    There are some restrictions on names:

    - -
      -
    • Name: Your name must be at least 2 characters and at most 20 characters long. It cannot contain spaces or colons. All characters must be US-ASCII.
    • -
    • Password: Your password must be at least 5 characters long.
    • -
    • - Email: - <% if Danbooru.config.enable_email_verification? %> - You must enter a valid email address. You will need to verify your email address after registering. - <% else %> - You can optionally enter an email address. Although optional, you will not be able to reset your password without an email address. - <% end %> -
    • -
    -
    - <% end %> +

    A basic account is free and lets you keep favorites, upload artwork, and write comments. If you want <%= link_to "more features", wiki_pages_path(:title => "help:accounts") %> you can upgrade your account later.

    <%= simple_form_for(@user) do |f| %> <%= f.input :name, :as => :string %> + <%= f.input :email, :required => false, :as => :email %> <%= f.input :password %> <%= f.input :password_confirmation %> - <%= f.input :email, :required => false, :as => :email %> - <%= f.button :submit %> + <%= f.button :submit, "Sign up" %> <% end %>
    +<%= render "secondary_links" %> + <% content_for(:page_title) do %> Sign up - <%= Danbooru.config.app_name %> <% end %> diff --git a/app/views/users/upgrade_information.html.erb b/app/views/users/upgrade_information.html.erb new file mode 100644 index 000000000..021d2154d --- /dev/null +++ b/app/views/users/upgrade_information.html.erb @@ -0,0 +1,50 @@ +
    +
    +

    Upgrade Account

    + +

    Annoyed by ads? Want more searching power? Upgrade your account for only $10 and become a power user of the best database of anime artwork on the internet.

    + +
    +
    +

    Basic

    +
      +
    • Free
    • +
    • Ad supported
    • +
    • Search 2 tags at a time
    • +
    +
    + +
    +

    Privileged

    +
      +
    • One time $10 fee
    • +
    • No ads
    • +
    • Search 8 tags at a time
    • +
    • Subscribe to tags
    • +
    • Warm fuzzy feeling
    • +
    +
    + +
    +

    Contributor

    +
      +
    • Invite only
    • +
    • Unlimited uploads
    • +
    +
    +
    + +

    Just provide your email address and details for upgrading your account will be sent to you. If you have any further questions or concerns, feel free to contact me at <%= mail_to Danbooru.config.contact_email, nil, :encode => :javascript %>.

    + + <%= form_tag(upgrade_user_path(CurrentUser.user)) do %> + <%= email_field_tag :email, CurrentUser.email %> + <%= submit_tag "Upgrade" %> + <% end %> +
    +
    + +<%= render "secondary_links" %> + +<% content_for(:page_title) do %> + Upgrade - <%= Danbooru.config.app_name %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index f69848b73..85579bb0a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -151,7 +151,15 @@ Danbooru::Application.routes.draw do end end resources :uploads - resources :users + resources :users do + collection do + get :upgrade_information + end + + member do + post :upgrade + end + end resources :user_feedbacks resources :wiki_pages do member do