mirror of
				https://github.com/iv-org/invidious.git
				synced 2025-11-04 06:08:31 -06:00 
			
		
		
		
	WIP: welcome message on home page (#740)
TODO: final text needs to be determined, then localized.
This commit is contained in:
		
							parent
							
								
									86491da253
								
							
						
					
					
						commit
						325e45582c
					
				@ -36,3 +36,7 @@ body {
 | 
				
			|||||||
  background-color: inherit;
 | 
					  background-color: inherit;
 | 
				
			||||||
  color: inherit;
 | 
					  color: inherit;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.welcome-box {
 | 
				
			||||||
 | 
					  background-image: linear-gradient(45deg, #111, #666);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -137,6 +137,12 @@ img.thumbnail {
 | 
				
			|||||||
  top: -0.7em;
 | 
					  top: -0.7em;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.infobox {
 | 
				
			||||||
 | 
					  border: 1px solid #ccc;
 | 
				
			||||||
 | 
					  border-radius: 5px;
 | 
				
			||||||
 | 
					  padding: 1em ;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Navbar
 | 
					 * Navbar
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -255,6 +261,30 @@ input[type="search"]::-webkit-search-cancel-button {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Welcome Message
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.welcome-outer {
 | 
				
			||||||
 | 
					  margin: 0 1em;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.welcome-box {
 | 
				
			||||||
 | 
					  padding: 0 1em ;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#dismiss_welcome {
 | 
				
			||||||
 | 
					  font-size: small;
 | 
				
			||||||
 | 
					  float: right;
 | 
				
			||||||
 | 
					  margin: 1em 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#call_to_action {
 | 
				
			||||||
 | 
					  overflow: hidden;
 | 
				
			||||||
 | 
					  text-overflow: ellipsis;
 | 
				
			||||||
 | 
					  max-width: 100%;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Footer
 | 
					 * Footer
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
				
			|||||||
@ -14,3 +14,7 @@ a:not([data-id]) > .icon,
 | 
				
			|||||||
.playlist-restricted > ol > li > a {
 | 
					.playlist-restricted > ol > li > a {
 | 
				
			||||||
  color: #303030;
 | 
					  color: #303030;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.welcome-box {
 | 
				
			||||||
 | 
					  background-image: linear-gradient(45deg, #fff, #ccc);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										22
									
								
								assets/js/welcome.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								assets/js/welcome.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					var dismiss_welcome = document.getElementById('dismiss_welcome');
 | 
				
			||||||
 | 
					dismiss_welcome.href = 'javascript:void(0);';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dismiss_welcome.addEventListener('click', function () {
 | 
				
			||||||
 | 
					    var dark_mode = document.getElementById('dark_theme').media === 'none';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    var url = '/dismiss_welcome?redirect=false';
 | 
				
			||||||
 | 
					    var xhr = new XMLHttpRequest();
 | 
				
			||||||
 | 
					    xhr.responseType = 'json';
 | 
				
			||||||
 | 
					    xhr.timeout = 10000;
 | 
				
			||||||
 | 
					    xhr.open('GET', url, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    hide_welcome();
 | 
				
			||||||
 | 
					    window.localStorage.setItem('welcome_dismissed', true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    xhr.send();
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function hide_welcome (bool) {
 | 
				
			||||||
 | 
					    document.getElementById('feed-menu').classList.remove('hidden');
 | 
				
			||||||
 | 
					    document.getElementById('welcome-outer').classList.add('hidden');
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1699,6 +1699,42 @@ get "/toggle_theme" do |env|
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					get "/dismiss_welcome" do |env|
 | 
				
			||||||
 | 
					  locale = LOCALES[env.get("preferences").as(Preferences).locale]?
 | 
				
			||||||
 | 
					  referer = get_referer(env, unroll: false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  redirect = env.params.query["redirect"]?
 | 
				
			||||||
 | 
					  redirect ||= "true"
 | 
				
			||||||
 | 
					  redirect = redirect == "true"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  preferences = env.get("preferences").as(Preferences)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  preferences.welcome_dismissed = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  preferences = preferences.to_json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if Kemal.config.ssl || config.https_only
 | 
				
			||||||
 | 
					    secure = true
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    secure = false
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if config.domain
 | 
				
			||||||
 | 
					    env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", domain: "#{config.domain}", value: preferences, expires: Time.utc + 2.years,
 | 
				
			||||||
 | 
					      secure: secure, http_only: true)
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    env.response.cookies["PREFS"] = HTTP::Cookie.new(name: "PREFS", value: preferences, expires: Time.utc + 2.years,
 | 
				
			||||||
 | 
					      secure: secure, http_only: true)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if redirect
 | 
				
			||||||
 | 
					    env.redirect referer
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    env.response.content_type = "application/json"
 | 
				
			||||||
 | 
					    "{}"
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
post "/watch_ajax" do |env|
 | 
					post "/watch_ajax" do |env|
 | 
				
			||||||
  locale = LOCALES[env.get("preferences").as(Preferences).locale]?
 | 
					  locale = LOCALES[env.get("preferences").as(Preferences).locale]?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -151,6 +151,7 @@ struct ConfigPreferences
 | 
				
			|||||||
    unseen_only:            {type: Bool, default: false},
 | 
					    unseen_only:            {type: Bool, default: false},
 | 
				
			||||||
    video_loop:             {type: Bool, default: false},
 | 
					    video_loop:             {type: Bool, default: false},
 | 
				
			||||||
    volume:                 {type: Int32, default: 100},
 | 
					    volume:                 {type: Int32, default: 100},
 | 
				
			||||||
 | 
					    welcome_dismissed:      {type: Bool, default: false},
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -215,7 +216,7 @@ struct Config
 | 
				
			|||||||
    hmac_key:                 String?,                              # HMAC signing key for CSRF tokens and verifying pubsub subscriptions
 | 
					    hmac_key:                 String?,                              # HMAC signing key for CSRF tokens and verifying pubsub subscriptions
 | 
				
			||||||
    domain:                   String?,                              # Domain to be used for links to resources on the site where an absolute URL is required
 | 
					    domain:                   String?,                              # Domain to be used for links to resources on the site where an absolute URL is required
 | 
				
			||||||
    use_pubsub_feeds:         {type: Bool | Int32, default: false}, # Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
 | 
					    use_pubsub_feeds:         {type: Bool | Int32, default: false}, # Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
 | 
				
			||||||
    default_home:             {type: String, default: "Top"},
 | 
					    default_home:             {type: String, default: "Popular"},
 | 
				
			||||||
    feed_menu:                {type: Array(String), default: ["Popular", "Top", "Trending", "Subscriptions"]},
 | 
					    feed_menu:                {type: Array(String), default: ["Popular", "Top", "Trending", "Subscriptions"]},
 | 
				
			||||||
    top_enabled:              {type: Bool, default: true},
 | 
					    top_enabled:              {type: Bool, default: true},
 | 
				
			||||||
    captcha_enabled:          {type: Bool, default: true},
 | 
					    captcha_enabled:          {type: Bool, default: true},
 | 
				
			||||||
 | 
				
			|||||||
@ -92,6 +92,7 @@ struct Preferences
 | 
				
			|||||||
    unseen_only:            {type: Bool, default: CONFIG.default_user_preferences.unseen_only},
 | 
					    unseen_only:            {type: Bool, default: CONFIG.default_user_preferences.unseen_only},
 | 
				
			||||||
    video_loop:             {type: Bool, default: CONFIG.default_user_preferences.video_loop},
 | 
					    video_loop:             {type: Bool, default: CONFIG.default_user_preferences.video_loop},
 | 
				
			||||||
    volume:                 {type: Int32, default: CONFIG.default_user_preferences.volume},
 | 
					    volume:                 {type: Int32, default: CONFIG.default_user_preferences.volume},
 | 
				
			||||||
 | 
					    welcome_dismissed:      {type: Bool, default: CONFIG.default_user_preferences.welcome_dismissed},
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,8 @@
 | 
				
			|||||||
<div class="h-box pure-g">
 | 
					<% if !(env.get? "user") && !env.get("preferences").as(Preferences).welcome_dismissed %>
 | 
				
			||||||
 | 
					    <div id="feed-menu" class="h-box pure-g hidden">
 | 
				
			||||||
 | 
					<% else %>
 | 
				
			||||||
 | 
					    <div id="feed-menu" class="h-box pure-g">
 | 
				
			||||||
 | 
					<% end %>
 | 
				
			||||||
    <div class="pure-u-1 pure-u-md-1-4"></div>
 | 
					    <div class="pure-u-1 pure-u-md-1-4"></div>
 | 
				
			||||||
    <div class="pure-u-1 pure-u-md-1-2">
 | 
					    <div class="pure-u-1 pure-u-md-1-2">
 | 
				
			||||||
        <div class="pure-g">
 | 
					        <div class="pure-g">
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								src/invidious/views/components/welcome_message.ecr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/invidious/views/components/welcome_message.ecr
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					<div class="welcome-outer" id="welcome-outer">
 | 
				
			||||||
 | 
					    <div class="infobox welcome-box">
 | 
				
			||||||
 | 
					        <a id="dismiss_welcome" class="pure-button" href="/dismiss_welcome?referer=<%= env.get?("current_page") %>">dismiss</a>
 | 
				
			||||||
 | 
					        <h1>Welcome to Invidious</h1>
 | 
				
			||||||
 | 
					        <p>Invidious is a community developed Youtube-player, that respects your privacy. Features include:
 | 
				
			||||||
 | 
					        <ul>
 | 
				
			||||||
 | 
					            <li>Ad-free
 | 
				
			||||||
 | 
					            <li>Audio-only mode
 | 
				
			||||||
 | 
					            <li>Works without Javascript
 | 
				
			||||||
 | 
					            <li>No Google account required
 | 
				
			||||||
 | 
					            <li>Download video, audio and subtitles
 | 
				
			||||||
 | 
					            <li><a href="https://github.com/omarroth/invidious/blob/master/README.md">and many more!</a>
 | 
				
			||||||
 | 
					        </ul>
 | 
				
			||||||
 | 
					        <p><a href="/login?referer=%2Fdata_control" class="pure-button pure-button-primary" id="call_to_action">create an account and import your subscriptions now</a>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div class="pure-u-1 pure-u-md-1-4"></div>
 | 
				
			||||||
 | 
					    <p>Here is a selection of videos that our community is interested in:
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
@ -9,6 +9,9 @@
 | 
				
			|||||||
</title>
 | 
					</title>
 | 
				
			||||||
<% end %>
 | 
					<% end %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<% if !(env.get? "user") && !env.get("preferences").as(Preferences).welcome_dismissed %>
 | 
				
			||||||
 | 
					    <%= rendered "components/welcome_message" %>
 | 
				
			||||||
 | 
					<% end %>
 | 
				
			||||||
<%= rendered "components/feed_menu" %>
 | 
					<%= rendered "components/feed_menu" %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="pure-g">
 | 
					<div class="pure-g">
 | 
				
			||||||
 | 
				
			|||||||
@ -161,6 +161,8 @@
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        </script>
 | 
					        </script>
 | 
				
			||||||
        <script src="/js/notifications.js?v=<%= ASSET_COMMIT %>"></script>
 | 
					        <script src="/js/notifications.js?v=<%= ASSET_COMMIT %>"></script>
 | 
				
			||||||
 | 
					    <% else %>
 | 
				
			||||||
 | 
					        <script src="/js/welcome.js?v=<%= ASSET_COMMIT %>"></script>
 | 
				
			||||||
    <% end %>
 | 
					    <% end %>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user