PageRenderTime 178ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/software/cedar-rapids-online.html

https://github.com/tjr/tjr.github.com
HTML | 231 lines | 185 code | 46 blank | 0 comment | 0 complexity | a2ed5f0e9a222437b8b756e77268ce81 MD5 | raw file
  1. <html>
  2. <head>
  3. <title>Cedar Rapids Online - a CherryPy web application</title>
  4. <link rel="stylesheet" href="/css/traditional.css" media="all" title="Default" charset="utf-8">
  5. </head>
  6. <body>
  7. <div id="content">
  8. <h1>Cedar Rapids Online</h1>
  9. <p>
  10. a web application by <a href="/">Trevis Rothwell</a>
  11. </p>
  12. <hr>
  13. <a href="http://picasaweb.google.com/lh/photo/1oP34MQeXoF6KDHG3dmrrQ?feat=embedwebsite"><img src="http://lh4.ggpht.com/_IsIl4HvOgJw/R3bgPQ_05AI/AAAAAAAAA4g/PtgjABVNHak/s288/downtown-cedar-rapids-05.jpg" class="photo" align="right"/></a>
  14. <h2>Quick Links</h2>
  15. <ul>
  16. <li><a href="http://github.com/tjr/CedarRapidsOnline">Get the source code</a></li>
  17. </ul>
  18. <h2>Background Information</h2>
  19. <p>
  20. Much of what I know about building web applications I learned from Philip Greenspun's
  21. <a href="http://philip.greenspun.com/seia/">instructional materials</a>. To execute on what I
  22. learned, I decided to build an online learning community website for residents of
  23. Cedar Rapids, Iowa. I originally built it using Python and PostgreSQL, running directly
  24. on top of the <a href="http://www.modpython.org/">mod_python</a> Apache module. Unfortunately,
  25. either there was very little interest on the web for a Cedar Rapids online learning community,
  26. or I did a woeful job of marketing my project. Maybe a little of both. In any event, after
  27. it became clear that the vast majority of registered users were Russian spammers, I shut the
  28. site down.
  29. <p>
  30. However, even if the site was not a commercial success, it was still an example of the kind
  31. of work I can do, so I eventually decided to dust it off, polish it up, and unleash it as part
  32. of my project portfolio. I spent about a week of evenings recoding the application to run
  33. in the <a href="http://www.cherrypy.org/">CherryPy</a> web framework, and released the source
  34. code under the GNU Affero GPL. It could still stand some code refactoring and other miscellaneous
  35. improvements, but I'm not really interested in running it as a real user-facing website right
  36. now, and have mostly moved on to other projects for the time being.
  37. <p>
  38. The remainder of this document explains the software architecture and some design decisions
  39. from the point of view of getting ready for real users.
  40. <h2>Design Goals</h2>
  41. <p>
  42. This project is a traditional online learning community website, with the target audience
  43. of residents and potential future residents of Cedar Rapids, Iowa. The key features are:
  44. <ul>
  45. <li>User accounts and authentication.</li>
  46. <li>Article documents, with optional user comments.</li>
  47. <li>Discussion forums, as user-generated content.</li>
  48. <li>Event calendar, as user-generated content.</li>
  49. </ul>
  50. <p>
  51. Apart from building the software, this project also requires magnet content in the form
  52. of articles (ideally with some pertinent photography).
  53. <h2>Implementation</h2>
  54. <h3>The Big Picture</h3>
  55. <ul>
  56. <li>The web site is served simply by the built-in CherryPy web server. If this ever proves
  57. unable to handle the user load, the CherryPy documentation includes suggestions for other
  58. serving options.</li>
  59. <li>The data is stored in a half-dozen PostgreSQL tables.</li>
  60. <li>The web pages are generated using Python scripts built with the CherryPy web library
  61. and the PyGreSQL database library. No HTML templating language is used, as most of the
  62. HTML content is generated from data in the database, and I have no problem writing
  63. relatively small amounts of HTML directly in Python.</li>
  64. </ul>
  65. <h3>The User Interface</h3>
  66. <ul>
  67. <li>Index Page<br>
  68. The main index page includes an overview text describing the purpose of the
  69. website, and provides links to the core functionality through a menu at the
  70. top of the page. (This menu is also present on the other pages.) Without logging
  71. in, the user can view the article pages, the discussion forum, and the event calendar,
  72. but cannot contribute any information to the site.
  73. </li>
  74. <br>
  75. <li>Register Page<br>
  76. The user registration page lets users create a new account on the site. Users must provide
  77. a name (which will be displayed on most content they create on the site), an email address
  78. (semi-validated through regular expressions), and a password. They may optionally provide
  79. the URL of their own website. Based on past experience, full email validation, by way of
  80. (say) sending a site-generated password to the user's email account can be a hindrance for
  81. some users. While the site is new and extremely eager to attract as many new users as
  82. possible, this hurdle is not being presented. As the site grows, it may be optimal to
  83. require full email address validation.
  84. <br><br>
  85. Prior to a successful registration, the system verifies that the provided email address
  86. is not already in use, as email addresses serve as the user's login ID, and as such must
  87. be unique.
  88. </li>
  89. <br>
  90. <li>Login Page<br>
  91. Registered users can log in by providing their email address and password.
  92. </li>
  93. <br>
  94. <li>Articles<br>
  95. The main articles page is used to display an index of magnet content articles. The
  96. article index is itself an article named "map"; going to "/articles/" presents the same
  97. content as going to "/articles/map".
  98. <br><br>
  99. The articles themselves are accessible by passing the name (or, more precisely, the "slug")
  100. of the article to the "/articles/" page. For example, an article with the slug
  101. "eating-out" would be viewable at the URL "/articles/eating-out". Each article can be
  102. optionally set to allow user comments or disallow them; users must be logged in to post
  103. comments.
  104. <br><br>
  105. Note also that the main index page ("/") is an article as well, named "welcome". This is
  106. slightly non-sensical, but easily allows the main index to be editable from the articles
  107. admin interface, rather than offering a separate interface just for the index.
  108. </li>
  109. <br>
  110. <li>Discussions<br>
  111. The discussions page displays a listing of user-generated discussion threads, in
  112. chronologically-descending order. Like the articles page, each discussion thread is
  113. accessible as a sub-URL: "/discussions/" shows the index, and "/discussions/42" shows
  114. discussion thread #42. (Since articles are generated only by admin users, and there
  115. will ostensibly be fewer articles than discussions, articles are identified by a
  116. memorable slug name, while discussions are identified by number. A slug could be
  117. generated based on discussion subject, if more SEO-friendly URLs are desired.)
  118. <br><br>
  119. Logged-in users can start new discussions from the index, and add replies to existing
  120. threads from that thread's page. Nested threading is not implemented, in the hopes that
  121. discussions will stay on topic.
  122. </li>
  123. <br>
  124. <li>Events<br>
  125. The events page is very similar to the discussions page. Logged-in users can create new event
  126. listings; the main events index shows a listing of events in chronological order (with
  127. headers automatically inserted to separate months and years), and individual event
  128. details can be viewed at, e.g., "/events/42". No comments are allowed for events.
  129. </li>
  130. <br>
  131. <li>Admin Pages<br>
  132. The admin pages are restricted to logged-in users at the admin level (2 or higher, though
  133. presently there is no distinction for any user level above 2). There are admin pages
  134. to create and edit articles; delete comments; delete discussions; delete events. Throughout
  135. the site, if the user is an admin, there are links attached to user-generated content to
  136. go to page to delete the specified content. For example, for every discussion and reply,
  137. there will be a link to delete it. If a discussion is deleted, all replies are also deleted.
  138. If a reply is deleted, only that particular reply is deleted.
  139. </li>
  140. </ul>
  141. <h2>Data Model</h2>
  142. <p>
  143. There are five tables in the data model:
  144. <ul>
  145. <li>users</li>
  146. <li>articles</li>
  147. <li>discussions</li>
  148. <li>discussion_categories</li>
  149. <li>events</li>
  150. </ul>
  151. <p>
  152. Article replies are stored as articles with a non-null "refers_to" field pointing
  153. to the parent article. Discussion replies are stored with a non-null "refers_to" field
  154. pointing to the parent discussion. The discussion categories table is currently unused;
  155. when an online community is young, it's better to not segregate users into discussion
  156. categories, but rather keep all discussions together so people can find each other. As
  157. the community grows, discussion categories may be implemented.
  158. <p>
  159. The SQL tables are written in PostgreSQL format, and are viewable (and documented in
  160. more detail) in the <a href="http://github.com/tjr/CedarRapidsOnline/blob/master/sql/crdb2.sql">
  161. code repository</a>.
  162. <h2>Future Directions</h2>
  163. <p>
  164. The existing design should be a fairly robust online learning community system. This
  165. is not a research project; online communities have existed since the mid-1990's, and
  166. much has been tried and either proven successful or failed. Any changes that need to be
  167. made in this particular online community will have to be determined based on usage.
  168. <h2>License</h2>
  169. <p>
  170. The software is licensed under the
  171. <a href="http://www.gnu.org/licenses/licenses.html">GNU Affero GPL</a>.
  172. <p>
  173. <img src="/images/agpl.png">
  174. <h2>References</h2>
  175. <ul>
  176. <li><a href="http://philip.greenspun.com/seia/">Software Engineering for Internet
  177. Applications</a></li>
  178. <li><a href="http://philip.greenspun.com/wtr/dead-trees/">Database-Backed Web Sites</a></li>
  179. <li><a href="http://philip.greenspun.com/sql/">SQL for Web Nerds</a></li>
  180. </ul>
  181. <hr>
  182. <i><a href="mailto:tjr@acm.org">tjr@acm.org</a></i>
  183. </div>
  184. </body>
  185. </html>