Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
slide-index
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Welter, Felix
slide-index
Commits
e46e1c80
Commit
e46e1c80
authored
4 years ago
by
felixwelter
Browse files
Options
Downloads
Patches
Plain Diff
Add option to give title row
parent
1310e543
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app.py
+9
-1
9 additions, 1 deletion
app.py
slide_indexer/basic_indexer.py
+1
-0
1 addition, 0 deletions
slide_indexer/basic_indexer.py
templates/index.html
+5
-1
5 additions, 1 deletion
templates/index.html
with
15 additions
and
2 deletions
app.py
+
9
−
1
View file @
e46e1c80
...
...
@@ -25,6 +25,13 @@ def index():
return
render_template
(
'
index.html
'
,
ll
=
ll
)
@app.route
(
'
/current_index
'
)
def
current_index
():
index
=
Index
(
index_dir
=
INDEX_DIR
)
return
"
<br>
"
.
join
(
[
"
{} {} {}
"
.
format
(
res
[
"
file_name
"
],
res
[
"
page
"
],
res
[
"
title
"
])
for
res
in
index
.
search
(
"
*
"
,
""
)])
def
allowed_file
(
filename
):
return
'
.
'
in
filename
and
filename
.
rsplit
(
'
.
'
,
1
)[
1
].
lower
()
in
[
"
pdf
"
]
...
...
@@ -39,7 +46,8 @@ def upload():
files
=
request
.
files
.
getlist
(
'
files
'
)
index
=
Index
(
index_dir
=
INDEX_DIR
)
indexer
=
BasicIndexer
(
index
,
IMAGE_DIR
)
indexer
.
title_row
=
2
# TODO: Add mechanism for automatic detection of user configuration
if
request
.
form
[
'
title_row
'
]:
indexer
.
title_row
=
int
(
request
.
form
[
'
title_row
'
])
for
i
,
file
in
enumerate
(
files
):
if
file
.
filename
!=
''
:
if
file
and
allowed_file
(
file
.
filename
):
...
...
This diff is collapsed.
Click to expand it.
slide_indexer/basic_indexer.py
+
1
−
0
View file @
e46e1c80
...
...
@@ -20,6 +20,7 @@ class BasicIndexer():
pdf_file_name
=
pdf_file_path
.
split
(
os
.
sep
)[
-
1
]
for
i
,
page
in
enumerate
(
pdf
.
pages
):
text
=
page
.
extract_text
()
print
(
self
.
title_row
)
self
.
index
.
add
(
pdf_file_name
,
i
+
1
,
text
,
text
.
split
(
"
\n
"
)[
self
.
title_row
])
if
self
.
process_images
:
img_name
=
pdf_file_name
+
"
_
"
+
str
(
i
+
1
)
+
"
.jpg
"
...
...
This diff is collapsed.
Click to expand it.
templates/index.html
+
5
−
1
View file @
e46e1c80
...
...
@@ -6,7 +6,8 @@
<h1>
Upload new slide
</h1>
<form
action=
"upload"
enctype=
"multipart/form-data"
method=
"post"
>
<input
type=
"file"
name=
"files"
multiple=
""
>
<input
type=
"submit"
value=
"Upload"
>
<input
type=
"submit"
value=
"Upload"
><br>
Title row:
<input
type=
"number"
name=
"title_row"
>
</form>
<ul>
{% for item in ll %}
...
...
@@ -17,6 +18,9 @@
<form
action=
"reset_index"
method=
"post"
>
<input
type=
"submit"
value=
"Reset Index"
>
</form>
<p>
<a
href=
"current_index"
>
View example of extracted titles
</a>
</p>
<h1>
Query
</h1>
<form
action=
"search"
method=
"post"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment