Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hh1966
chemotion_eln_server
Commits
53157f8c
Commit
53157f8c
authored
Apr 13, 2019
by
hh1966
Browse files
Change svg image export path
parent
bda77dbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/export/export_collections.rb
View file @
53157f8c
...
...
@@ -68,13 +68,12 @@ module Export
end
# write all the images into an images directory
@images
.
each
do
|
image
|
image_path
=
File
.
join
(
'images'
,
image
[
:file_name
])
image_data
=
File
.
read
(
image
[
:file_path
])
@images
.
each
do
|
file_path
|
image_data
=
File
.
read
(
File
.
join
(
'public'
,
file_path
))
image_checksum
=
Digest
::
SHA256
.
hexdigest
(
image_data
)
zip
.
put_next_entry
imag
e_path
zip
.
put_next_entry
fil
e_path
zip
.
write
image_data
description
+=
"
#{
image_checksum
}
#{
imag
e_path
}
\n
"
description
+=
"
#{
image_checksum
}
#{
fil
e_path
}
\n
"
end
# write the description file
...
...
@@ -152,8 +151,8 @@ module Export
fetch_literals
(
sample
)
# collect the sample_svg_file and molecule_svg_file
fetch_
image
(
'samples'
,
sample
.
sample_svg_file
)
fetch_
image
(
'molecules'
,
sample
.
molecule
.
molecule_svg_file
)
@images
<<
File
.
join
(
'
image
s'
,
'samples'
,
sample
.
sample_svg_file
)
@images
<<
File
.
join
(
'
image
s'
,
'molecules'
,
sample
.
molecule
.
molecule_svg_file
)
end
end
...
...
@@ -188,7 +187,7 @@ module Export
fetch_literals
(
reaction
)
# collect the reaction_svg_file
fetch_
image
(
'reactions'
,
reaction
.
reaction_svg_file
)
@images
<<
File
.
join
(
'
image
s'
,
'reactions'
,
reaction
.
reaction_svg_file
)
end
end
...
...
@@ -256,7 +255,7 @@ module Export
fetch_literals
(
research_plan
)
# collect the svg_file
fetch_
image
(
'research_plans'
,
research_plan
.
svg_file
)
@images
<<
File
.
join
(
'
image
s'
,
'research_plans'
,
research_plan
.
svg_file
)
end
end
...
...
@@ -319,16 +318,6 @@ module Export
end
end
def
fetch_image
(
image_path
,
image_file_name
)
unless
image_file_name
.
nil?
or
image_file_name
.
empty?
file_path
=
File
.
join
(
'public'
,
'images'
,
image_path
,
image_file_name
)
if
File
.
exist?
(
file_path
)
@images
<<
{
:file_name
=>
image_file_name
,
:file_path
=>
file_path
}
end
end
end
def
fetch_many
(
instances
,
foreign_keys
=
{})
instances
.
each
do
|
instance
|
fetch_one
(
instance
,
foreign_keys
)
...
...
lib/import/import_collections.rb
View file @
53157f8c
...
...
@@ -446,7 +446,7 @@ module Import
def
fetch_image
(
image_path
,
image_file_name
)
unless
image_file_name
.
nil?
or
image_file_name
.
empty?
import_file_path
=
File
.
join
(
@directory
,
'images'
,
image_file_name
)
import_file_path
=
File
.
join
(
@directory
,
'images'
,
image_path
,
image_file_name
)
if
File
.
exists?
(
import_file_path
)
# copy extracted file from the import
...
...
@@ -460,12 +460,10 @@ module Import
def
fetch_reaction_image
(
image_file_name
)
unless
image_file_name
.
nil?
or
image_file_name
.
empty?
import_file_path
=
File
.
join
(
@directory
,
'images'
,
image_file_name
)
import_file_path
=
File
.
join
(
@directory
,
'images'
,
'reactions'
,
image_file_name
)
if
File
.
exists?
(
import_file_path
)
File
.
open
(
import_file_path
)
do
|
f
|
f
.
read
()
end
File
.
read
(
import_file_path
)
end
end
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment