Added helper functions, added test data files master
authorNeil Smith <neil.git@njae.me.uk>
Wed, 30 Dec 2015 11:26:22 +0000 (11:26 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Wed, 30 Dec 2015 11:26:22 +0000 (11:26 +0000)
20 files changed:
SIGNED.md [new file with mode: 0644]
dir1/IMG_20150404_102723.jpg [new file with mode: 0644]
dir1/IMG_20150406_135852.jpg [new file with mode: 0644]
dir1/IMG_20150406_135909.jpg [new file with mode: 0644]
dir1/IMG_20150406_141704.jpg [new file with mode: 0644]
dir1/IMG_20150406_145314.jpg [new file with mode: 0644]
dir1/IMG_20150411_112705.jpg [new file with mode: 0644]
dir1/IMG_20150411_132115.jpg [new file with mode: 0644]
dir1/VID_20150406_150034.mp4 [new file with mode: 0644]
dir1/VID_20150406_150054.mp4 [new file with mode: 0644]
dir2/IMG_20150812_134302.jpg [new file with mode: 0644]
dir2/IMG_20150812_134315.jpg [new file with mode: 0644]
dir2/IMG_20150812_145033:nopm:.jpg [new file with mode: 0644]
dir2/IMG_20150812_153048.jpg [new file with mode: 0644]
dir2/IMG_20150812_155951.jpg [new file with mode: 0644]
dir2/IMG_20150812_155956.jpg [new file with mode: 0644]
dir2/IMG_20150812_160010.jpg [new file with mode: 0644]
dir2/PANO_20150812_134323.jpg [new file with mode: 0644]
dir2/PANO_20150812_145742.jpg [new file with mode: 0644]
helpers.rb

diff --git a/SIGNED.md b/SIGNED.md
new file mode 100644 (file)
index 0000000..0f02fff
--- /dev/null
+++ b/SIGNED.md
@@ -0,0 +1,94 @@
+##### Signed by https://keybase.io/neilnjae
+```
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2
+
+iQIcBAABCAAGBQJWg79oAAoJEJPB2e07PgbqCjcP/0JhCw6pn70JuP9epOjYZM1g
+Jriq7i7n/4iclYWQqb9Qm2a50A+6MiXRd1H/eD/uwaDDoWD6u6PFejijYhZWhGkl
+DWUi949sdRsgxR5M8tFRkiEWeEidTyk7znKGHqquF/xZ32lyIl+mWrJZVbg9phLE
+5c1xpT3kppRwB6G/cgnfyIQKPJFQ+GcENH16YKG+xrklhzBDy+hYdEyFQdyOcDBE
+WKmKqXLRs0nhl9F6QxhmuBhrpqEJjTIntQ+hL4HQXZtuPbr8ijUnOT0alVCnX4g3
+eK2y5LlFk5mMNMy+ZkYTq8NpnSVqL26Lfj3afIQD7YwU0RADuTs8jUhfphIZT1No
+on2Lk7WlzfpmysIFuIzxvhrhUZEWmKSdj5W7niiP0ND9V/ruFrrEZxQn5VmP/APK
+Ffse/WeRtqmVInSqdMZUtpyzX0uW0LkyVEtAq0uVw0wR0PnhwdtyzCYnz104SHKz
+igBO/V43Bm6Jn1R69JmkaijZE+5+VWOytCN/uMllKTGWTkTxLMqewvMja09qyj2E
+7vMzJKHwZhGhSSCfyDPQlIuC6OJoFcPhw683oNKcHoCIbZ+47RxNun6Ue2y4di2q
+YOjTSKgJBwy+L+dGlcofZRJuRD7aTaGjTgKURma00w7XSxIo+bqUHEC8Slt5UyED
+0nAy3kn/bUZQoPG8cSAl
+=S9i5
+-----END PGP SIGNATURE-----
+
+```
+
+<!-- END SIGNATURES -->
+
+### Begin signed statement 
+
+#### Expect
+
+```
+size      exec  file                                   contents                                                                                                                         
+                ./                                                                                                                                                                      
+546               .gitignore                           c229f06884e3730a56210115ad71a210ba3f7f4f6803f4662a4ff65644bd190f                                                                 
+160               Gemfile                              eba2f6952ab24f3ca4c4aecc7aa7f0904bc186364799270b2f2e52bb57779351                                                                 
+450               app.rb                               b3514e4ac16486ec7b987698166139018b27ced7733ca5d57a8f961e89fd7c7b                                                                 
+                  dir1/                                                                                                                                                                 
+1494572             IMG_20150404_102723.jpg            e9ed46266e367199ebb62ce9a34759768013d3bf27fb4d89e7f2f293fd84797f|c2568e83e56b62ae661555eaac9a5b6343a3549170ac56b660f63ca30e089b74
+2417431             IMG_20150406_135852.jpg            6f3c46e20756f1438d8c1844cabcfad15f99263c29b3f7ff2c7d815990e04b63|359b3cc272bcb60f1f06c30b2220354a54026809e22c19b3a6390894b38333d5
+2607561             IMG_20150406_135909.jpg            ea035714b728201f10c20c5f9712ce6583d0fd35ff04a6eafa7f5459c34dc607|ae1178fa54dc9eddb0714129717053ee0e9fe9e76f4ec72c19597560f9e117ff
+2290575             IMG_20150406_141704.jpg            89bb7f46072e58efe8fce2c10f419a5d880239cd18a1aa0ee82256bdb19a89b9|0c39555799dcb048c915db57b862d41327d0771b410a32bc4afdcc9f951e7b06
+2395464             IMG_20150406_145314.jpg            e88fa3a466e6434897fc1dbd75be6534174f04ed9152b0d6414ad24f23fadb10|fa957bc3f4130eff32a65a9919e7196d74a95ae965c3d1a4cf081899ca83b2d6
+2502894             IMG_20150411_112705.jpg            1eba8fb33af898c074b71304c5d3106318fae3ccaf01937e33cb19f42b76f327|38bd30258188f98f308fef78c9cb007b44fb210bdfba13a39522d049d69a1b2d
+2696900             IMG_20150411_132115.jpg            887522ea3aff2f4187ab9a567e7eb957432605ee52a9315df94e2e0aba4954d8|497c08fd3d77ee03d20e9b3084ff284513787f938d963068404b6620d76a04c2
+9625651             VID_20150406_150034.mp4            3c844f1868813999c81db8eb82fd800ef388e63cf417890f7e0d0378679b9362|e7b83de5f2b8f21494c8cd518663d71496f7aa5569dcff3e4193c265f77a6ef8
+21500687            VID_20150406_150054.mp4            a75be8d23be6a231261fa127b21bea04fb721eb1d705ea3dee8eaf4f300c2e7f|cbc04824912a77af353dcf45be237dcf54aa0aac244790d08dab2fcd18faa41f
+                  dir2/                                                                                                                                                                 
+2206457             IMG_20150812_134302.jpg            1d3713b30b8edf03b3d15620c918793b4cd3b65bcf901baa4627b574bd6e0b29|961e0ddc7011efed3bde3715bae81a5d68ec18586595b28a9e46d62c2ef84c6c
+2758975             IMG_20150812_134315.jpg            50e73e9467730002756afd99eb4cf0cafb688c3305ad0ddeeb00d6e9045e2910|bcc6ee4844fcec26d8f658564d882a9c453f945288df35a282149c06781bf650
+1599007             IMG_20150812_145033%3Anopm%3A.jpg  f4b408ce3b317b23292178b3673f8c5ee70eaa24865028d6e617d31acc971f46|711604cb61c81f25d4386d42a8b023e298e0d904a5ebcaa750a3791a2cebecd7
+3092136             IMG_20150812_153048.jpg            03ab5812e04cb7a2b2feaa5cad40108a192093fe6028cc1eb9e35236493fb923|1c74a6087775633fe0a475ba43a60ecd1edb5a051b69fc19952e94f57a963276
+3634142             IMG_20150812_155951.jpg            1c2495686fe82b78ac1e9a2bd16a4619ebba8d5f23ac061d2f56344de05985f5|dcefefb1609dcc24a1e32a3f09722547d51d8b78c6efc49f2ba2a36e919bf1a4
+3070906             IMG_20150812_155956.jpg            8cbdebb3e6cf4e22d4f1a8ba6bf1b0310c045edc493af7a22f1a781703325d0f|df01f628e3dc38cd8efa34b28d4834b472f2b6cea706a88d6b728c5cb0daf3b6
+1291332             IMG_20150812_160010.jpg            6fb1c47765e88130aca8e498f3e2c8eacece39d35cd8227a961366d2d72e58f7|d118952edd05ba207c0f59885f59f020e467692a27eda949df034ff95fdd3885
+5790576             PANO_20150812_134323.jpg           7fe8a88216eaeff6328ed1f158711cd328067a20d87d64f01dcaac25c3a47072|41b196ed2b5e23b1359cf9df8d7009c26f292f2e2b0b82e02094cebf2b3478be
+5231682             PANO_20150812_145742.jpg           ef9420a7589c536e0a3a9b30ee8e09e0fa207a0d9e93220be5a4709bad55ebbe|5efdbd0ef05bebb818b17307945cb0f77a570bb8f1d6b33d3a5500277e9cb763
+817               helpers.rb                           d1c26ba9d178a864e72732bc58ba1eb40b849d7de5b399498041fbd0dd883ca7                                                                 
+160               rakefile                             6ffa79af5f0ed3756301a43c1bfe84029a995ef106ed7ca4dc8f3f85da69bf96                                                                 
+```
+
+#### Ignore
+
+```
+/SIGNED.md
+```
+
+#### Presets
+
+```
+git  # ignore .git and anything as described by .gitignore files
+```
+
+<!-- summarize version = 0.0.9 -->
+
+### End signed statement
+
+<hr>
+
+#### Notes
+
+With keybase you can sign any directory's contents, whether it's a git repo,
+source code distribution, or a personal documents folder. It aims to replace the drudgery of:
+
+  1. comparing a zipped file to a detached statement
+  2. downloading a public key
+  3. confirming it is in fact the author's by reviewing public statements they've made, using it
+
+All in one simple command:
+
+```bash
+keybase dir verify
+```
+
+There are lots of options, including assertions for automating your checks.
+
+For more info, check out https://keybase.io/docs/command_line/code_signing
\ No newline at end of file
diff --git a/dir1/IMG_20150404_102723.jpg b/dir1/IMG_20150404_102723.jpg
new file mode 100644 (file)
index 0000000..88f4367
Binary files /dev/null and b/dir1/IMG_20150404_102723.jpg differ
diff --git a/dir1/IMG_20150406_135852.jpg b/dir1/IMG_20150406_135852.jpg
new file mode 100644 (file)
index 0000000..70673ee
Binary files /dev/null and b/dir1/IMG_20150406_135852.jpg differ
diff --git a/dir1/IMG_20150406_135909.jpg b/dir1/IMG_20150406_135909.jpg
new file mode 100644 (file)
index 0000000..a25114e
Binary files /dev/null and b/dir1/IMG_20150406_135909.jpg differ
diff --git a/dir1/IMG_20150406_141704.jpg b/dir1/IMG_20150406_141704.jpg
new file mode 100644 (file)
index 0000000..3e4b313
Binary files /dev/null and b/dir1/IMG_20150406_141704.jpg differ
diff --git a/dir1/IMG_20150406_145314.jpg b/dir1/IMG_20150406_145314.jpg
new file mode 100644 (file)
index 0000000..8537754
Binary files /dev/null and b/dir1/IMG_20150406_145314.jpg differ
diff --git a/dir1/IMG_20150411_112705.jpg b/dir1/IMG_20150411_112705.jpg
new file mode 100644 (file)
index 0000000..0ccf520
Binary files /dev/null and b/dir1/IMG_20150411_112705.jpg differ
diff --git a/dir1/IMG_20150411_132115.jpg b/dir1/IMG_20150411_132115.jpg
new file mode 100644 (file)
index 0000000..8190005
Binary files /dev/null and b/dir1/IMG_20150411_132115.jpg differ
diff --git a/dir1/VID_20150406_150034.mp4 b/dir1/VID_20150406_150034.mp4
new file mode 100644 (file)
index 0000000..0ce14d5
Binary files /dev/null and b/dir1/VID_20150406_150034.mp4 differ
diff --git a/dir1/VID_20150406_150054.mp4 b/dir1/VID_20150406_150054.mp4
new file mode 100644 (file)
index 0000000..2106f89
Binary files /dev/null and b/dir1/VID_20150406_150054.mp4 differ
diff --git a/dir2/IMG_20150812_134302.jpg b/dir2/IMG_20150812_134302.jpg
new file mode 100644 (file)
index 0000000..7bfbd4c
Binary files /dev/null and b/dir2/IMG_20150812_134302.jpg differ
diff --git a/dir2/IMG_20150812_134315.jpg b/dir2/IMG_20150812_134315.jpg
new file mode 100644 (file)
index 0000000..195f6c2
Binary files /dev/null and b/dir2/IMG_20150812_134315.jpg differ
diff --git a/dir2/IMG_20150812_145033:nopm:.jpg b/dir2/IMG_20150812_145033:nopm:.jpg
new file mode 100644 (file)
index 0000000..57d5eca
Binary files /dev/null and b/dir2/IMG_20150812_145033:nopm:.jpg differ
diff --git a/dir2/IMG_20150812_153048.jpg b/dir2/IMG_20150812_153048.jpg
new file mode 100644 (file)
index 0000000..2bb4567
Binary files /dev/null and b/dir2/IMG_20150812_153048.jpg differ
diff --git a/dir2/IMG_20150812_155951.jpg b/dir2/IMG_20150812_155951.jpg
new file mode 100644 (file)
index 0000000..8384f05
Binary files /dev/null and b/dir2/IMG_20150812_155951.jpg differ
diff --git a/dir2/IMG_20150812_155956.jpg b/dir2/IMG_20150812_155956.jpg
new file mode 100644 (file)
index 0000000..17bc043
Binary files /dev/null and b/dir2/IMG_20150812_155956.jpg differ
diff --git a/dir2/IMG_20150812_160010.jpg b/dir2/IMG_20150812_160010.jpg
new file mode 100644 (file)
index 0000000..a9aa0a6
Binary files /dev/null and b/dir2/IMG_20150812_160010.jpg differ
diff --git a/dir2/PANO_20150812_134323.jpg b/dir2/PANO_20150812_134323.jpg
new file mode 100644 (file)
index 0000000..3b545e9
Binary files /dev/null and b/dir2/PANO_20150812_134323.jpg differ
diff --git a/dir2/PANO_20150812_145742.jpg b/dir2/PANO_20150812_145742.jpg
new file mode 100644 (file)
index 0000000..97b408d
Binary files /dev/null and b/dir2/PANO_20150812_145742.jpg differ
index a0de50de0a95e8f787a1212db9e63e40699f153d..66ca90e0015b49105fa18ac3459d0a2dd2c13ffa 100644 (file)
@@ -1,13 +1,36 @@
 module Sinatra
-  module SampleApp
+  module PhotoFiling
     module Helpers
 
-      def require_logged_in
-        redirect('/sessions/new') unless is_authenticated?
+      def files_in_dir
+        Dir.entries(session[:current_dir]).select {|f| File.file? f}.sort_by {|f| file_sort_key f}
       end
 
-      def is_authenticated?
-        return !!session[:user_id]
+      def files_for_today(current_file)
+        if File.exists?(current_file)
+          day = File.mtime(current_file).to_date
+          files_in_dir.select {|f| File.mtime(f).to_date == day}
+        end
+      end
+
+      def next_file(file)
+        fid = files_in_dir
+        i = fid.find_index(file)
+        if i && i < fid.length
+          fid[i + 1]
+        end
+      end
+
+      def previous_file(file)
+        fid = files_in_dir
+        i = fid.find_index(file)
+        if i && i > 0
+          fid[i - 1]
+        end
+      end
+
+      def file_sort_key(file)
+        File.mtime(file).to_s + file
       end
 
     end