11from libzim import ZimArticle , ZimBlob , ZimCreator
22
33class ZimTestArticle (ZimArticle ):
4- content = '''<!DOCTYPE html>
5- <html class="client-js">
6- <head><meta charset="UTF-8">
7- <title>Monadical</title>
8- </head>
9- <h1> ñññ Hello, it works ñññ </h1></html>'''
104
11- def __init__ (self ):
5+ def __init__ (self , url , title , content ):
126 ZimArticle .__init__ (self )
7+ self .url = url
8+ self .title = title
9+ self .content = content
1310
1411 def is_redirect (self ):
1512 return False
1613
17- @property
18- def can_write (self ):
19- return True
20-
2114 def get_url (self ):
22- return "A/Monadical_SAS "
15+ return f "A/{ self . url } "
2316
2417 def get_title (self ):
25- return "Monadical SAS "
18+ return f" { self . title } "
2619
2720 def get_mime_type (self ):
2821 return "text/html"
@@ -41,7 +34,23 @@ def get_data(self):
4134
4235# Create a ZimTestArticle article
4336
44- article = ZimTestArticle ()
37+ content = '''<!DOCTYPE html>
38+ <html class="client-js">
39+ <head><meta charset="UTF-8">
40+ <title>Monadical</title>
41+ </head>
42+ <h1> ñññ Hello, it works ñññ </h1></html>'''
43+
44+ content2 = '''<!DOCTYPE html>
45+ <html class="client-js">
46+ <head><meta charset="UTF-8">
47+ <title>Monadical 2</title>
48+ </head>
49+ <h1> ñññ Hello, it works 2 ñññ </h1></html>'''
50+
51+ article = ZimTestArticle ("Monadical_SAS" , "Monadical" , content )
52+ article2 = ZimTestArticle ("Monadical_2" , "Monadical 2" , content2 )
53+
4554print (article .content )
4655
4756# Write the article
@@ -50,17 +59,19 @@ def get_data(self):
5059
5160test_zim_file_path = "/opt/python-libzim/tests/kiwix-test"
5261
53- zim_creator = ZimCreator (test_zim_file_path + '-' + rnd_str + '.zim' ,main_page = "welcome " ,index_language = "eng" , min_chunk_size = 2048 )
62+ zim_creator = ZimCreator (test_zim_file_path + '-' + rnd_str + '.zim' ,main_page = "Monadical " ,index_language = "eng" , min_chunk_size = 2048 )
5463
55- # Add article to zim file
64+ # Add articles to zim file
5665zim_creator .add_article (article )
66+ zim_creator .add_article (article2 )
5767
5868# Set mandatory metadata
59- if not zim_creator .mandatory_metadata_ok :
69+ if not zim_creator .mandatory_metadata_ok () :
6070 zim_creator .update_metadata (creator = 'python-libzim' ,description = 'Created in python' ,name = 'Hola' ,publisher = 'Monadical' ,title = 'Test Zim' )
6171
72+ print (zim_creator ._get_metadata ())
73+
6274zim_creator .write_metadata (zim_creator ._get_metadata ())
6375
6476# Write articles to zim file
65- zim_creator .finalize ()
66-
77+ zim_creator .finalize ()
0 commit comments