We are looking to remove/disable a macros on our instance of confluence, but we need to run a check to see if any pages are using the plugin to preclude their media from breaking? Can one query the Confluence DB for occurrences of a macros on any pages within Confluence?
You can use the search to find out if a macro was inserted on one or more pages. An example: If you like to know if the multiexcerpt or multiexcerpt-include macro has been used in your Confluence, type macroName:multi* in the Search field, and hit Enter.
Yes, I tried macroName:widget* and it worked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, Ian.
You can do this via the XMLRPC
Here is a example written in python finding all pages with a instance of the thumbnail macro (ac:thumbnail)
Once complete all links containing said macro are written to a errors.json file.
#!/usr/bin/env python import xmlrpclib import json class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' def disable(self): self.HEADER = '' self.OKBLUE = '' self.OKGREEN = '' self.WARNING = '' self.FAIL = '' self.ENDC = '' #Confluence XML-RPC info url = 'http://localhost:1990/rpc/xmlrpc' client = xmlrpclib.Server(url, verbose=0); authToken = client.confluence2.login("admin", "admin"); spaces = client.confluence2.getSpaces(authToken); # Error stack errors = [] # Macro definition we're looking for macro = "ac:thumbnail" for space in spaces: print ("Parsing space: " + space['name']); spacePages = client.confluence2.getPages(authToken,space['key']) for spacePage in spacePages: print ("- Parsing page: " + spacePage['title']); # get the page in question with content page = client.confluence2.getPage(authToken, spacePage["id"]) # did we find the macro definition? if(page["content"].find(macro) > 0): print ("{0}Found {1} macro!{2}".format(bcolors.WARNING, macro, bcolors.ENDC)) errors.append(spacePage["url"]) # print the errors for error in errors: print error["url"] #store the errors with open('errors.json', 'w') as outfile: json.dump([errors], outfile) client.confluence2.logout(authToken)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To view the macro handle, go to a page containing the macro and click Tools->View Storage format
You should now see something like this:
<ac:structured-macro ac:name="tip">
where tip is the macro handle. Try this with the answer by Evelin
Or simply update the lines
# Macro definition we're looking for macro = 'ac:structured-macro ac:name="tip"'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The macro handle for Widget Connector is simply :)
ac:structured-macro ac:name="widget"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.