Skip to content

Commit

Permalink
move application/opensearchdescription+xml to domain root which is th…
Browse files Browse the repository at this point in the history
…e only place it is used. remove dumb old js way of loading it
  • Loading branch information
arkarkark committed Jan 9, 2018
1 parent 2a34a0b commit 5cec808
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
15 changes: 14 additions & 1 deletion app/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,17 @@ def get(self, lookup, _):
self.redirect(str(jinja2.Template(default_url).render({'url': lookup})))
else:
file_name = os.path.join(os.path.dirname(__file__), 'brand/default.html')
self.response.out.write(open(file_name).read())
file_contents = open(file_name).read()
SEARCH = '<!--search-->'
if users.is_current_user_admin():
file_contents = file_contents.replace(
SEARCH,
'<link title="snippy" rel="search" type="application/opensearchdescription+xml" href="/admin/suggestxml">'
)
else:
file_contents = file_contents.replace(
SEARCH,
'<!-- not admin -->'
)

self.response.out.write(file_contents)
1 change: 1 addition & 0 deletions app/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Snippy(crud_model.CrudNdbModel):
proxy = ndb.BooleanProperty()
promoted = ndb.BooleanProperty()
used_count = ndb.IntegerProperty()
created_date = ndb.DateTimeProperty(auto_now_add=True)

def _pre_put_hook(self):
memcache.delete(MISSING + self.keyword)
Expand Down
1 change: 1 addition & 0 deletions branding.wtwf/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>wtwf.com</title>
<script src="static/vendor.js"></script>
<script src="static/wtwf.js"></script>
<!--search-->
</head>
<body ng-controller="MainController as mainController">
<h1 align=center><u>Whiskey</u> <u>Tango<br>Whiskey</u> <u>Foxtrot</u></h1>
Expand Down
2 changes: 0 additions & 2 deletions client/admin/admin.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ html lang="en" ng-app="Snippy"

link href="/static/snip.css" rel="stylesheet"

link title="snippy" rel="search" type="application/opensearchdescription+xml" href="/admin/suggestxml"

script src="/static/vendor.js"
script src="/static/app.js"

Expand Down
14 changes: 9 additions & 5 deletions client/admin/list.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ ul ng-show="currentUser.can"
li ng-show="currentUser.can.editSnips"
a href="/admin/import/" Import a JSON file of snips
li
a> href="javascript:window.external.AddSearchProvider(window.location.href.split('/').splice(0,3).join('/') + '/admin/suggestxml');"
| Add Snippy Search to your browser
| (xml
a< target="_self" href="/admin/suggestxml" here
| )
| If you have
code &lt;!--search--&gt;
| in your default template then this line will be inserted there to add a default search engine.
br
code
| &lt;link title="snippy" rel="search" type="application/opensearchdescription+xml" href="
a target="_self" href="/admin/suggestxml"
| /admin/suggestxml
| "&gt;

0 comments on commit 5cec808

Please sign in to comment.