···77 array("notes"),
88 array("duration_secs"),
99 array("air_date"),
1010+ array("filesize"),
1011 );
1112 static $validates_uniqueness_of = array(
1213 array("episode"),
···14151516 static $attr_accessible = array(
1617 "episode", "is_pending", "air_date", "title", "is_explicit",
1717- "duration_secs", "notes", "filesize", "summary",
1818+ "duration_secs", "notes", "summary",
1819 );
19202020- public function mp3_url() {
2121- return Settings::fetch()->url . "episodes/garbage" . $this->episode
2222- . ".mp3";
2121+ static $after_destroy = array("delete_mp3_file");
2222+2323+ public function get_file_path() {
2424+ return "episodes/garbage" . intval($this->episode) . ".mp3";
2525+ }
2626+2727+ public function get_mp3_url() {
2828+ return Settings::fetch()->url . $this->file_path;
2329 }
24302525- public function absolute_url() {
3131+ public function get_mp3_path() {
3232+ return HALFMOON_ROOT . "/public/" . $this->file_path;
3333+ }
3434+3535+ /* publicly viewable page, not mp3 */
3636+ public function get_absolute_url() {
2637 return Settings::fetch()->url . "episodes/" . $this->episode;
2738 }
28392929- public function artwork_url() {
4040+ public function get_artwork_url() {
3041 return Settings::fetch()->logo_url;
3142 }
32433333- public function notes_html() {
4444+ public function get_notes_html() {
3445 $parsedown = new Parsedown();
3546 return $parsedown->text($this->notes);
4747+ }
4848+4949+ public function take_new_mp3($file) {
5050+ move_uploaded_file($file, $this->mp3_path);
5151+ $this->filesize = filesize($this->mp3_path);
5252+ }
5353+5454+ public function delete_mp3_file() {
5555+ unlink($this->mp3_path);
3656 }
3757}
3858
-3
public/404.html
···66</head>
77<body>
88 <h1>File not found</h1>
99- <p>
1010- Change this error message for pages not found in <tt>public/404.html</tt>
1111- </p>
129</body>
1310</html>
+1-1
public/500.html
···77<body>
88 <h1>Application error</h1>
99 <p>
1010- Change this error message in <tt>public/500.html</tt>
1010+ :(
1111 </p>
1212</body>
1313</html>