Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. 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.
  2.  
  3. 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.
  4.  
  5. Changes to the default /etc/apache2/httpd.conf
  6. ==============================================
  7.  
  8. Listen 127.0.0.1:80 # so that the world can't see the list
  9.  
  10. DocumentRoot "/Library/WebServer/Documents/public" # to fit in with passenger, you need to create the public dir (and maybe /tmp too)
  11.  
  12. # add /public here too, and no multiviews (as per passenger docs)
  13. <Directory "/Library/WebServer/Documents/public">
  14. Options Indexes FollowSymLinks -MultiViews
  15. AllowOverride None
  16. Order allow,deny
  17. Allow from all
  18. </Directory>
  19.  
  20. New file /etc/apache2/other/passenger.conf
  21. ==========================================
  22.  
  23. # This is basicaly what gets output by the passenger install + the PassengerDefaultUser root line
  24.  
  25. LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.8/ext/apache2/mod_passenger.so
  26. PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.8
  27. PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  28. PassengerDefaultUser root
  29.  
  30. New file /Library/WebServer/Documents/config.ru
  31. ===============================================
  32.  
  33. require 'rubygems'
  34. require 'appscript'
  35. require 'sinatra'
  36.  
  37. require 'todo_app'
  38.  
  39. run Sinatra::Application
  40.  
  41. New file /Library/WebServer/Document/todo_app.rb
  42. ================================================
  43.  
  44. # This is very ugly but it works :)
  45.  
  46. get "*" do
  47. output = []
  48. output << "<html>"
  49. output << " <head>"
  50. output << " <style>"
  51. output << " body {"
  52. output << " background-color: #999;"
  53. output << " text-align: center;"
  54. output << " font-family: 'Bank Gothic';"
  55. output << " }"
  56. output << " h1 {"
  57. output << " margin-top: 1em;"
  58. output << " font-size: 300%;"
  59. output << " color: #333;"
  60. output << " }"
  61. output << " li {"
  62. output << " list-style-type: none;"
  63. output << " font-size: 150%;"
  64. output << " }"
  65. output << " </style>"
  66. output << " </head>"
  67. output << " <body>"
  68. output << " <h1>Do something productive</h1>"
  69. app = Appscript.app("Things.app")
  70.  
  71. list = app.lists.ID("FocusToday").get
  72.  
  73. current_location = nil
  74. list.to_dos.get.each do |todo|
  75. project = todo.project.get
  76. location = if project == :missing_value
  77. todo.area.get.name.get
  78. else
  79. project.name.get
  80. end
  81. if location != current_location
  82. if current_location != nil
  83. output << "</ul>"
  84. end
  85. output << "<h2>#{location}</h2>"
  86. current_location = location
  87. output << "<ul>"
  88. end
  89. output << "<li>"
  90. if todo.status.get == :completed
  91. output << "<del>"
  92. end
  93.  
  94. output << todo.name.get
  95.  
  96. if todo.status.get == :completed
  97. output << "</del>"
  98. end
  99. output << "</li>"
  100. end
  101. output << "</ul>"
  102. output << "</body>"
  103. output << "</html>"
  104. output.join("\n")
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement