woople-theme 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +20 -0
  3. data/Rakefile +37 -0
  4. data/app/assets/images/woople-theme/certification/missing.png +0 -0
  5. data/app/assets/images/woople-theme/certification/red-icon.png +0 -0
  6. data/app/assets/images/woople-theme/certification/red-icon2x.png +0 -0
  7. data/app/assets/images/woople-theme/completed-triangle.png +0 -0
  8. data/app/assets/images/woople-theme/completed-triangle2x.png +0 -0
  9. data/app/assets/images/woople-theme/icons/menu.png +0 -0
  10. data/app/assets/images/woople-theme/icons/menu2x.png +0 -0
  11. data/app/assets/images/woople-theme/icons/search.png +0 -0
  12. data/app/assets/images/woople-theme/icons/search2x.png +0 -0
  13. data/app/assets/images/woople-theme/icons/sortASC.png +0 -0
  14. data/app/assets/images/woople-theme/icons/sortASC2x.png +0 -0
  15. data/app/assets/images/woople-theme/icons/sortDESC.png +0 -0
  16. data/app/assets/images/woople-theme/icons/sortDESC2x.png +0 -0
  17. data/app/assets/images/woople-theme/icons/thumbs_down.png +0 -0
  18. data/app/assets/images/woople-theme/icons/thumbs_down2x.png +0 -0
  19. data/app/assets/images/woople-theme/icons/thumbs_up.png +0 -0
  20. data/app/assets/images/woople-theme/icons/thumbs_up2x.png +0 -0
  21. data/app/assets/images/woople-theme/logo.png +0 -0
  22. data/app/assets/images/woople-theme/missing-profile.png +0 -0
  23. data/app/assets/images/woople-theme/missing.png +0 -0
  24. data/app/assets/images/woople-theme/rails.png +0 -0
  25. data/app/assets/images/woople-theme/star-icon.png +0 -0
  26. data/app/assets/images/woople-theme/star-icon2x.png +0 -0
  27. data/app/assets/javascripts/woople-theme/theme.js +39 -0
  28. data/app/assets/stylesheets/woople-theme/base.css.less +101 -0
  29. data/app/assets/stylesheets/woople-theme/buttons.css.less +38 -0
  30. data/app/assets/stylesheets/woople-theme/colours.css.less +29 -0
  31. data/app/assets/stylesheets/woople-theme/content-item.css.less +157 -0
  32. data/app/assets/stylesheets/woople-theme/content.css.less +38 -0
  33. data/app/assets/stylesheets/woople-theme/course.css.less +47 -0
  34. data/app/assets/stylesheets/woople-theme/framework.css +5 -0
  35. data/app/assets/stylesheets/woople-theme/framework/index.css.less +8 -0
  36. data/app/assets/stylesheets/woople-theme/framework/responsive.css.less +1 -0
  37. data/app/assets/stylesheets/woople-theme/grid.css.less +38 -0
  38. data/app/assets/stylesheets/woople-theme/index.css.less +20 -0
  39. data/app/assets/stylesheets/woople-theme/legacy.css.less +28 -0
  40. data/app/assets/stylesheets/woople-theme/menu.css.less +132 -0
  41. data/app/assets/stylesheets/woople-theme/modal.css.less +56 -0
  42. data/app/assets/stylesheets/woople-theme/outline.css.less +117 -0
  43. data/app/assets/stylesheets/woople-theme/page-header.css.less +48 -0
  44. data/app/assets/stylesheets/woople-theme/pagination.css.less +31 -0
  45. data/app/assets/stylesheets/woople-theme/profile.css.less +120 -0
  46. data/app/assets/stylesheets/woople-theme/responsive.css.less +1 -0
  47. data/app/assets/stylesheets/woople-theme/theme-retina.css +44 -0
  48. data/app/assets/stylesheets/woople-theme/theme.css +8 -0
  49. data/app/assets/stylesheets/woople-theme/variables.css.less +68 -0
  50. data/app/helpers/javascript_helper.rb +5 -0
  51. data/app/helpers/theme_helper.rb +36 -0
  52. data/app/presenters/content_image.rb +7 -0
  53. data/app/presenters/content_item_presenter.rb +14 -0
  54. data/app/presenters/menu_link_presenter.rb +52 -0
  55. data/app/presenters/menu_presenter.rb +7 -0
  56. data/app/presenters/menu_section_presenter.rb +19 -0
  57. data/app/presenters/outline_download_presenter.rb +7 -0
  58. data/app/presenters/outline_presenter.rb +43 -0
  59. data/app/presenters/outline_video_presenter.rb +45 -0
  60. data/app/presenters/page_header_presenter.rb +6 -0
  61. data/app/presenters/profile_presenter.rb +9 -0
  62. data/app/presenters/theme_presentation.rb +51 -0
  63. data/app/views/layouts/theme.html.erb +43 -0
  64. data/app/views/woople-theme/_content_item.html.erb +28 -0
  65. data/app/views/woople-theme/_content_item_header.html.erb +7 -0
  66. data/app/views/woople-theme/_menu.html.erb +15 -0
  67. data/app/views/woople-theme/_outline.html.erb +19 -0
  68. data/app/views/woople-theme/_outline_download.html.erb +6 -0
  69. data/app/views/woople-theme/_outline_video.html.erb +13 -0
  70. data/app/views/woople-theme/_page_header.html.erb +8 -0
  71. data/app/views/woople-theme/_profile.html.erb +20 -0
  72. data/app/views/woople-theme/_video_modal.html.erb +20 -0
  73. data/config/locales/en.yml +18 -0
  74. data/config/routes.rb +2 -0
  75. data/lib/tasks/woople-theme_tasks.rake +4 -0
  76. data/lib/woople-theme.rb +5 -0
  77. data/lib/woople-theme/configuration.rb +23 -0
  78. data/lib/woople-theme/engine.rb +14 -0
  79. data/lib/woople-theme/version.rb +3 -0
  80. metadata +196 -0
