Permalink
Browse files

Admin section introduced.

For now it only includes only development tools:

* A link to recompute all the news score and rank information.
* A link that shows the home page annotated with news id, score, rank.

The user needs to have the "a" flag to access this section.
  • Loading branch information...
1 parent 1c43c9e commit 5ceb46559c4a81f787f99dc9ea1daf66446afd51 @antirez committed Oct 10, 2012
Showing with 41 additions and 4 deletions.
  1. +31 −2 app.rb
  2. +1 −1 page.rb
  3. +9 −1 public/css/style.css
View
@@ -499,6 +499,28 @@ def render_comment_subthread(comment,sep="")
end
end
+get '/admin' do
+ redirect "/" if !$user || !user_is_admin?($user)
+ H.page {
+ H.div(:id => "adminlinks") {
+ H.h2 {"Admin"}+
+ H.h3 {"Developer tools"}+
+ H.ul {
+ H.li {
+ H.a(:href=>"/recompute") {
+ "Recompute news score and rank (may be slow!)"
+ }
+ }+
+ H.li {
+ H.a(:href=>"/?debug=1") {
+ "Show annotated home page"
+ }
+ }
+ }
+ }
+ }
+end
+
###############################################################################
# API implementation
###############################################################################
@@ -824,7 +846,7 @@ def check_api_secret
# The link is not shown at all if the user is not logged in, while
# it is shown with a badge showing the number of replies for logged in
# users.
-def replies_link
+def navbar_replies_link
return "" if !$user
count = $user['replies'] || 0
H.a(:href => "/replies", :class => "replies") {
@@ -835,14 +857,21 @@ def replies_link
}
end
+def navbar_admin_link
+ return "" if !$user || !user_is_admin?($user)
+ H.b {
+ H.a(:href => "/admin") {"admin"}
+ }
+end
+
def application_header
navitems = [ ["top","/"],
["latest","/latest/0"],
["submit","/submit"]]
navbar = H.nav {
navitems.map{|ni|
H.a(:href=>ni[1]) {H.entities ni[0]}
- }.inject{|a,b| a+"\n"+b}+replies_link
+ }.inject{|a,b| a+"\n"+b}+navbar_replies_link+navbar_admin_link
}
rnavbar = H.nav(:id => "account") {
if $user
View
@@ -128,7 +128,7 @@ def page()
self.meta(:charset => "utf-8")+
self.title{H.entities @title}+
self.meta(:content => :index, :name => :robots)+
- self.link(:href => "/css/style.css?v=8", :rel => "stylesheet",
+ self.link(:href => "/css/style.css?v=9", :rel => "stylesheet",
:type => "text/css")+
self.link(:href => "/images/favicon.png", :rel => "shortcut icon")+
self.script(:src => "/js/jquery.1.6.4.min.js"){}+
View
@@ -16,6 +16,10 @@ h2 {
color:#333;
}
+li {
+ list-style-type: none;
+}
+
header {
display:block;
position:relative;
@@ -251,7 +255,6 @@ topcomment {
}
.userinfo ul li {
- list-style-type: none;
margin-bottom:10px;
}
@@ -292,3 +295,8 @@ topcomment {
left:-5px;
opacity:0.7
}
+
+#adminlinks li {
+ list-style-type: disc;
+ margin-left:20px;
+}

0 comments on commit 5ceb465

Please sign in to comment.