Commits

Anonymous committed 1ca9b69

added s3 search template, moved s3 credentials to private area

Comments (0)

Files changed (3)

sfgeek/apps/s3songs/management/commands/get_music_bucket_list.py

 import pytz
 from datetime import datetime, timedelta
 from django.core.management.base import BaseCommand, CommandError
+
+from django.conf import settings
 import os
 import sys
 import re
 
 from s3songs.lib.data_sources.files import music_json_filename
 
-AWS_ACCESS_KEY_ID = 'AKIAJAXY4LMFNR2GTLEA'
-AWS_SECRET_ACCESS_KEY = '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'
-
-BUCKET_NAME = 'music.sfblur.com'
-conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
+conn = boto.connect_s3(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY)
 
 class Command(BaseCommand):
     """
     def handle(self, *args, **options):
 
         print '----- bucket location -----'
-        bucket = conn.get_bucket(BUCKET_NAME)
+        bucket = conn.get_bucket(settings.BUCKET_NAME)
 
         print '----- listing bucket -----'
         dir_list = bucket.list()

sfgeek/apps/s3songs/templates/s3songs/search.html

+<!DOCTYPE html>
+<html>
+<head>
+    <title>Search S3</title>
+
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
+</head>
+<body>
+<form  id="music-search-form">
+    <input id='music-query' name='music-query'></input>
+    <input type="submit"></input>
+</form>
+<div id='music-search-result-list'><ul></ul></div>
+</body>
+</html>
+<script>
+var song_dict;
+$( document ).ready(function() {
+    console.log( "ready!" );
+    $.get("/static/music.json", function( data ) {
+      song_dict =  data ;
+      console.log( "Load was performed." );
+    });
+    $("#music-search-form").submit(function(e)
+    {
+        e.preventDefault(); //STOP default action
+        console.log( "Form button pressed." );
+        $("#music-search-result-list ul").empty();
+        query =  $("#music-search-form input[name=music-query]").val( );
+        if(query.length < 3)
+        {
+            $("#music-search-result-list ul").append('<li><a href="#"><span class="tab">need more characters</span></a></li>');
+        } else {
+            //console.log(query);
+            song_dict.forEach(function(entry) {
+
+                if (entry.key.toLowerCase().indexOf(query.toLowerCase()) != -1){
+                    //console.log(entry.key + ' Matched');
+                    //console.log(entry);
+                    $("#music-search-result-list ul").append('<li><a href="'+entry.value+'"><span class="tab">'+entry.key+'</span></a></li>');
+                }
+            });
+        }
+
+
+
+    });
+});
+</script>

sfgeek/settings.py

             },
         }
 
+
+########################################################################
+# import local environment settings
+
+try:
+    from local_settings import *
+except ImportError:
+    pass