Skip to content

Commit

Permalink
Improve helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Francois committed Sep 25, 2013
1 parent 4bebd8b commit 163f998
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
9 changes: 5 additions & 4 deletions app/helpers/admin/base_helper.rb
Expand Up @@ -164,9 +164,10 @@ def set_autosave_tag(article)
@article.inspect
hidden_field_tag("article[id]", @article.id) unless @article.id.nil?
end

def twitter_disabled_message(disabled)
return unless disabled
content_tag(:p, _("If you want to push short statuses on Twitter, you need to %s Twitter gave you after you %s.", link_to(_("fill in the oauth credentials"), :controller => 'admin/settings', :action => 'write'), link_to(_("registered your application"), "https://dev.twitter.com/apps/new")).html_safe, :class => 'alert alert-warning')

def twitter_disabled_message
unless this_blog.has_twitter_configured? && current_user.has_twitter_configured?
content_tag(:p, _("If you want to push short statuses on Twitter, you need to %s Twitter gave you after you %s.", link_to(_("fill in the oauth credentials"), :controller => 'admin/settings', action: 'write'), link_to(_("registered your application"), "https://dev.twitter.com/apps/new")).html_safe, class: 'alert alert-warning')
end
end
end
13 changes: 6 additions & 7 deletions app/views/admin/notes/new.html.erb
Expand Up @@ -11,8 +11,7 @@

<fieldset class="hidden-phone">
<legend><%= _("Publish settings") %></legend>
<% disabled = (this_blog.has_twitter_configured? and current_user.has_twitter_configured?) ? false : true %>
<%= twitter_disabled_message(disabled) %>
<%= twitter_disabled_message %>
<label for="note_push_to_twitter" class='checkbox'>
<%= check_box 'note', 'push_to_twitter', {:disabled => disabled} %>
<%= _("POSSE to Twitter")%>
Expand All @@ -23,15 +22,15 @@
<%= text_field 'note', 'permalink', :class => 'input-block-level' %>
<label for='note_published' class='checkbox'>
<%= check_box 'note', 'published' %>
<%= _("Published") %>
<%= _("Published") %>
</label>
<label for='note_published_at'><%= _("Publish at") %></label>
<%= calendar_date_select 'note', 'published_at', {:class => 'span11'} %>
</fieldset>
<div class='pull-right'>
<%= save( _("Publish")) %>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class='span8'>
Expand All @@ -57,9 +56,9 @@
</td>
</tr>
<% end %>
<%= display_pagination(@notes, 3, 'first', 'last')%>
<%= display_pagination(@notes, 3, 'first', 'last')%>
</tbody>
</table>

</div>
</div>
3 changes: 1 addition & 2 deletions app/views/admin/settings/write.html.erb
Expand Up @@ -57,8 +57,7 @@

<fieldset class='form-horizontal'>
<legend><%= _("Publish on Twitter")%></legend>
<% disabled = (this_blog.has_twitter_configured?) ? false : true %>
<%= twitter_disabled_message(disabled) %>
<%= twitter_disabled_message %>
<div class='control-group'>
<label class='control-label' for="setting_twitter_consumer_key"><%= _("Twitter consumer key")%></label>
<div class='controls'>
Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/users/_form.html.erb
Expand Up @@ -123,8 +123,7 @@
<% unless controller.controller_name == 'users'%>
<fieldset class='form-horizontal'>
<legend><%= _("Publish on Twitter")%></legend>
<% disabled = (this_blog.has_twitter_configured?) ? false : true %>
<%= twitter_disabled_message(disabled) %>
<%= twitter_disabled_message %>
<div class='control-group'>
<label class='control-label' for="user_twitter_account"><%= _("Twitter account")%></label>
<div class='controls'>
Expand Down

0 comments on commit 163f998

Please sign in to comment.