This repository was archived by the owner on Sep 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +46
-3
lines changed Expand file tree Collapse file tree 5 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -46,3 +46,15 @@ $wgLogos = [
46
46
]
47
47
];
48
48
$wgFavicon = "$wgResourceBasePath/favicon.ico";
49
+
50
+ // Apply config.json
51
+ $config = json_decode(
52
+ file_get_contents( 'config.json' ),
53
+ true
54
+ );
55
+ if ( $config ) {
56
+ foreach ( $config as $key => $value ) {
57
+ $name = "wg$key";
58
+ $$name = $value;
59
+ }
60
+ }
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ date +%s > $PATCHDEMO/wikis/$NAME/created.txt
45
45
# apply our default settings
46
46
cat $PATCHDEMO /LocalSettings.txt >> $PATCHDEMO /wikis/$NAME /w/LocalSettings.php
47
47
48
+ # add site config
49
+ echo " $SITECONFIG " >> $PATCHDEMO /wikis/$NAME /w/config.json
50
+
48
51
# update Main_Page
49
52
sleep 1 # Ensure edit appears after creation in history
50
53
echo " $MAINPAGE " | php $PATCHDEMO /wikis/$NAME /w/maintenance/edit.php " Main_Page"
Original file line number Diff line number Diff line change 1
1
( function ( ) {
2
2
var myWikis , wikisTable ,
3
- form = document . getElementById ( 'new-form' ) ;
3
+ form = document . getElementById ( 'new-form' ) ,
4
+ siteConfig = form . querySelector ( '[name=siteConfig]' ) ;
4
5
5
- form . addEventListener ( 'submit' , function ( ) {
6
+ form . addEventListener ( 'submit' , function ( e ) {
7
+ if ( siteConfig . value . trim ( ) ) {
8
+ try {
9
+ JSON . parse ( siteConfig . value ) ;
10
+ } catch ( err ) {
11
+ e . preventDefault ( ) ;
12
+ alert ( 'Invalid JSON: ' + err . message )
13
+ return ;
14
+ }
15
+ }
6
16
form . querySelector ( 'button[type=submit]' ) . disabled = true ;
7
17
} ) ;
8
18
Original file line number Diff line number Diff line change 27
27
<div>Then, apply patches:</div>
28
28
<textarea name="patches" placeholder="Gerrit changeset number or Change-Id, one per line" rows="4" cols="50"></textarea>
29
29
</label>
30
+ <label>
31
+ <div>Site config:<br/>All keys will be given a <code>$wg</code> prefix.<br/>This file will be <strong>public</strong>.</div>
32
+ <textarea name="siteConfig" placeholder="{
33
+ "Sitename": "Test wiki"
34
+ }" rows="4" cols="50"></textarea>
35
+ </label>
30
36
<button type="submit">Create demo</button>
31
37
</form>
32
38
<br/>
82
88
}
83
89
$ creator = get_creator ( $ dir );
84
90
$ created = get_created ( $ dir );
91
+ $ siteConfig = get_if_file_exists ( 'wikis/ ' . $ dir . '/w/config.json ' );
92
+ $ hasConfig = $ siteConfig && strlen ( trim ( $ siteConfig ) );
85
93
86
94
if ( !$ created ) {
87
95
// Add created.txt to old wikis
94
102
$ wikis [ $ dir ] = [
95
103
'mtime ' => $ created ,
96
104
'title ' => $ title ,
97
- 'creator ' => $ creator
105
+ 'creator ' => $ creator ,
106
+ 'hasConfig ' => $ hasConfig ,
98
107
];
99
108
}
100
109
}
115
124
$ anyCanDelete = $ anyCanDelete || $ canDelete ;
116
125
$ rows .= '<tr ' . ( $ creator !== $ username ? ' class="other" ' : '' ) . '> ' .
117
126
'<td class="title"> ' . $ title . '</td> ' .
127
+ '<td> ' .
128
+ ( $ data [ 'hasConfig ' ] ?
129
+ '<a href="wikis/ ' . $ wiki . '/w/config.json">JSON</a> ' :
130
+ ''
131
+ ) .
132
+ '</td> ' .
118
133
'<td><a href="wikis/ ' . $ wiki . '/w"> ' . $ wiki . '</a></td> ' .
119
134
'<td> ' . date ( 'c ' , $ data [ 'mtime ' ] ) . '</td> ' .
120
135
( $ useOAuth ? '<td> ' . ( $ creator ? user_link ( $ creator ) : '? ' ) . '</td> ' : '' ) .
127
142
128
143
echo '<tr> ' .
129
144
'<th>Patches</th> ' .
145
+ '<th>Config</th> ' .
130
146
'<th>Link</th> ' .
131
147
'<th>Time</th> ' .
132
148
( $ useOAuth ? '<th>Creator</th> ' : '' ) .
Original file line number Diff line number Diff line change 6
6
7
7
$ branch = trim ( $ _POST ['branch ' ] );
8
8
$ patches = $ _POST ['patches ' ];
9
+ $ siteConfig = $ _POST ['siteConfig ' ];
9
10
10
11
$ namePath = md5 ( $ branch . $ patches . time () );
11
12
$ server = ( isset ( $ _SERVER ['HTTPS ' ] ) ? 'https:// ' : 'http:// ' ) . $ _SERVER ['HTTP_HOST ' ];
147
148
'WIKINAME ' => $ wikiName ,
148
149
'CREATOR ' => $ user ? $ user ->username : '' ,
149
150
'MAINPAGE ' => $ mainPage ,
151
+ 'SITECONFIG ' => $ siteConfig ,
150
152
'SERVER ' => $ server ,
151
153
'SERVERPATH ' => $ serverPath ,
152
154
'COMPOSER_HOME ' => __DIR__ . '/composer ' ,
You can’t perform that action at this time.
0 commit comments