Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save chrismcg/266050 to your computer and use it in GitHub Desktop.
Save chrismcg/266050 to your computer and use it in GitHub Desktop.
This is basically a dirty hack :) I have no idea if messing with the default OSX apache config this way is frowned upon. My view is that it works now, and if it breaks I'll fix it.
Add any domains you want to blacklist to /etc/hosts, pointing at 127.0.0.1. You need to enable web sharing to get apache running of course.
Changes to the default /etc/apache2/httpd.conf
==============================================
Listen 127.0.0.1:80 # so that the world can't see the list
DocumentRoot "/Library/WebServer/Documents/public" # to fit in with passenger, you need to create the public dir (and maybe /tmp too)
# add /public here too, and no multiviews (as per passenger docs)
<Directory "/Library/WebServer/Documents/public">
Options Indexes FollowSymLinks -MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
New file /etc/apache2/other/passenger.conf
==========================================
# This is basicaly what gets output by the passenger install + the PassengerDefaultUser root line
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.8
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
PassengerDefaultUser root
New file /Library/WebServer/Documents/config.ru
===============================================
require 'rubygems'
require 'appscript'
require 'sinatra'
require 'todo_app'
run Sinatra::Application
New file /Library/WebServer/Document/todo_app.rb
================================================
# This is very ugly but it works :)
get "*" do
output = []
output << "<html>"
output << " <head>"
output << " <style>"
output << " body {"
output << " background-color: #999;"
output << " text-align: center;"
output << " font-family: 'Bank Gothic';"
output << " }"
output << " h1 {"
output << " margin-top: 1em;"
output << " font-size: 300%;"
output << " color: #333;"
output << " }"
output << " li {"
output << " list-style-type: none;"
output << " font-size: 150%;"
output << " }"
output << " </style>"
output << " </head>"
output << " <body>"
output << " <h1>Do something productive</h1>"
app = Appscript.app("Things.app")
list = app.lists.ID("FocusToday").get
current_location = nil
list.to_dos.get.each do |todo|
project = todo.project.get
location = if project == :missing_value
todo.area.get.name.get
else
project.name.get
end
if location != current_location
if current_location != nil
output << "</ul>"
end
output << "<h2>#{location}</h2>"
current_location = location
output << "<ul>"
end
output << "<li>"
if todo.status.get == :completed
output << "<del>"
end
output << todo.name.get
if todo.status.get == :completed
output << "</del>"
end
output << "</li>"
end
output << "</ul>"
output << "</body>"
output << "</html>"
output.join("\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment