コード例 #1
0
ファイル: snap.py プロジェクト: chrisGoad/imagediver_sv
 def genPage(self,sendToS3=True,compressJs=True):
   #vprint("CONSTANTS.COMPRESS",constants.compressJs)
   pagetext = "" # LATER fix this; pagetext is for custom pages
   pg0= gen.pageHeader("","ImageDiver") + "<body>"
   svdv = constants.devVersion
   if sendToS3: constants.devVersion = 0
   if  (sendToS3 or constants.compressJs):
     pg0 += constants.jsPreamble + constants.cjsForPage("common") +  constants.cjsForPage("snap")
   else:
     pg0 +=  constants.jsPreamble + constants.toJsIncludes(constants.commonJsFiles) + constants.toJsIncludes(constants.jsFiles['snap'])
   constants.devVersion = svdv
   pg1 = """
   <script>
   page.initialize();
   </script>
   <div class="outerDiv">
     <div class="topDiv">
         <div class="topDivTop"></div>
        <div class="titleDiv"></div>
     </div>
   </div>
   </body>
   </html>
   """
   pg =  pg0 + pg1
   #fl = "/mnt/ebs1/imagediver/temp/snap.html"
   tp = self.topic
   #topicdir = "/topicd" if constants.publishToS3Dev else "/topic"
   s3path = constants.topicDir+tp+"/index.html" #the path where the page will finally end up
   #models.writeFile(fl,pg)
   #print "publishing to ",s3path
   #return pg
   if sendToS3:
     s3.s3SetContents(s3path,contents=pg,relativeTo="",contentType="text/html")
   return pg
コード例 #2
0
def emitPage(webin):
  
  sess = webin.session;
  if sess==None:
    user = "";
  else:
    user = sess.user;
  txt = """
<head>
    <link rel="stylesheet" type="text/css" href="/css/imagestyle.css"/>
</head>


<body>
<script>var jQuery; // for commonJS compatability</script>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
"""
  pageName = 'albums_for_image'
  if constants.compressJs:
    txt += cjsForPage(pageName)
  else:
    txt += jsForPage(pageName)
  txt += """
<script>
idv.loggedInUser='******'

$(document).ready(page.initialize);

</script>

"""
  return htmlResponse(txt)
コード例 #3
0
def emitPage(webin):
    Logr.log("page", "EMITTING GALLERY PAGE")
    sess = webin.session
    if sess == None:
        user = ""
    else:
        user = sess.user
    images = {}
    albums = {}

    pg0 = gen.pageHeader(webin, "imageDiver") + """
<body>
"""

    pageName = 'gallery'

    if constants.compressJs:
        pg0 += commonCjsInclude + cjsForPage("gallery") + toJsInclude(
            "/pages/gallery_data.js")
    else:
        pg0 += commonJsIncludes + toJsIncludes(
            jsFiles['gallery']) + toJsInclude("/pages/gallery_data.js")
    """
  
      pg0 +=  commonJsIncludes + jsForPage(pageName)

  if constants.compressJs:
    pg0 += constants.jsPreamble + constants.toJsInclude("/cjs/common.js") +  constants.toJsInclude("/cjs/gallery.js")
  else:
    pg0 +=  constants.commonJsIncludes + constants.toJsInclude("/pages/gallery.js")
  """
    pg0 += """

<script>
$(document).ready(function () {
  page.initialize({loggedInUser:'******'});

});

</script>
<div class="outerDiv">
  <div class="topDiv">
      <div class="topDivTop"></div>
     <div class="titleDiv">the depths of high-resolution images, annotated</div>
  </div>
</div>

</body>
</html>
"""

    return htmlResponse(pg0)
コード例 #4
0
def emitPage(webin):
    sess = webin.session
    if sess == None:
        user = ""
    else:
        user = sess.user

    pg0 = gen.pageHeader(webin,
                         "the depths of high resolution images, annotated",
                         facebook=False) + "<body>"
    pageName = 'images'
    if constants.compressJs:
        pg0 += commonCjsInclude + cjsForPage(pageName)
    else:
        pg0 += commonJsIncludes + jsForPage(pageName)
    """
  var loading = $('<div style="margin:40px"><center>LOADING...  <img src="/ajax-loader.gif"/></center></dir>');
page.loadingDiv = loading;
$('body').append(loading);
 """
    pg1 = """


idv.util.commonInit();
var jsonUrl = "/api/allImages"
idv.util.get(jsonUrl,function (rs) {
  var images = rs.value;
  $('document').ready(
    function () {
      page.initialize(images,loggedInUser,"all");
    });

});
 


</script>
</body>
</html>
"""
    otxt = pg0 + \
      "<script>" + \
       "var loggedInUser='******';\n"
    otxt += constants.emitConstants()
    otxt += pg1

    return htmlResponse(otxt)
コード例 #5
0
def genStdPage(webin,
               pageName,
               options=None,
               pageTitle=None,
               compressJs=None,
               staticSize=False):
    if compressJs == None:
        cjs = constants.compressJs
    else:
        cjs = compressJs
    if cjs:
        jsFiles = commonCjsIncludes() + cjsForPage(pageName)
    else:
        jsFiles = commonJsIncludes() + jsForPage(pageName)
    if options == None: options = {}
    return genDynPage(webin,
                      jsFiles,
                      options,
                      pageTitle=pageTitle,
                      staticSize=staticSize)
コード例 #6
0
def emitPage(webin):

    sess = webin.session
    if sess == None:
        user = ""
    else:
        user = sess.user
    txt = """
<head>
    <link rel="stylesheet" type="text/css" href="/css/imagestyle.css"/>
</head>


<body>
<script>var jQuery; // for commonJS compatability</script>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
"""
    pageName = 'upload_iframe'
    if constants.compressJs:
        txt += cjsForPage(pageName)
    else:
        txt += jsForPage(pageName)
    txt += """
<script>
idv.loggedInUser='******'

$(document).ready(initialize);

</script>


<form id="theForm" target="_self" enctype="multipart/form-data" action="/api/upload?id=333" method="post">
  <p>File: <input id="fileInput" style="color:white" type="file" name="file"/></p>
  <p id="errorP"></p>
  <p><input id ="theButton" type="button" value="Upload"></p>
</form>
</body>
</html>
"""
    return htmlResponse(txt)
コード例 #7
0
import misc

import model.models
models = model.models
import model.snap
snapm = model.snap
import pages.gen
gen = pages.gen
import urlparse


headLines = []
js = ""
pageName = 'post_to_tumblr'
if constants.compressJs:
  js += commonCjsInclude +  cjsForPage(pageName)
else:
  js +=  commonJsIncludes + jsForPage(pageName)


def authorizeTumblr(user,topic):
  tk = oauth_tumblr.requestToken()
  if topic:
    tk["topic"] = topic
  tkj = json.dumps(tk)
  #print "TKJ",tkj
  " the token needs to be saved for a few minutes: until the user authorizes or declines the app "
  dir = "/mnt/ebs1/imagediver/tokens/"
  uname = misc.pathLast(user)
  fln = dir+uname
  f = open(fln,'w')
コード例 #8
0
def genAlbumPage(options, forS3Dev=False):
    vprint("OPTIONSSS", options)
    vprint("CONSTANTS.COMPRESS", constants.compressJs)
    if forS3Dev:
        options["forS3Dev"] = 1
    forHomePage = options.get("forHomePage", False)
    user = options["loggedInUser"]  # the visitor's imageidver user name
    albumOwner = options["albumOwner"]
    imD = options["imageD"]
    imAuthor = imD.get("author", "")
    imTitle = imD.get("title", "")
    published = options["published"]
    albumTopic = options.get("albumTopic", None)
    imageTopic = options.get("imageTopic", None)
    compressJs = options.get("compressJs", False)
    del options["imageD"]
    optionsJson = json.dumps(options)
    if albumTopic:
        sp = albumTopic.split("/")
    else:
        sp = imageTopic.split("/")
    imowner = sp[2]
    imname = sp[3]
    #if albumTopic:
    #  albumname = sp[4]

    path = options["path"]
    pagetext = ""  # LATER fix this; pagetext is for custom pages

    #imageTopic = "/image/"+imowner+"/"+imname
    #albumTopic = "/album/"+imowner+"/"+imname+"/"+albumname;
    #albumD = album.loadAlbumD(albumTopic)
    #imageTopic = albumD.image
    #http://static.imagediver.org/images/4294b03/astoria_1923/resized/width_300.jpg

    if forHomePage:
        imt = "the depths of high-resolution images, annotated"
    else:
        #albumD = album.loadAlbumD(albumTopic)
        if imTitle:
            ttl = imTitle.encode('utf-8')
        else:
            ttl = imname
        #print "TTL",ttl,imAuthor
        imt = ttl + ", " + imAuthor.encode(
            'ascii', errors='ignore'
        ) if imAuthor else ttl  # WORKAROUND - what's wrong here?
    #print "IMT ",imt

    fttl = "ImageDiver" if (path == "/") else "ImageDiver: " + imt
    fdes = "the depths of high-resolution images, annotated" if (
        path == "/") else imt + ", Zoomable and Annotated"
    """fbim = "http://imagediver.s3-website-us-east-1.amazonaws.com/resized300/"+imowner+"/"+imname+".jpg"""
    #fbim = "http://static.imagediver.org/resized300/"+imowner+"/"+imname+".jpg"""
    fbim = "http://static.imagediver.org/images/" + imowner + "/" + imname + "/resized/width_300.jpg" ""
    pg0 = gen.pageHeader(path, fttl, fdes, facebook=True,
                         facebookImage=fbim) + "<body>"
    if compressJs or constants.compressJs:
        pg0 += jsPreamble + cjsForPage("common") + cjsForPage("album")
    else:
        if pagetext:
            pg0 += constants.commonJsIncludes + constants.albumPageJsIncludes  # option not maintained
        else:
            pg0 += constants.jsPreamble + toJsIncludes(
                commonJsFiles, forS3Dev) + toJsIncludes(
                    jsFiles['album'], forS3Dev)

    pg1 = """
<script>
page.initialize({0});
</script>
{1}
<div class="outerDiv">
  <div class="topDiv">
      <div class="topDivTop"></div>
     <div class="titleDiv"> {2} </div>
  </div>
</div>
{3}
</body>
</html>
""".format(optionsJson, pagetext, imt, constants.noScript)
    return pg0 + pg1