Browse Source

Fix #2552 (#2580)

pull/2582/head
Ulysses Lara 6 years ago
committed by Edward
parent
commit
7f9862806f
  1. 6
      sapl/lexml/urls.py
  2. 4
      sapl/lexml/views.py
  3. 16
      sapl/templates/base.html
  4. 8
      sapl/templates/lexml/resultado-pesquisa.html

6
sapl/lexml/urls.py

@ -1,6 +1,6 @@
from django.conf.urls import include, url
from sapl.lexml.views import LexmlProvedorCrud, LexmlPublicadorCrud, lexml_request
from sapl.lexml.views import LexmlProvedorCrud, LexmlPublicadorCrud, lexml_request, request_search
from .apps import AppConfig
@ -11,5 +11,7 @@ urlpatterns = [
include(LexmlProvedorCrud.get_urls())),
url(r'^sistema/lexml/publicador/',
include(LexmlPublicadorCrud.get_urls())),
url(r'^sistema/lexml', lexml_request, name='lexml_endpoint')
url(r'^sistema/lexml/request_search/(?P<keyword>[\w\-]+)/', request_search, name='lexml_search'),
url(r'^sistema/lexml', lexml_request, name='lexml_endpoint'),
]

4
sapl/lexml/views.py

@ -1,4 +1,5 @@
from django.http import HttpResponse
from django.shortcuts import render
from sapl.crud.base import CrudAux
from sapl.lexml.OAIServer import OAIServerFactory, get_config
@ -15,3 +16,6 @@ def lexml_request(request):
r = oai_server.handleRequest(request.GET)
response = r.decode('UTF-8')
return HttpResponse(response, content_type='text/xml')
def request_search(request, keyword):
return render(request,"lexml/resultado-pesquisa.html",{"keyword":keyword})

16
sapl/templates/base.html

@ -44,8 +44,8 @@
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img src="{% webpack_static 'img/search.png' %}"><span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-item">
<form class="navbar-form search-form" method="get" action="http://sapl3.interlegis.leg.br/generico/lexml_pesquisar">
<input type="text" class="form-control" placeholder="Pesquisar no LexML" />
<form id="formulario-lexml" class="navbar-form search-form" method="get" action="">
<input id="input-lexml" type="text" class="form-control" placeholder="Pesquisar no LexML" />
</form>
</li>
</ul>
@ -254,5 +254,17 @@
</script>
{% endblock foot_js %}
<script>
$(document).ready(function(){
var form = document.getElementById("formulario-lexml");
$("#input-lexml").change(function(){
let value = $("#input-lexml").val();
let url = "{% url 'sapl.lexml:lexml_search' 'xxx'%}"
url = url.replace('xxx', value)
form.action = url;
});
});
</script>
</body>
</html>

8
sapl/templates/lexml/resultado-pesquisa.html

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block base_content %}
<iframe style="width:1350px;" src="https://www.lexml.gov.br/busca/search?keyword={{keyword}};" marginwidth="0" marginheight="0" width="100%" height="500px" frameborder="0" title="Resultado da pesquisa no LexML">
<span>O endereço do link é:</span>
</iframe>
{% endblock base_content %}
Loading…
Cancel
Save