Skip to content

Commit

Permalink
alert of old ruby version for end of ruby 1.8 #267
Browse files Browse the repository at this point in the history
	* show an alert message top of config page
	* hide the message after click close button
	* save option 'old_ruby_alert.hide' as true
  • Loading branch information
tdtds committed Mar 13, 2013
1 parent f607ef3 commit fac629a
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
@@ -1,5 +1,6 @@
2013-03-13 TADA Tadashi <t@tdtds.jp>
* tdiary/server.rb: fix js not load
* alert of old ruby version for end of ruby 1.8

2013-02-10 MATSUOKA Kohei <kohei@machu.jp>
* tdiary/view.rb, js/comment_ajax.js: post comment with ajax
Expand Down
20 changes: 20 additions & 0 deletions js/01conf.js
Expand Up @@ -39,4 +39,24 @@ $(function(){
});
return false;
});

/*
* old ruby alert
*/
$('#alert-old-ruby').on('click', function(){
var data = 'conf=old_ruby_alert;saveconf=OK';
var csrf_key = $('#conf-form input[name=csrf_protection_key]').attr('value');
if (csrf_key){ data += ';csrf_protection_key=' + csrf_key; }

$.ajax({
url: $('#conf-form').attr('action'),
type: 'POST',
dataType: 'html',
data: data
}).done(function(html){
$('.alert-warn').hide();
}).fail(function(XMLHttpRequest, textStatus, errorThrown){
alert('failed saving settings.' + textStatus);
});
});
});
25 changes: 25 additions & 0 deletions plugin/00default.rb
Expand Up @@ -982,6 +982,31 @@ def saveconf_recommendfilter
end
end

#
# old ruby alert
#
def old_ruby_alert
if RUBY_VERSION < '1.9' and !@conf['old_ruby_alert.hide']
%Q|<div class="alert-warn">
<a href="#" class="action-button" id="alert-old-ruby">&times;</a>
#{old_ruby_alert_message}
</div>|
else
''
end
end

def old_ruby_alert_message
"お使いのRuby #{RUBY_VERSION}は次のリリースからサポート対象外になります。"
end

add_conf_proc( 'old_ruby_alert', nil) do
if @mode == 'saveconf'
@conf['old_ruby_alert.hide'] = true
end
%Q|<h3>OLD RUBY ALERT</h3>| # dummy
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
Expand Down
7 changes: 7 additions & 0 deletions plugin/en/00default.rb
Expand Up @@ -375,6 +375,13 @@ def comment_mail_basic_html
HTML
end

#
# old ruby alert
#
def old_ruby_alert_message
"The ruby #{RUBY_VERSION} will be unsupported by tDiary next release."
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
Expand Down
1 change: 1 addition & 0 deletions skel/conf.rhtml
@@ -1,5 +1,6 @@
<%%=navi%>
<h1><%=h @conf.html_title %>(<%%=h navi_preference%>) - <%%=h conf_label( <%=@key.dump%> )%><%%=help( <%=@key.dump%> + '.rb' )%></h1>
<%%= old_ruby_alert %>
<div class="sidebar">
<%% each_conf_genre do |genre|%>
<div class="block">
Expand Down
43 changes: 43 additions & 0 deletions theme/conf.css
Expand Up @@ -28,6 +28,49 @@ a:visited {
color: #A8B392;
}

div.alert-warn {
background-color: #faa;
border-style: solid;
border-color: #f88;
border-width: 1px;
border-radius: 8px;
padding: 4px 8px;
margin: 1em auto;
width: 80%;
zoom: 100%;
}

.action-button {
float: right;
border-style: solid;
border-color: transparent;
border-width: 1px;
border-radius: 8px;
padding: 0px 4px;
color: #000;
}
.action-button:hover {
background-color: #f88;
border-style: solid;
border-color: #f55;
border-width: 1px;
border-radius: 8px;
padding: 0px 4px;
}
.action-button:link,
.action-button:visited {
color: #000;
text-decoration: none;
}

div.alert-warn:after {
content: "";
height: 0;
visibility: hidden;
display: block;
clear: both;
}

div.adminmenu {
font-size: 80%;
margin: 3px 0px 3px 0px;
Expand Down

0 comments on commit fac629a

Please sign in to comment.