Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cimav/somos
base: 97bf3fbe49
...
head fork: cimav/somos
compare: 7da9c5dbc5
  • 8 commits
  • 12 files changed
  • 0 commit comments
  • 1 contributor
View
89 app/assets/javascripts/home.js.coffee
@@ -2,6 +2,7 @@ currentGroup = 0
currentPost = 0
currentUser = 0
postContentHeight = 0
+hash = false
$('#nav-title-span').live('click', (e) ->
$('#groups-area').toggle()
@@ -190,31 +191,36 @@ $('#new-posts-message')
$('.get-group')
.live('ajax:success', (data, status, xhr) ->
- window.location.hash = '#!/g/' + $(this).attr('short_name')
- $("#li_group_#{currentGroup}").removeClass('selected')
- currentGroup = $(this).attr('group_id')
+ setHash('#!/g/' + $(this).attr('short_name'))
$('#container').html(status);
- $("#li_group_#{currentGroup}").addClass('selected')
- title = $("#group_link_#{currentGroup}").html()
- $('#nav-title-span').html(title)
- $('#nav-title-span').removeClass('font-20')
- $('#nav-title-span').removeClass('font-22')
- if (title.length > 20)
- $('#nav-title-span').addClass('font-16')
- else
- $('#nav-title-span').addClass('font-22')
- getPosts()
- getGroupBrick(currentGroup)
+ afterGetGroup($(this).attr('group_id'))
)
+@afterGetGroup = afterGetGroup = (g) ->
+ $("#li_group_#{currentGroup}").removeClass('selected')
+ currentGroup = g
+ $("#li_group_#{currentGroup}").addClass('selected')
+ title = $("#group_link_#{currentGroup}").html()
+ $('#nav-title-span').html(title)
+ $('#nav-title-span').removeClass('font-20')
+ $('#nav-title-span').removeClass('font-22')
+ if (title.length > 20)
+ $('#nav-title-span').addClass('font-16')
+ else
+ $('#nav-title-span').addClass('font-22')
+ getPosts()
+
$('.get-page')
.live('ajax:success', (data, status, xhr) ->
- window.location.hash = '#!/g/' + $(this).attr('group_name') + '/' + $(this).attr('short_name')
- $('.page-title').removeClass('selected')
+ setHash('#!/g/' + $(this).attr('group_name') + '/' + $(this).attr('short_name'))
$('#posts-area').html(status);
- $('#li_page_' + $(this).attr('page_id')).addClass('selected')
+ afterGetPage($(this).attr('page_id'))
)
+@afterGetPage = afterGetPage = (p) ->
+ $('.page-title').removeClass('selected')
+ $('#li_page_' + p).addClass('selected')
+
$('#add_page')
.live("ajax:beforeSend", (evt, xhr, settings) ->
# TODO: Display spinner
@@ -237,19 +243,6 @@ $('#add_page')
# TODO: Display errors
)
-
-
-getGroupBrick = (group) ->
- #$("#right-sidebar-content").html('')
- #url = '/g/' + group + '/members'
- #$.get(url, {}, (html) ->
- # $("#right-sidebar-content").append(html)
- # url = '/g/' + group + '/page_list'
- # $.get(url, {}, (html) ->
- # $("#right-sidebar-content").append(html)
- # )
- #)
-
$('.get-post')
.live('ajax:success', (data, status, xhr) ->
window.location.hash = '#!/p/' + $(this).attr('post_id')
@@ -260,13 +253,16 @@ $('.get-post')
$('.get-user')
.live('ajax:success', (data, status, xhr) ->
username = $(this).attr('username')
- window.location.hash = '#!/' + username
- currentUsername = username
+ setHash('#!/' + username)
$('#container').html(status)
- $container = $('#posts-wide')
- $container.imagesLoaded( () ->
- $container.masonry({ itemSelector: '.post', columnWidth: $('.post').width() + 20 })
- )
+ afterGetUser(username)
+ )
+
+@afterGetUser = afterGetUser = (username) ->
+ currentUsername = username
+ $container = $('#posts-wide')
+ $container.imagesLoaded( () ->
+ $container.masonry({ itemSelector: '.post', columnWidth: $('.post').width() + 20 })
)
$('#get-home')
@@ -308,11 +304,11 @@ populateHome = () ->
getUpcomingBirthdays()
getHome = (reload) ->
- #window.history.pushState('', document.title, window.location.pathname)
currentGroup = 0
currentPost = 0
currentUser = 0
if (reload)
+ window.history.pushState('', document.title, window.location.pathname)
url = '/home/index'
$.get(url, {}, (html) ->
$("#container").html(html)
@@ -321,8 +317,25 @@ getHome = (reload) ->
else
populateHome()
+setHash = (h) ->
+ hash = h
+ window.location.hash = hash
+
+checkHash = () ->
+ if window.location.hash != hash
+ hash = window.location.hash
+ if (hash.slice(0, 2) == '#!')
+ url = hash.slice(2 - hash.length) + '?__from__=url'
+ $.get(url, {}, (html) ->
+ $('#container').html(html)
+ )
+
+
+
$ ->
getGroupList()
- getHome(false)
+ if window.location.hash.slice(0, 2) != '#!'
+ getHome(false)
recentTimer = setInterval(getRecentPostsCounter, 10000)
+hashTimer = setInterval(checkHash, 1000)
View
3  app/assets/stylesheets/groups.css.scss
@@ -110,6 +110,9 @@ ul.page-list {
background: #fff;
float: left;
min-height: 48px;
+ h2 {
+ margin: 20px 0;
+ }
}
#group-page-inner {
View
1  app/controllers/groups_controller.rb
@@ -19,7 +19,6 @@ def page_list
def show
@group = Group.where(:short_name => params[:short_name]).first || not_found
- @members = Membership.where(:group_id => @group.id)
render :layout => false
end
View
4 app/controllers/pages_controller.rb
@@ -12,8 +12,8 @@ def show
end
def show_group_page
- # TODO: Validate group
- @page = Page.find(params[:id])
+ @group = Group.where(:short_name => params[:group_short_name]).first || not_found
+ @page = @group.pages.where(:short_name => params[:page_short_name]).first || not_found
render :layout => false
end
View
1  app/views/groups/_members.html.haml
@@ -1,5 +1,6 @@
.post
#group-members
+ - members = group.memberships
%h3= "#{t :members} (#{members.count})"
- members.each do |member|
%span.member
View
2  app/views/groups/_page_list.html.haml
@@ -4,7 +4,7 @@
= link_to home_link, {:controller => 'groups', :action => 'show', :short_name => group.short_name}, :method => :get, :remote => true, :class => 'get-group', :'data-type' => 'html', :id => "group_link_#{group.id}", :short_name => "#{group.short_name}", :group_id => "#{group.id}"
- group.pages.where(:status => Page::PUBLISHED).order('position').each do |page|
%li.page-title{:id => "li_page_#{page.id}"}
- = link_to url_for(:controller => "pages", :action => "show_group_page", :group_id => group.id, :id => page.id), :method => :get, :remote => true, :class => 'get-page', :'data-type' => 'html', :id => "page_link_#{page.id}", :group_name => "#{group.short_name}", :short_name => "#{page.short_name}", :page_id => "#{page.id}" do
+ = link_to url_for(:controller => "pages", :action => "show_group_page", :group_short_name => group.short_name, :page_short_name => page.short_name), :method => :get, :remote => true, :class => 'get-page', :'data-type' => 'html', :id => "page_link_#{page.id}", :group_name => "#{group.short_name}", :short_name => "#{page.short_name}", :page_id => "#{page.id}" do
= page.title
- membership = current_user.memberships.where(:group_id => group.id).first
- if !membership.blank?
View
15 app/views/groups/_sidebar.html.haml
@@ -0,0 +1,15 @@
+#sidebar
+ - membership = current_user.memberships.where(:group_id => group.id).first
+ - if membership && membership.can_publish?
+ .post
+ #share-block
+ %span.share-plus +
+ = t :share_to_the_community
+ .post
+ #group-pages
+ %h3= t :pages
+ #pages-list
+ = render :partial => 'groups/page_list', :locals => {:group => group }
+ = render :partial => 'groups/members', :locals => {:group => group }
+.clearfix
+
View
17 app/views/groups/show.html.haml
@@ -1,15 +1,6 @@
#posts-area
-#sidebar
- - membership = current_user.memberships.where(:group_id => @group.id).first
- - if membership && membership.can_publish?
- .post
- #share-block
- %span.share-plus +
- = t :share_to_the_community
- .post
- #group-pages
- %h3= t :pages
- #pages-list
- = render :partial => 'page_list', :locals => {:group => @group }
- = render :partial => 'members', :locals => {:members => @members }
+= render :partial => 'sidebar', :locals => {:group => @group }
+- if params['__from__'] == 'url'
+ :javascript
+ afterGetGroup(#{@group.id})
View
2  app/views/layouts/application.html.haml
@@ -19,7 +19,7 @@
#search-box
= form_tag '/search/', :id => 'live-search', :method => 'get', :remote => true do
= text_field_tag :q, nil, :id => 'search-input', :placeholder => 'Busqueda'
+ #flash-notice
#container
- #flash-notice
= yield
.clearfix
View
7 app/views/pages/show_group_page.html.haml
@@ -1,3 +1,4 @@
+
#group-page
#group-page-inner
#group-page-contents
@@ -16,6 +17,9 @@
#save-page-button
= submit_tag (t :save), :disable_with => (t :save_wait), :id => "page-save-submit"
+- if params['__from__'] == 'url'
+ = render :partial => 'groups/sidebar', :locals => {:group => @page.group }
+
:javascript
$(function() {
$('#page-editor').tinymce({
@@ -35,4 +39,7 @@ $(function() {
});
}
+- if params['__from__'] == 'url'
+ :javascript
+ afterGetPage(#{@page.id});
View
5 app/views/users/profile.html.haml
@@ -55,3 +55,8 @@
.posts
- @u.posts.each do |post|
= render :partial => 'posts/post', :locals => {:post => post}
+
+- if params['__from__'] == 'url'
+ :javascript
+ afterGetUser('#{@u.username}')
+
View
2  config/routes.rb
@@ -28,7 +28,7 @@
resources :pages
match 'g/:group_id/p/add' => 'pages#add_page'
- match 'g/:group_id/p/:id' => 'pages#show_group_page'
+ match 'g/:group_short_name/:page_short_name' => 'pages#show_group_page'
match 'pages/:id/update_title' => 'pages#update'
match 'events/upcoming' => 'post_events#upcoming'

No commit comments for this range

Something went wrong with that request. Please try again.