Comments (15)
A last idea:
Maybe the SHA of the file content could be uploaded to confluence too. Either as additional file, or as postfix in the upload comment.
from md2cf.
Actually that's not a bad idea at all. It could be in the update comment like you suggested, or perhaps as part of the page itself, maybe in a hidden field.
from md2cf.
1.1.2
is up!
from md2cf.
I have a prototype up running, which can skip some pages.
new definition in api.py
:
def get_body(self, page_id):
body = None
try:
params = {
#"id": page_id,
"expand": "body.storage"
}
result = self.api.content(page_id).get(params=params)
body = result["body"]["storage"]["value"]
except:
pass
return body
upsert_page
in __main__.py
gets following change:
print(f"Updating page: {page.title}")
existing_body = confluence.get_body(existing_page.id)
if existing_body.strip("\n") != page.body.strip("\n"): # strip to remove the trailing linebreak from the generated page
confluence.update_page(
page=existing_page,
body=page.body,
parent_id=page.parent_id,
update_message=message,
)
else:
print(f" Page already up to date: {page.title}")
When the page is simple enough this works.
But I found some further differences, which need to escaped.
- For example quotes: the one from the server of course has
"
in it, the generated has"
in it. => can be managed - Another difference are the code macros: the version on the server has
<ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="bfba7d1f-dc91-4acb-9165-e28209c0e32d">
in it.ac:schema-version
andac:macro-id
are not part of the generated document. The schema-version is probably a quick adaption ofblock_code
. But I don't think we should upload a generated ID onto the server.
=> So we probably have to parse the complete xml for differences and ignore these IDs. Urghs. I hate xml parsing.
from md2cf.
Oh, that's actually a very good point. We have two options:
- Keep a local file with the SHA1 of every uploaded page, and only upsert if it's different
- Do some parsing like you suggested, and compare the live page to the one that's about to be uploaded
I feel like the first solution would be tidier, but it requires some persistent storage, which is not always an option (especially in CI pipelines). Hmmm.
Another thing to keep in mind is that the page content might have stayed the same, but an attachment might have been updated.
from md2cf.
Yeah, local files would unfortunately not be ideal for CI (as for our use case).
The attachment problem was indeed skipped by me (because we don't have many, so they're not the main problem).
from md2cf.
I just implemented this in v1.1.0
. You can pass the --only-changed
option, and it will append the hash of the page/attachment at the end of the update comment and compare it :) Of course this will still trigger changes everywhere the first time you run it, as it needs to add the hash to everything, but after that you should be golden.
Let me know if it works alright for you!
from md2cf.
Hey,
Thank you very much for implementing it.
Gonna test it right away.
Best regards,
Marcel
from md2cf.
Hello @iamjackg,
thank you very much for implementing this.
I found a small bug, when the command line option -m
is used, the old hash cannot be determined and the page will not be skipped.
Could you maybe take a look at this? Thank you very much!
Best regards,
Marcel
EDIT:
StR (Upload contains one file, nothing special)
Create new page with -m "Automatic upload of documentation" --only-changed --skip-empty Upload
<< Creating new page: md2cf
Rerun same command:
<< Updating page: md2cf
from md2cf.
I'll take a look tonight :)
from md2cf.
Quick question, does the page you're trying to upload happen to be empty? And what version of Confluence are you running? Did you recently update it?
from md2cf.
I've found the issue btw, I'm about to release a fix. I'm only asking because I'm testing a newer version of Confluence (7.14.1), and it seems like it already doesn't update pages whose content did not change.
from md2cf.
Quick question, does the page you're trying to upload happen to be empty? And what version of Confluence are you running? Did you recently update it?
I created a fresh page for this test. But it also happens with existing pages.
Confluence version is 7.13.3.
Last update was a month ago, I think
Gonna test 1.1.2 right away. Thank you for the quick fix.
from md2cf.
1.1.2 looks good, thank you very much!
from md2cf.
Perfect, I'm gonna close this then. Cheers!
from md2cf.
Related Issues (20)
- mermaid diagrams support HOT 6
- .pages file at top (root) level HOT 2
- Error parsing xhtml: Unexpected character \'>\' (code 62) expected \'=\'\\n HOT 6
- Link parsing fails for document references HOT 1
- PyYaml 6.0 failing with cython 3 update
- Title Checking is Case Sensitive but Confluence Page Uniqueness is Insensitive
- Skip Hidden Folders HOT 2
- Images displayed with a width of less than 400px HOT 2
- Image attachments don't work when using confluence.update_page() HOT 1
- Emoji does not get rendered when it is in line with a bullet
- 500 Server Error: Internal Server Error for url HOT 1
- Support for Obsidian Wikilinks
- `AttributeError` when adding new tags to an existing page HOT 1
- any chance for --only-changed to be compatible with --enable-relative-links ?
- Capability to upload files (pdf, docs...)
- Ignore the pages on upload
- writing page id in the md file
- Inline HTML not supporting
- Add support for adding a prefix to a title to avoid title conflicts
- dependencies are too tight specified
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from md2cf.