diff --git a/pinry/static/js/vue/main.js b/pinry/static/js/vue/main.js new file mode 100644 index 0000000..157ab48 --- /dev/null +++ b/pinry/static/js/vue/main.js @@ -0,0 +1,36 @@ + +function fetchPins(offset) { + var apiUrl = API_BASE + 'pins/?format=json&ordering=-id&limit=50&offset='+String(offset); + if (tagFilter) apiUrl = apiUrl + '&tags__name=' + tagFilter; + if (userFilter) apiUrl = apiUrl + '&submitter__username=' + userFilter; + return axios.get(apiUrl) +} + +var app = new Vue({ + el: '#app', + components: { + 'waterfall': Waterfall.waterfall, + 'waterfall-slot': Waterfall.waterfallSlot, + }, + data() { + return { + pins: [], + loading: true, + } + }, + methods: { + getInitialPins: function () { + var self = this; + var offset = 0; + fetchPins(offset).then( + function (res) { + self.pins = res.data.results; + self.loading = false; + } + ); + }, + }, + created: function () { + this.getInitialPins(); + }, +}); diff --git a/pinry/templates/base.html b/pinry/templates/base.html index f1b10ce..c34ca69 100644 --- a/pinry/templates/base.html +++ b/pinry/templates/base.html @@ -89,28 +89,30 @@ - {% block yield %}{% endblock %} +
+ {% block yield %}{% endblock %} +
- {% include "includes/messages.html" %} - {% include "includes/lightbox.html" %} - {% include "includes/pins.html" %} - {% include "includes/pin_form.html" %} {% block extra_templates %}{% endblock %} + + {% compress js %} - - - - + +{# #} +{# #} +{# #} +{# #} + {% endcompress %} {% compress js inline %} {% block extra_js %}{% endblock %} diff --git a/pinry/templates/core/pins.html b/pinry/templates/core/pins.html index 3f99e09..5d08750 100644 --- a/pinry/templates/core/pins.html +++ b/pinry/templates/core/pins.html @@ -1,6 +1,8 @@ {% extends "base.html" %} {% block yield %} -
-
+
+ {% include "includes/vue-pins.html" %} +
+
{% endblock %} diff --git a/pinry/templates/includes/vue-pins.html b/pinry/templates/includes/vue-pins.html new file mode 100644 index 0000000..770ba1e --- /dev/null +++ b/pinry/templates/includes/vue-pins.html @@ -0,0 +1,16 @@ +{% verbatim %} + + + + + + + + +{% endverbatim %}