Onboarding for new libraries and new users

This commit is contained in:
Jared Turner 2020-06-07 18:40:31 +01:00
parent aaf0a3c6af
commit fa85d9834f
2 changed files with 123 additions and 78 deletions

View File

@ -69,6 +69,13 @@ class MainRouter < Router
continue_reading = @context.library.get_continue_reading_entries username
recently_added = @context.library.get_recently_added_entries username
new_user = true
titles = @context.library.titles
titles.each { |t| new_user = false if t.load_percentage(username) > 0 }
empty_library = true
empty_library = false if titles.size > 0
layout "home"
rescue e
@context.error e

View File

@ -1,6 +1,42 @@
<%- unless continue_reading.empty? -%>
<h2 class="uk-title home-headings">Continue Reading</h2>
<div id="item-container-continue" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
<%- if new_user && empty_library -%>
<div class="uk-container uk-text-center">
<i class="fas fa-plus" style="font-size: 80px;"></i>
<h2>Add your first manga</h2>
<p style="margin-bottom: 40px;">We can't find any files yet. Add some to your library and they'll appear here.</p>
<dl class="uk-description-list">
<dt style="font-weight: 500;">Current library path</dt>
<dd><code><%= @context.config.library_path %></code></dd>
<dt style="font-weight: 500;">Want to change your library path?</dt>
<dd>Update <code>config.yml</code> located at: <code>/can/I/access/config_path/from/view?</code></dd>
<dt style="font-weight: 500;">Can't see your files yet?</dt>
<dd>You must wait <%= @context.config.scan_interval %> minutes for the library scan to complete, or restart Mango.</dd>
</dl>
</div>
<%- elsif new_user && empty_library == false -%>
<div class="uk-container uk-text-center">
<i class="fas fa-book-open" style="font-size: 80px;"></i>
<h2>Read your first manga</h2>
<p>Once you start reading, Mango will remember where you left off
and show your entries here.</p>
<a href="/library" class="uk-button uk-button-default">View library</a>
</div>
<%- elsif new_user == false && empty_library == false -%>
<%- if continue_reading.empty? && recently_added.empty? -%>
<div class="uk-container uk-text-center">
<img src="/img/banner.png" style="max-width: 400px; padding: 0 20px;">
<p>A self-hosted manga server and reader</p>
<a href="/library" class="uk-button uk-button-default">View library</a>
</div>
<%- end -%>
<%- unless continue_reading.empty? -%>
<h2 class="uk-title home-headings">Continue Reading</h2>
<div id="item-container-continue" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
<%- continue_reading.each do |cr| -%>
<div class="item" data-mtime="<%= cr[:entry].mtime.to_unix %>" data-progress="<%= cr[:percentage] %>" id="<%= cr[:entry].id %>">
<a class="acard">
@ -17,12 +53,12 @@
</a>
</div>
<%- end -%>
</div>
<%- end -%>
</div>
<%- end -%>
<%- unless recently_added.empty? -%>
<h2 class="uk-title home-headings">Recently Added</h2>
<div id="item-container-continue" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
<%- unless recently_added.empty? -%>
<h2 class="uk-title home-headings">Recently Added</h2>
<div id="item-container-continue" class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
<%- recently_added.each do |ra| -%>
<%- if ra[:grouped_count] == 1 -%>
<div class="item" data-progress="<%= ra[:percentage] %>" id="<%= ra[:entry].id %>">
@ -55,11 +91,11 @@
</div>
<%- end -%>
<%- end -%>
</div>
<%- end -%>
</div>
<%- end -%>
<!-- TODO: DRY this code with calls in other ecr files? eg. title.ecr -->
<div id="modal" class="uk-flex-top" uk-modal>
<!-- TODO: DRY this code with calls in other ecr files? eg. title.ecr -->
<div id="modal" class="uk-flex-top" uk-modal>
<div class="uk-modal-dialog uk-margin-auto-vertical">
<button class="uk-modal-close-default" type="button" uk-close></button>
<div class="uk-modal-header">
@ -83,7 +119,9 @@
</p>
</div>
</div>
</div>
</div>
<%- end -%>
<% content_for "script" do %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.dotdotdot/4.0.11/dotdotdot.js"></script>