@@ -0,0 +1,7 @@
1
+ require 'delegate'
2
+
3
+ class MenuPresenter < SimpleDelegator
4
+ def initialize(menu)
5
+ super(ThemePresentation.wrap_collection(menu, MenuSectionPresenter))
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ require 'delegate'
2
+
3
+ class MenuSectionPresenter < SimpleDelegator
4
+ def name
5
+ yield(section.name) if section.respond_to? :name
6
+ end
7
+
8
+ def links
9
+ @links ||= ThemePresentation.wrap_collection(section.links, MenuLinkPresenter)
10
+ end
11
+
12
+ private
13
+
14
+ def section
15
+ __getobj__
16
+ end
17
+
18
+ end
19
+
@@ -0,0 +1,7 @@
1
+ require 'delegate'
2
+
3
+ class OutlineDownloadPresenter < SimpleDelegator
4
+ def css_class
5
+ "disabled" if !__getobj__.enabled
6
+ end
7
+ end
@@ -0,0 +1,43 @@
1
+ require 'delegate'
2
+
3
+ class OutlinePresenter < SimpleDelegator
4
+ def assessment
5
+ css_class = "assessment"
6
+ css_class << " disabled" if assessment_disabled?
7
+
8
+ yield(css_class) if has_assessment?
9
+ end
10
+
11
+ def render_downloads(view_context)
12
+ wrapped_downloads = ThemePresentation.wrap_collection(downloads, OutlineDownloadPresenter)
13
+ view_context.render partial: 'woople-theme/outline_download', collection: wrapped_downloads
14
+ end
15
+
16
+ def render_videos(view_context)
17
+ wrapped_videos = ThemePresentation.wrap_collection(videos, OutlineVideoPresenter)
18
+ view_context.render partial: 'woople-theme/outline_video', collection: wrapped_videos
19
+ end
20
+
21
+ private
22
+
23
+ def downloads
24
+ outline.downloads
25
+ end
26
+
27
+ def videos
28
+ outline.videos
29
+ end
30
+
31
+ def assessment_disabled?
32
+ outline.respond_to?(:assessment_enabled?) && !outline.assessment_enabled?
33
+ end
34
+
35
+ def has_assessment?
36
+ outline.respond_to?(:assessment) && outline.assessment
37
+ end
38
+
39
+ def outline
40
+ __getobj__
41
+ end
42
+
43
+ end
@@ -0,0 +1,45 @@
1
+ require 'delegate'
2
+
3
+ class OutlineVideoPresenter < SimpleDelegator
4
+ def css_class
5
+ css_classes = []
6
+ css_classes << "disabled" if !video.enabled
7
+ css_classes << "completed" if video.completed
8
+
9
+ css_classes.join(" ")
10
+ end
11
+
12
+ def slug
13
+ "video_#{video.id}"
14
+ end
15
+
16
+ def duration
17
+ minutes = (video.duration.to_f / 1000.0 / 60.0).floor
18
+ remainder = (video.duration - (minutes * 60 * 1000))
19
+ seconds = (remainder.to_f / 1000.0).floor
20
+
21
+ if seconds <= 9
22
+ seconds = "0#{seconds}"
23
+ end
24
+
25
+ "#{minutes}:#{seconds}"
26
+ end
27
+
28
+ def completed
29
+ yield if video.completed
30
+ end
31
+
32
+ def url
33
+ if video.enabled
34
+ video.url
35
+ else
36
+ "#"
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def video
43
+ __getobj__
44
+ end
45
+ end
@@ -0,0 +1,6 @@
1
+ require 'delegate'
2
+ require_relative 'content_image'
3
+
4
+ class PageHeaderPresenter < SimpleDelegator
5
+ include ContentImage
6
+ end
@@ -0,0 +1,9 @@
1
+ require 'delegate'
2
+
3
+ class ProfilePresenter < SimpleDelegator
4
+ def each(*)
5
+ super do |e|
6
+ yield ThemePresentation.wrap(e, ProfilePresenter)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,51 @@
1
+ require 'ostruct'
2
+
3
+ class ThemePresentation
4
+ def self.wrap(data, *presenters)
5
+ normalized = normalize(data)
6
+ presenters = normalize_presenters(presenters)
7
+
8
+ wrapped_data = presenters.inject(normalized) do |wrapped, presenter|
9
+ presenter.new(wrapped)
10
+ end
11
+
12
+ class << wrapped_data
13
+ attr_accessor :wrapped_by
14
+ end
15
+
16
+ wrapped_data.wrapped_by = presenters
17
+
18
+ wrapped_data
19
+ end
20
+
21
+ def self.wrap_collection(collection, *presenters)
22
+ collection.collect { |item| wrap(item, *presenters) }
23
+ end
24
+
25
+ private
26
+
27
+ def self.normalize(data)
28
+ if data.is_a? Hash
29
+ OpenStruct.new(data)
30
+ else
31
+ data
32
+ end
33
+ end
34
+
35
+ def self.normalize_presenters(presenters)
36
+ presenters.reject!(&:nil?)
37
+ add_class_delegation(presenters)
38
+
39
+ presenters
40
+ end
41
+
42
+ def self.add_class_delegation(presenters)
43
+ presenters.each do |presenter|
44
+ presenter.class_eval do
45
+ def class
46
+ __getobj__.class
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Woople</title>
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta name="apple-mobile-web-app-capable" content="yes" />
7
+
8
+ <%= stylesheet_link_tag "woople-theme/theme", :media => "all" %>
9
+ <%= stylesheet_link_tag "woople-theme/theme-retina", media: 'only screen and (-webkit-min-device-pixel-ratio: 2)' %>
10
+ <%= javascript_include_tag "woople-theme/theme" %>
11
+ <%= application_javascript %>
12
+ <%= csrf_meta_tags %>
13
+
14
+ <script>
15
+ <%= 'var showingPlayer = true;' if @video.present? %>
16
+ </script>
17
+
18
+ </head>
19
+ <body>
20
+ <%= yield :body_content %>
21
+
22
+ <div class="container" id="navigation">
23
+ <div class="row">
24
+ <a href="#" class="close-navigation close">&times;</a>
25
+ <a href="#navigation" class="navigation"><i class="icon-th-list"></i></a>
26
+
27
+ <div id="masthead" class="span12">
28
+ <%= image_tag('woople-theme/logo.png', class: 'masthead-logo') %>
29
+ <%= profile %>
30
+ </div>
31
+
32
+ <%= menu %>
33
+
34
+ <div class="outer-content span9">
35
+ <div class="content">
36
+ <%= yield %>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <p class="copyright"><a href="<%t 'woople_theme.company.url' %>"><%=t 'woople_theme.company.name' %></a> &copy; <%= DateTime.now.strftime("%Y") %></p>
41
+ </div>
42
+ </body>
43
+ </html>
@@ -0,0 +1,28 @@
1
+ <div class="content-item row <%= content_item.completed %>">
2
+ <div class="content-item-image span1">
3
+ <a href="/course">
4
+ <% content_item.image do |url| %>
5
+ <%= image_tag(url) %>
6
+ <% end %>
7
+ </a>
8
+ </div>
9
+ <div class="content-item-content span7">
10
+ <h2><a href="/course"><%= content_item.name %></a></h2>
11
+
12
+ <div class="content-item-metadata row">
13
+ <div class="span2">
14
+ <em class="timeRemaining"><%= content_item.time_remaining %></em> / <%= content_item.time_total %>
15
+ </div>
16
+ <div class="span2">
17
+ <i class="icon-star"></i> <span class="popularity"><%= content_item.popularity %></span>
18
+ </div>
19
+
20
+ <% content_item.certification_metadata do |data| %>
21
+ <div class="span2">
22
+ <span class="badge certificationValue"><%= data %></span>
23
+ </div>
24
+ <% end %>
25
+ </div>
26
+ </div>
27
+ <div class="content-item-progress-bar" style="width:<%= content_item.percent_complete %>%"></div>
28
+ </div>
@@ -0,0 +1,7 @@
1
+ <% #NOTE: Only one sort should be possible at the same time. These need to sort server side due to pagination %>
2
+ <div class="content-item-header row">
3
+ <div class="span1">&nbsp;</div>
4
+ <div class="span2"><a href="#" class="sortAsc"><%=t 'woople_theme.content_item_header.time_left' %> <i class="icon-chevron-up"></i><i class="icon-chevron-down"></i> </a></div>
5
+ <div class="span2"><a href="#" class="sortDesc"><%=t 'woople_theme.content_item_header.popularity' %> <i class="icon-chevron-up"></i><i class="icon-chevron-down"></i></a></div>
6
+ <div class="span2"><a href="#"><%=t 'woople_theme.content_item_header.points' %> <i class="icon-chevron-up"></i><i class="icon-chevron-down"></i></a></div>
7
+ </div>
@@ -0,0 +1,15 @@
1
+ <div class="menu span3">
2
+ <div class="menu-content">
3
+ <ul class="nav nav-list">
4
+ <% menu.each do |section| %>
5
+ <% section.name do |name| %>
6
+ <li class="nav-header"><%= name %></li>
7
+ <% end %>
8
+ <% section.links.each do |link| %>
9
+ <li class="<%= link.css_class %>"><a href="<%= link.url %>"><%= link.featured_tag(link.name + link.badge + link.certification_badge) %></a></li>
10
+ <% end %>
11
+ <% end %>
12
+ </ul>
13
+ </div>
14
+ </div>
15
+
@@ -0,0 +1,19 @@
1
+ <div class="outline">
2
+ <h2><%= outline.name %></h2>
3
+ <table class="table">
4
+ <thead>
5
+ <tr>
6
+ <th></th>
7
+ <th class="string"><%=t 'woople_theme.outline.name' %></th>
8
+ <th class="count"><%=t 'woople_theme.outline.duration' %></th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <%= outline.render_downloads(self) %>
13
+ <%= outline.render_videos(self) %>
14
+ </tbody>
15
+ </table>
16
+ <% outline.assessment do |assessment_class| %>
17
+ <p class="<%= assessment_class %>"><a><%=t 'woople_theme.outline.start_assessment' %></a></p>
18
+ <% end %>
19
+ </div>
@@ -0,0 +1,6 @@
1
+ <tr class="<%= outline_download.css_class %>">
2
+ <td><a class="action btn btn-primary" href="#"><i class="icon-white icon-download-alt"></i></a></td>
3
+ <td><a href="#"><%= outline_download.name %></a></td>
4
+ <td></td>
5
+ </tr>
6
+
@@ -0,0 +1,13 @@
1
+ <tr id="<%= outline_video.slug %>" class="<%= outline_video.css_class %>">
2
+ <td>
3
+ <a class="action btn btn-primary" href="<%= outline_video.url %>">
4
+ <i class="icon-white icon-play">
5
+ </i></a>
6
+ <% outline_video.completed do %>
7
+
8
+ <% end %>
9
+ </td>
10
+ <td><a href="<%= outline_video.url %>" class="video_link"><%= outline_video.name %></a></td>
11
+ <td><%= outline_video.duration %></td>
12
+ </tr>
13
+
@@ -0,0 +1,8 @@
1
+ <header class="page-header">
2
+ <% header.image do |url| %>
3
+ <%= image_tag(url) %>
4
+ <% end %>
5
+
6
+ <h1><%= header.title %></h1>
7
+ <p><%= header.description %></p>
8
+ </header>
@@ -0,0 +1,20 @@
1
+ <div class="profile">
2
+ <form class="search">
3
+ <a href="#" class='search-page'><i class="icon-search"></i></a>
4
+ <input type="text" class="search-query" placeholder="<%=t 'woople_theme.profile.search' %>">
5
+ </form>
6
+ <ul class="nav nav-pills profile-link">
7
+ <li class="dropdown">
8
+ <a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= image_tag('woople-theme/missing-profile.png') %></a>
9
+ <ul id="menu1" class="dropdown-menu">
10
+ <% profile.each do |section| %>
11
+ <% section.each do |link| %>
12
+ <li><a href="<%= link.url %>"><%= link.name %></a></li>
13
+ <% end %>
14
+ <li class="divider"></li>
15
+ <% end %>
16
+ </ul>
17
+ </li>
18
+ </ul>
19
+ </div>
20
+
@@ -0,0 +1,20 @@
1
+ <div id="myModal" class="modal hide">
2
+ <div class="modal-header">
3
+ <a class="close" data-dismiss="modal">×</a>
4
+ <% %>
5
+ <h3><%= video.name %></h3>
6
+ </div>
7
+ <div class="modal-body">
8
+ <div class="modal-video">
9
+ <% #TODO: this only works with youtube urls right now. obviously hack %>
10
+ <iframe src="<%= video.src %>" frameborder="0" allowfullscreen></iframe>
11
+ </div>
12
+ </div>
13
+ <div class="modal-footer">
14
+ <div class="btn-group" data-toggle="buttons-radio">
15
+ <button class="btn btn-primary"><i class="icon-thumbs-up"></i> <%=t 'woople_theme.video_modal.like' %></button>
16
+ <button class="btn btn-primary"><i class="icon-thumbs-down"></i> <%=t 'woople_theme.video_modal.dislike' %></button>
17
+ </div>
18
+ </div>
19
+ </div>
20
+
@@ -0,0 +1,18 @@
1
+ en:
2
+ woople_theme:
3
+ company:
4
+ name: "Woople"
5
+ url: http://woople.com
6
+ content_item_header:
7
+ time_left: Time Left
8
+ popularity: Popularity
9
+ points: Points
10
+ outline:
11
+ name: Name
12
+ duration: Duration
13
+ start_assessment: START ASSESSMENT
14
+ profile:
15
+ search: Search...
16
+ video_modal:
17
+ like: Like
18
+ dislike: Dislike
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :woople-theme do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,5 @@
1
+ require 'woople-theme/engine'
2
+ require 'woople-theme/configuration'
3
+
4
+ module WoopleTheme
5
+ end
@@ -0,0 +1,23 @@
1
+ module WoopleTheme
2
+ class Configuration
3
+ attr_accessor :profile_helper, :menu_helper, :layout_javascript
4
+
5
+ def profile_helper
6
+ @profile_helper || :profile_helper
7
+ end
8
+
9
+ def menu_helper
10
+ @menu_helper || :menu_helper
11
+ end
12
+ end
13
+
14
+ class << self
15
+ attr_accessor :configuration
16
+ end
17
+
18
+ def self.configure
19
+ self.configuration ||= Configuration.new
20
+ yield(configuration)
21
+ end
22
+
23
+ end